Fix deadlock in QWaylandWindow::waitForFrameSync

Calling the QOpenGLContext::swapBuffers from
QGuiApplicationPrivate::processExposeEvent in some cases leads to
recursive calls of QWaylandWindow::waitForFrameSync. Since the
mWaitingForFrameCallback check in WaylandWindow::waitForFrameSync
is performed after the mutex is locked, the QMutexLocker tries to lock the
mFrameSyncMutex mutex in every recursive call, that leads to a deadlock.
This patch moves the performing of the mWaitingForFrameCallback check
before locking the mutex.

Change-Id: Ia2d834b7dd03fcd91bbe29a3a897b4db2d155527
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
This commit is contained in:
Pavel Tumakaev 2019-07-31 13:26:51 +03:00
parent 84acc4a4e9
commit c3960e5997

View File

@ -657,10 +657,11 @@ QMutex QWaylandWindow::mFrameSyncMutex;
bool QWaylandWindow::waitForFrameSync(int timeout)
{
QMutexLocker locker(&mFrameSyncMutex);
if (!mWaitingForFrameCallback)
return true;
QMutexLocker locker(&mFrameSyncMutex);
wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(mFrameCallback), mFrameQueue);
mDisplay->dispatchQueueWhile(mFrameQueue, [&]() { return mWaitingForFrameCallback; }, timeout);