From 84c3fcffd937d2e826cc9f835a44a63490b62dcf Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Tue, 21 May 2019 09:06:30 +0200 Subject: [PATCH 1/3] Client: Don't crash when the cursor theme fails to load Fixes: QTBUG-75920 Change-Id: I29d84b487afb2a90b8a633abce2fcc39ca75adae Reviewed-by: Paul Olav Tvete Reviewed-by: Jani Heikkinen --- src/plugins/platforms/wayland/qwaylandinputdevice.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp index 39c02d962c7..7f6f01cd1b9 100644 --- a/src/plugins/platforms/wayland/qwaylandinputdevice.cpp +++ b/src/plugins/platforms/wayland/qwaylandinputdevice.cpp @@ -272,6 +272,10 @@ void QWaylandInputDevice::Pointer::updateCursorTheme() int pixelSize = cursorSize() * scale; auto *display = seat()->mQDisplay; mCursor.theme = display->loadCursorTheme(cursorThemeName(), pixelSize); + + if (!mCursor.theme) + return; // A warning has already been printed in loadCursorTheme + if (auto *arrow = mCursor.theme->cursorImage(Qt::ArrowCursor)) { int arrowPixelSize = qMax(arrow->width, arrow->height); // Not all cursor themes are square while (scale > 1 && arrowPixelSize / scale < cursorSize()) @@ -310,6 +314,9 @@ void QWaylandInputDevice::Pointer::updateCursor() if (!mCursor.theme || idealCursorScale() != mCursor.themeBufferScale) updateCursorTheme(); + if (!mCursor.theme) + return; + // Set from shape using theme if (struct ::wl_cursor_image *image = mCursor.theme->cursorImage(shape)) { struct wl_buffer *buffer = wl_cursor_image_get_buffer(image); From 1c59778c10ddcebfdef182c7a2fe82c280af9d2a Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Wed, 5 Jun 2019 13:10:38 +0200 Subject: [PATCH 2/3] Client: Don't add all windows to activePopups Neither Qt::ToolTip nor Qt::Popup are single bits in Qt::WindowFlags, and do in fact include Qt::Window. This meant that when we or'ed them and did a bitwise and with QWindow::type(), we would match more types than just Qt::Popup and Qt::ToolTip. We would for instance get any Qt::Window as well, which meant the main window would be added to activePopups, leading to strange things happening, such as crashes and the main window closing unexpectedly. [ChangeLog][QPA plugin] Fixed a crash when closing multiple popups at once. Fixes: QTBUG-76124 Change-Id: I1a6a59e161a436604a7ac8ab824396481dc99a20 Reviewed-by: Paul Olav Tvete (cherry picked from commit 4a9a5e2f62935488b1eeb06cd5d69a168a5a9308) --- src/plugins/platforms/wayland/qwaylandwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/platforms/wayland/qwaylandwindow.cpp b/src/plugins/platforms/wayland/qwaylandwindow.cpp index 4532bc23607..8b2c12277c5 100644 --- a/src/plugins/platforms/wayland/qwaylandwindow.cpp +++ b/src/plugins/platforms/wayland/qwaylandwindow.cpp @@ -387,7 +387,7 @@ QWaylandScreen *QWaylandWindow::calculateScreenFromSurfaceEvents() const void QWaylandWindow::setVisible(bool visible) { if (visible) { - if (window()->type() & (Qt::Popup | Qt::ToolTip)) + if (window()->type() == Qt::Popup || window()->type() == Qt::ToolTip) activePopups << this; initWindow(); mDisplay->flushRequests(); From 002fade6293be14991e90e599b1c9d1954c21e97 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Wed, 12 Jun 2019 16:03:13 +0200 Subject: [PATCH 3/3] Don't crash if we start a drag without dragFocus Sometimes origin will be nullptr, triggering a crash. [ChangeLog][QPA plugin] Fixed a crash that sometimes happened when starting a drag-and-drop operation. Fixes: QTBUG-76368 Change-Id: I8f4e6b05f073644834c3c72a8307dac5b897f626 Reviewed-by: Johan Helsing --- src/plugins/platforms/wayland/qwaylanddatadevice.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/wayland/qwaylanddatadevice.cpp b/src/plugins/platforms/wayland/qwaylanddatadevice.cpp index 300c9de0aa8..11984f9d394 100644 --- a/src/plugins/platforms/wayland/qwaylanddatadevice.cpp +++ b/src/plugins/platforms/wayland/qwaylanddatadevice.cpp @@ -111,7 +111,10 @@ void QWaylandDataDevice::startDrag(QMimeData *mimeData, QWaylandWindow *icon) if (!origin) origin = m_display->currentInputDevice()->touchFocus(); - start_drag(m_dragSource->object(), origin->object(), icon->object(), m_display->currentInputDevice()->serial()); + if (origin) + start_drag(m_dragSource->object(), origin->object(), icon->object(), m_display->currentInputDevice()->serial()); + else + qCDebug(lcQpaWayland) << "Couldn't start a drag because the origin window could not be found."; } void QWaylandDataDevice::cancelDrag()