summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2017-03-16 10:04:01 +0100
committerOlivier Goffart (Woboq GmbH) <ogoffart@woboq.com>2017-03-27 12:35:45 +0000
commitd9e2574ec82a99a5efa272124e8f5298378720b1 (patch)
treee33e170bc5568df0e553969874ae5c4296a1fd59 /src
parentb7d2a040dfb4af3b152e8950e294e9c9f998d040 (diff)
Fix crash in QWindowPrivate::applyCursor when screen is null
QWindow::setVisible calls QWindowPrivate::applyCursor without checking if screen() returns null. This patch adds a check in QWindowPrivate::applyCursor that the screen is not null. Now that it is tested there, no need to test it from the other caller (setCursor) This patch should not change behavior of setCursor at all, it should only fix the crash when coming from setVisible Task-number: QTBUG-59528 Change-Id: I06bbdb4e04c02ac840ba637242d1f2cfde5bdd62 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit 5cda0172e0eb912ef4814f3c5618686cbb1a5da1)
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qwindow.cpp17
-rw-r--r--src/gui/kernel/qwindow_p.h2
2 files changed, 11 insertions, 8 deletions
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index c7ad10a46f..72a7f48cff 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -2516,26 +2516,29 @@ void QWindowPrivate::setCursor(const QCursor *newCursor)
cursor = QCursor(Qt::ArrowCursor);
hasCursor = false;
}
- // Only attempt to set cursor and emit signal if there is an actual platform cursor
- QScreen* screen = q->screen();
- if (screen && screen->handle()->cursor()) {
- applyCursor();
+ // Only attempt to emit signal if there is an actual platform cursor
+ if (applyCursor()) {
QEvent event(QEvent::CursorChange);
QGuiApplication::sendEvent(q, &event);
}
}
-void QWindowPrivate::applyCursor()
+// Apply the cursor and returns true iff the platform cursor exists
+bool QWindowPrivate::applyCursor()
{
Q_Q(QWindow);
- if (platformWindow) {
- if (QPlatformCursor *platformCursor = q->screen()->handle()->cursor()) {
+ if (QScreen *screen = q->screen()) {
+ if (QPlatformCursor *platformCursor = screen->handle()->cursor()) {
+ if (!platformWindow)
+ return true;
QCursor *c = QGuiApplication::overrideCursor();
if (!c && hasCursor)
c = &cursor;
platformCursor->changeCursor(c, q);
+ return true;
}
}
+ return false;
}
#endif // QT_NO_CURSOR
diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h
index 6880edaada..aefe2b2b9a 100644
--- a/src/gui/kernel/qwindow_p.h
+++ b/src/gui/kernel/qwindow_p.h
@@ -111,7 +111,7 @@ public:
void maybeQuitOnLastWindowClosed();
#ifndef QT_NO_CURSOR
void setCursor(const QCursor *c = 0);
- void applyCursor();
+ bool applyCursor();
#endif
void deliverUpdateRequest();