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>
This commit is contained in:
Lorn Potter 2021-09-06 15:39:03 +10:00
parent d685c4682b
commit 97be0cca17
2 changed files with 10 additions and 9 deletions

View File

@ -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();

View File

@ -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 {