Bug 1882021 [Linux] Make sure GtkCompositorWidget::mWidget reference is released on nsWindow::Destroy() to avoid nsWindow leak r=emilio

Depends on D203104

Differential Revision: https://phabricator.services.mozilla.com/D203177
This commit is contained in:
stransky 2024-02-29 21:10:16 +00:00
parent bc432c06b4
commit de3474c44a
3 changed files with 15 additions and 1 deletions

View file

@ -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;

View file

@ -36,7 +36,7 @@ class GtkCompositorWidget;
class WindowSurfaceProvider final {
public:
WindowSurfaceProvider();
~WindowSurfaceProvider() = default;
~WindowSurfaceProvider();
/**
* Initializes the WindowSurfaceProvider by giving it the window

View file

@ -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) {