diff options
author | Lorn Potter <lorn.potter@gmail.com> | 2021-09-06 15:39:03 +1000 |
---|---|---|
committer | Lorn Potter <lorn.potter@gmail.com> | 2021-10-29 04:18:34 +0000 |
commit | 97be0cca174a3b92c24062c557bf4df34db23f7b (patch) | |
tree | c77cf9213dd0d0ce754d9758cb8207136fe2a2e8 /src | |
parent | d685c4682bb7b7cd8e52f56982e7d50ce1698c46 (diff) |
wasm: fix changing cursor shape
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 <morten.sorvig@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platforms/wasm/qwasmcursor.cpp | 16 | ||||
-rw-r--r-- | src/plugins/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 61204517ce..4b4bb61071 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 1344af3816..dff914fdc0 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 { |