From 97be0cca174a3b92c24062c557bf4df34db23f7b Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Mon, 6 Sep 2021 15:39:03 +1000 Subject: 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 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/plugins/platforms/wasm/qwasmcursor.cpp') 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(); -- cgit v1.2.3