From 97be0cca174a3b92c24062c557bf4df34db23f7b Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Mon, 6 Sep 2021 15:39:03 +1000 Subject: [PATCH] wasm: fix changing cursor shape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous implementation would occasionally result in a crash when a window was closed. Apparently 'auto' cursor does not work so well, so we now use 'default' name. Fixes: QTBUG-96178 Pick-to: 6.2 5.15 Change-Id: I0179d20dbdc01f0e3021d746324e1e39c678a298 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/wasm/qwasmcursor.cpp | 16 ++++++++++------ .../platforms/wasm/qwasmeventtranslator.cpp | 3 --- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/plugins/platforms/wasm/qwasmcursor.cpp b/src/plugins/platforms/wasm/qwasmcursor.cpp index 61204517ce3..4b4bb610719 100644 --- a/src/plugins/platforms/wasm/qwasmcursor.cpp +++ b/src/plugins/platforms/wasm/qwasmcursor.cpp @@ -41,20 +41,24 @@ using namespace emscripten; void QWasmCursor::changeCursor(QCursor *windowCursor, QWindow *window) { - if (!windowCursor || !window) + if (!window) return; QScreen *screen = window->screen(); if (!screen) return; - // Bitmap and custom cursors are not implemented (will fall back to "auto") - if (windowCursor->shape() == Qt::BitmapCursor || windowCursor->shape() >= Qt::CustomCursor) - qWarning() << "QWasmCursor: bitmap and custom cursors are not supported"; + QByteArray htmlCursorName; + if (windowCursor) { - QByteArray htmlCursorName = cursorShapeToHtml(windowCursor->shape()); + // Bitmap and custom cursors are not implemented (will fall back to "auto") + if (windowCursor->shape() == Qt::BitmapCursor || windowCursor->shape() >= Qt::CustomCursor) + qWarning() << "QWasmCursor: bitmap and custom cursors are not supported"; + + htmlCursorName = cursorShapeToHtml(windowCursor->shape()); + } if (htmlCursorName.isEmpty()) - htmlCursorName = "auto"; + htmlCursorName = "default"; // Set cursor on the canvas val canvas = QWasmScreen::get(screen)->canvas(); diff --git a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp index 1344af38168..dff914fdc0a 100644 --- a/src/plugins/platforms/wasm/qwasmeventtranslator.cpp +++ b/src/plugins/platforms/wasm/qwasmeventtranslator.cpp @@ -444,9 +444,6 @@ bool QWasmEventTranslator::processMouse(int eventType, const EmscriptenMouseEven if (resizeMode == QWasmWindow::ResizeNone) window2 = screen()->compositor()->windowAt(globalPoint, 5); - if (lastWindow && lastWindow->cursor() != Qt::ArrowCursor) { - lastWindow->setCursor(Qt::ArrowCursor); - } if (window2 == nullptr) { window2 = lastWindow; } else {