Do not call setCursor on Desktop or if there is no platform window.

Fix a crash on Windows.

Change-Id: I2b88e113d7149444ebc8946c0ee0eba7a9b5bbc2
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
Friedemann Kleint 2011-10-27 13:25:14 +02:00 committed by Qt by Nokia
parent 919c5982b8
commit ddce31c12f

View File

@ -1220,6 +1220,14 @@ static void applyCursor(QWindow *w, const QCursor &c)
} }
} }
static inline void applyCursor(const QList<QWindow *> &l, const QCursor &c)
{
for (int i = 0; i < l.size(); ++i) {
QWindow *w = l.at(i);
if (w->handle() && w->windowType() != Qt::Desktop)
applyCursor(w, c);
}
}
/*! /*!
\fn void QGuiApplication::setOverrideCursor(const QCursor &cursor) \fn void QGuiApplication::setOverrideCursor(const QCursor &cursor)
@ -1250,8 +1258,7 @@ static void applyCursor(QWindow *w, const QCursor &c)
void QGuiApplication::setOverrideCursor(const QCursor &cursor) void QGuiApplication::setOverrideCursor(const QCursor &cursor)
{ {
qGuiApp->d_func()->cursor_list.prepend(cursor); qGuiApp->d_func()->cursor_list.prepend(cursor);
for (int i = 0; i < QGuiApplicationPrivate::window_list.size(); ++i) applyCursor(QGuiApplicationPrivate::window_list, cursor);
applyCursor(QGuiApplicationPrivate::window_list.at(i), cursor);
} }
/*! /*!
@ -1271,8 +1278,7 @@ void QGuiApplication::restoreOverrideCursor()
return; return;
qGuiApp->d_func()->cursor_list.removeFirst(); qGuiApp->d_func()->cursor_list.removeFirst();
QCursor c(qGuiApp->d_func()->cursor_list.value(0, QCursor())); QCursor c(qGuiApp->d_func()->cursor_list.value(0, QCursor()));
for (int i = 0; i < QGuiApplicationPrivate::window_list.size(); ++i) applyCursor(QGuiApplicationPrivate::window_list, c);
applyCursor(QGuiApplicationPrivate::window_list.at(i), c);
} }
#endif// QT_NO_CURSOR #endif// QT_NO_CURSOR