Skip to content

Commit

Permalink
Bug 1882021 [Linux] Make sure GtkCompositorWidget::mWidget reference …
Browse files Browse the repository at this point in the history
…is released on nsWindow::Destroy() to avoid nsWindow leak r=emilio

Depends on D203104

Differential Revision: https://phabricator.services.mozilla.com/D203177
  • Loading branch information
stransky committed Feb 29, 2024
1 parent bc432c0 commit de3474c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions widget/gtk/WindowSurfaceProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ WindowSurfaceProvider::WindowSurfaceProvider()
{
}

WindowSurfaceProvider::~WindowSurfaceProvider() {
#ifdef MOZ_WAYLAND
MOZ_DIAGNOSTIC_ASSERT(!mWidget,
"nsWindow reference is still live, we're leaking it!");
#endif
#ifdef MOZ_X11
MOZ_DIAGNOSTIC_ASSERT(!mXWindow, "mXWindow should be released on quit!");
#endif
}

#ifdef MOZ_WAYLAND
void WindowSurfaceProvider::Initialize(RefPtr<nsWindow> aWidget) {
mWindowSurfaceValid = false;
Expand Down
2 changes: 1 addition & 1 deletion widget/gtk/WindowSurfaceProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class GtkCompositorWidget;
class WindowSurfaceProvider final {
public:
WindowSurfaceProvider();
~WindowSurfaceProvider() = default;
~WindowSurfaceProvider();

/**
* Initializes the WindowSurfaceProvider by giving it the window
Expand Down
4 changes: 4 additions & 0 deletions widget/gtk/nsWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,10 @@ void nsWindow::Destroy() {

DestroyLayerManager();

// mSurfaceProvider holds reference to this nsWindow so we need to explicitly
// clear it here to avoid nsWindow leak.
mSurfaceProvider.CleanupResources();

g_signal_handlers_disconnect_by_data(gtk_settings_get_default(), this);

if (mIMContext) {
Expand Down

0 comments on commit de3474c

Please sign in to comment.