Fix crash in flushWindowSystemEvents() in QGuiApplication-cleanup.

Check for existence of QGuiApplication, discard events if it is 0.

Change-Id: I04b27679033fb13ef2fa38e39757d89465cba94b
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
This commit is contained in:
Friedemann Kleint 2013-03-04 21:25:39 +01:00 committed by The Qt Project
parent 09fb084e3a
commit 7a5fea113e
2 changed files with 13 additions and 2 deletions

View File

@ -527,6 +527,16 @@ void QWindowSystemInterface::deferredFlushWindowSystemEvents()
void QWindowSystemInterface::flushWindowSystemEvents()
{
const int count = QWindowSystemInterfacePrivate::windowSystemEventQueue.count();
if (!count)
return;
if (!QGuiApplication::instance()) {
qWarning().nospace()
<< "QWindowSystemInterface::flushWindowSystemEvents() invoked after "
"QGuiApplication destruction, discarding " << count << " events.";
QWindowSystemInterfacePrivate::windowSystemEventQueue.clear();
return;
}
if (QThread::currentThread() != QGuiApplication::instance()->thread()) {
QMutexLocker locker(&QWindowSystemInterfacePrivate::flushEventMutex);
QWindowSystemInterfacePrivate::FlushEventsEvent *e = new QWindowSystemInterfacePrivate::FlushEventsEvent();

View File

@ -387,9 +387,10 @@ public:
mutable QMutex mutex;
public:
WindowSystemEventList() : impl(), mutex() {}
~WindowSystemEventList()
{ const QMutexLocker locker(&mutex); qDeleteAll(impl); impl.clear(); }
~WindowSystemEventList() { clear(); }
void clear()
{ const QMutexLocker locker(&mutex); qDeleteAll(impl); impl.clear(); }
void prepend(WindowSystemEvent *e)
{ const QMutexLocker locker(&mutex); impl.prepend(e); }
WindowSystemEvent *takeFirstOrReturnNull()