From c9909b7ce9f307583b209e3d6fdecd2d211dff1b Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 3 Dec 2014 16:36:13 +0100 Subject: [PATCH 1/2] Silence uninited variable compiler warnings The code is correct but some compilers may still warn about dragData not getting initialized. Silence them. Change-Id: Ib52321667fc5094e22ebbef538b72b5477e6f10b Reviewed-by: Giulio Camuffo --- src/plugins/platforms/wayland/qwaylanddatadevice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/wayland/qwaylanddatadevice.cpp b/src/plugins/platforms/wayland/qwaylanddatadevice.cpp index 83e74ce6ca9..edf73a56a3e 100644 --- a/src/plugins/platforms/wayland/qwaylanddatadevice.cpp +++ b/src/plugins/platforms/wayland/qwaylanddatadevice.cpp @@ -126,7 +126,7 @@ void QWaylandDataDevice::data_device_drop() qDebug() << Q_FUNC_INFO << drag << m_dragOffer.data(); - QMimeData *dragData; + QMimeData *dragData = 0; Qt::DropActions supportedActions; if (drag) { dragData = drag->mimeData(); From d2e278e4e2a155a74ca6f3e072bc53eb05bda5f7 Mon Sep 17 00:00:00 2001 From: Giulio Camuffo Date: Sat, 6 Dec 2014 19:57:39 +0200 Subject: [PATCH 2/2] Fix possible double free when hiding a window There was a race condition between the gui and the wayland event thread which could lead to double freeing the QWaylandShmBackingStore's frame callback. Protect the wl_callback_destroy calls using a mutex. Change-Id: Ia70ebac208a6d4450328ba5254a850be26d84d6d Reviewed-by: Laszlo Agocs --- src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp | 3 +++ src/plugins/platforms/wayland/qwaylandshmbackingstore_p.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp b/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp index d407335d3f7..6ca65f053aa 100644 --- a/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp +++ b/src/plugins/platforms/wayland/qwaylandshmbackingstore.cpp @@ -46,6 +46,7 @@ #include #include +#include #include #include @@ -180,6 +181,7 @@ void QWaylandShmBackingStore::endPaint() void QWaylandShmBackingStore::hidden() { + QMutexLocker lock(&mMutex); if (mFrameCallback) { wl_callback_destroy(mFrameCallback); mFrameCallback = Q_NULLPTR; @@ -341,6 +343,7 @@ void QWaylandShmBackingStore::done(void *data, wl_callback *callback, uint32_t t static_cast(data); if (callback != self->mFrameCallback) // others, like QWaylandWindow, may trigger callbacks too return; + QMutexLocker lock(&self->mMutex); QWaylandWindow *window = self->waylandWindow(); wl_callback_destroy(self->mFrameCallback); self->mFrameCallback = 0; diff --git a/src/plugins/platforms/wayland/qwaylandshmbackingstore_p.h b/src/plugins/platforms/wayland/qwaylandshmbackingstore_p.h index 1212e52fe33..c0d730deead 100644 --- a/src/plugins/platforms/wayland/qwaylandshmbackingstore_p.h +++ b/src/plugins/platforms/wayland/qwaylandshmbackingstore_p.h @@ -47,6 +47,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -106,6 +107,7 @@ private: QWaylandShmBuffer *mBackBuffer; bool mFrontBufferIsDirty; bool mPainting; + QMutex mMutex; QSize mRequestedSize; Qt::WindowFlags mCurrentWindowFlags;