Avoid crashing race condition.

Change-Id: I940bcbc509a689804a02f71af45f5efc19bccf9f
Reviewed-by: Giulio Camuffo <giulio.camuffo@jollamobile.com>
This commit is contained in:
Gunnar Sletta 2014-06-30 11:14:52 +02:00
parent 0bfe40dc8d
commit c0847e9144

View File

@ -54,6 +54,7 @@
#include "qwaylandwindowmanagerintegration_p.h"
#include <QtCore/QFileInfo>
#include <QtCore/QPointer>
#include <QtGui/QWindow>
#include <QGuiApplication>
@ -245,9 +246,14 @@ void QWaylandWindow::setVisible(bool visible)
// QWaylandShmBackingStore::beginPaint().
} else {
QWindowSystemInterface::handleExposeEvent(window(), QRegion());
// when flushing the event queue, it could contain a close event, in which
// case 'this' will be deleted. When that happens, we must abort right away.
QPointer<QWaylandWindow> deleteGuard(this);
QWindowSystemInterface::flushWindowSystemEvents();
attach(static_cast<QWaylandBuffer *>(0), 0, 0);
commit();
if (!deleteGuard.isNull()) {
attach(static_cast<QWaylandBuffer *>(0), 0, 0);
commit();
}
}
}