From c78370cabc56668f45bdc2e96eaa8a1565d52c85 Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Mon, 17 Oct 2022 22:18:58 +0100 Subject: [PATCH] xcb: correctly disconnect xsettings callbacks registerCallbackForProperty can be initialized without us completely initialializing a GTK theme. We need a different guard for the destructor. (part cherry-picked from 012132c60d625b2de0039bdda3c22a0a8fe2dfe5) --- src/plugins/platforms/xcb/qxcbcursor.cpp | 8 +++++--- src/plugins/platforms/xcb/qxcbcursor.h | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp index 4210bf428e..0670b6ebce 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.cpp +++ b/src/plugins/platforms/xcb/qxcbcursor.cpp @@ -300,7 +300,7 @@ QXcbCursorCacheKey::QXcbCursorCacheKey(const QCursor &c) #endif // !QT_NO_CURSOR QXcbCursor::QXcbCursor(QXcbConnection *conn, QXcbScreen *screen) - : QXcbObject(conn), m_screen(screen), m_gtkCursorThemeInitialized(false) + : QXcbObject(conn), m_screen(screen), m_gtkCursorThemeInitialized(false), m_callbackForPropertyRegistered(false) { #if QT_CONFIG(cursor) // see NUM_BITMAPS in libXcursor/src/xcursorint.h @@ -343,7 +343,7 @@ QXcbCursor::~QXcbCursor() { xcb_connection_t *conn = xcb_connection(); - if (m_gtkCursorThemeInitialized) { + if (m_callbackForPropertyRegistered) { m_screen->xSettings()->removeCallbackForHandle(this); } @@ -562,8 +562,10 @@ xcb_cursor_t QXcbCursor::createFontCursor(int cshape) xcb_cursor_t cursor = XCB_NONE; #if QT_CONFIG(xcb_xlib) && QT_CONFIG(library) - if (m_screen->xSettings()->initialized()) + if (m_screen->xSettings()->initialized()) { m_screen->xSettings()->registerCallbackForProperty("Gtk/CursorThemeName",cursorThemePropertyChanged,this); + m_callbackForPropertyRegistered = true; + } // Try Xcursor first if (cshape >= 0 && cshape <= Qt::LastCursor) { diff --git a/src/plugins/platforms/xcb/qxcbcursor.h b/src/plugins/platforms/xcb/qxcbcursor.h index 0b238823f0..82fb47e55d 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.h +++ b/src/plugins/platforms/xcb/qxcbcursor.h @@ -122,6 +122,7 @@ private: void *handle); #endif bool m_gtkCursorThemeInitialized; + bool m_callbackForPropertyRegistered; }; QT_END_NAMESPACE -- GitLab