From 744fd39e66b0b44e65a2505d674fa1cda8b205a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 2 Jun 2017 11:09:55 +0200 Subject: xcb: Don't destroy foreign windows We can't rely on virtual dispatch in the destructor. Task-number: QTBUG-61140 Change-Id: Ib1026caf126095778c24254775cb5a0bfecf3a38 Reviewed-by: Fabian Vogt Reviewed-by: Gatis Paeglis --- src/plugins/platforms/xcb/qxcbintegration.cpp | 18 +----------------- src/plugins/platforms/xcb/qxcbwindow.cpp | 16 ++++++++++------ src/plugins/platforms/xcb/qxcbwindow.h | 12 ++++++++++++ 3 files changed, 23 insertions(+), 23 deletions(-) (limited to 'src/plugins/platforms/xcb') diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index b414bee204..8e3ee20329 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -214,25 +214,9 @@ QPlatformWindow *QXcbIntegration::createPlatformWindow(QWindow *window) const return xcbWindow; } -class QXcbForeignWindow : public QXcbWindow -{ -public: - QXcbForeignWindow(QWindow *window, WId nativeHandle) - : QXcbWindow(window) { m_window = nativeHandle; } - ~QXcbForeignWindow() {} - bool isForeignWindow() const override { return true; } - -protected: - // No-ops - void create() override {} - void destroy() override {} -}; - QPlatformWindow *QXcbIntegration::createForeignWindow(QWindow *window, WId nativeHandle) const { - QXcbWindow *xcbWindow = new QXcbForeignWindow(window, nativeHandle); - xcbWindow->create(); - return xcbWindow; + return new QXcbForeignWindow(window, nativeHandle); } #ifndef QT_NO_OPENGL diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 289d0720e7..d6c69d52ef 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -597,13 +597,17 @@ QXcbWindow::~QXcbWindow() } destroy(); +} - if (isForeignWindow()) { - if (connection()->mouseGrabber() == this) - connection()->setMouseGrabber(Q_NULLPTR); - if (connection()->mousePressWindow() == this) - connection()->setMousePressWindow(Q_NULLPTR); - } +QXcbForeignWindow::~QXcbForeignWindow() +{ + // Clear window so that destroy() does not affect it + m_window = 0; + + if (connection()->mouseGrabber() == this) + connection()->setMouseGrabber(nullptr); + if (connection()->mousePressWindow() == this) + connection()->setMousePressWindow(nullptr); } void QXcbWindow::destroy() diff --git a/src/plugins/platforms/xcb/qxcbwindow.h b/src/plugins/platforms/xcb/qxcbwindow.h index 56628094ee..f38343b6c2 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.h +++ b/src/plugins/platforms/xcb/qxcbwindow.h @@ -278,6 +278,18 @@ protected: xcb_cursor_t m_currentBitmapCursor = XCB_CURSOR_NONE; }; +class QXcbForeignWindow : public QXcbWindow +{ +public: + QXcbForeignWindow(QWindow *window, WId nativeHandle) + : QXcbWindow(window) { m_window = nativeHandle; } + ~QXcbForeignWindow(); + bool isForeignWindow() const override { return true; } + +protected: + void create() override {} // No-op +}; + QT_END_NAMESPACE Q_DECLARE_METATYPE(QXcbWindow*) -- cgit v1.2.3 From 78731b434e0e99ad108601249108e12d8a49c350 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Mon, 20 Feb 2017 19:59:38 +0300 Subject: xcb: Remove XIproto.h include from qxcbxsettings.cpp It indirectly includes X.h with LSBFirst and MSBFirst macros. Use XCB_IMAGE_ORDER_LSB_FIRST and XCB_IMAGE_ORDER_MSB_FIRST macros instead and remove unneeded XCB_USE_XLIB guards. Change-Id: Ic24c9605d0a627253f2793f9feab6c6e19dcda08 Reviewed-by: Gatis Paeglis (cherry picked from commit 538b9f504c0de11c473a40aed66df9900ac1c6c4) Reviewed-by: Oswald Buddenhagen --- src/plugins/platforms/xcb/qxcbxsettings.cpp | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'src/plugins/platforms/xcb') diff --git a/src/plugins/platforms/xcb/qxcbxsettings.cpp b/src/plugins/platforms/xcb/qxcbxsettings.cpp index 401eb8043c..88933c6c22 100644 --- a/src/plugins/platforms/xcb/qxcbxsettings.cpp +++ b/src/plugins/platforms/xcb/qxcbxsettings.cpp @@ -45,10 +45,6 @@ #include #include -#ifdef XCB_USE_XLIB -#include -#endif //XCB_USE_XLIB - QT_BEGIN_NAMESPACE /* Implementation of http://standards.freedesktop.org/xsettings-spec/xsettings-0.5.html */ @@ -145,19 +141,18 @@ public: return value + 4 - remainder; } -#ifdef XCB_USE_XLIB void populateSettings(const QByteArray &xSettings) { if (xSettings.length() < 12) return; char byteOrder = xSettings.at(0); - if (byteOrder != LSBFirst && byteOrder != MSBFirst) { + if (byteOrder != XCB_IMAGE_ORDER_LSB_FIRST && byteOrder != XCB_IMAGE_ORDER_MSB_FIRST) { qWarning("ByteOrder byte %d not 0 or 1", byteOrder); return; } #define ADJUST_BO(b, t, x) \ - ((b == LSBFirst) ? \ + ((b == XCB_IMAGE_ORDER_LSB_FIRST) ? \ qFromLittleEndian(x) : \ qFromBigEndian(x)) #define VALIDATE_LENGTH(x) \ @@ -220,7 +215,6 @@ public: } } -#endif //XCB_USE_XLIB QXcbVirtualDesktop *screen; xcb_window_t x_settings_window; @@ -267,10 +261,8 @@ QXcbXSettings::QXcbXSettings(QXcbVirtualDesktop *screen) const uint32_t event_mask[] = { XCB_EVENT_MASK_STRUCTURE_NOTIFY|XCB_EVENT_MASK_PROPERTY_CHANGE }; xcb_change_window_attributes(screen->xcb_connection(),d_ptr->x_settings_window,event,event_mask); -#ifdef XCB_USE_XLIB d_ptr->populateSettings(d_ptr->getSettings()); d_ptr->initialized = true; -#endif //XCB_USE_XLIB } QXcbXSettings::~QXcbXSettings() @@ -290,9 +282,8 @@ void QXcbXSettings::handlePropertyNotifyEvent(const xcb_property_notify_event_t Q_D(QXcbXSettings); if (event->window != d->x_settings_window) return; -#ifdef XCB_USE_XLIB + d->populateSettings(d->getSettings()); -#endif //XCB_USE_XLIB } void QXcbXSettings::registerCallbackForProperty(const QByteArray &property, QXcbXSettings::PropertyChangeFunc func, void *handle) -- cgit v1.2.3