Fix race condition on mWaitingForUpdateDelivery
Change-Id: I0e91bda73722468b9339fc434fe04420b5e7d3da Reviewed-by: David Edmundson <davidedmundson@kde.org>
This commit is contained in:
parent
eddb08768f
commit
b41a7e47ee
@ -716,18 +716,17 @@ void QWaylandWindow::handleFrameCallback()
|
|||||||
mFrameCallbackElapsedTimer.invalidate();
|
mFrameCallbackElapsedTimer.invalidate();
|
||||||
|
|
||||||
// The rest can wait until we can run it on the correct thread
|
// The rest can wait until we can run it on the correct thread
|
||||||
if (!mWaitingForUpdateDelivery) {
|
if (mWaitingForUpdateDelivery.testAndSetAcquire(false, true)) {
|
||||||
// Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
|
// Queued connection, to make sure we don't call handleUpdate() from inside waitForFrameSync()
|
||||||
// in the single-threaded case.
|
// in the single-threaded case.
|
||||||
mWaitingForUpdateDelivery = true;
|
|
||||||
QMetaObject::invokeMethod(this, &QWaylandWindow::doHandleFrameCallback, Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, &QWaylandWindow::doHandleFrameCallback, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
mFrameSyncWait.notify_all();
|
mFrameSyncWait.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandWindow::doHandleFrameCallback()
|
void QWaylandWindow::doHandleFrameCallback()
|
||||||
{
|
{
|
||||||
|
mWaitingForUpdateDelivery.storeRelease(false);
|
||||||
bool wasExposed = isExposed();
|
bool wasExposed = isExposed();
|
||||||
mFrameCallbackTimedOut = false;
|
mFrameCallbackTimedOut = false;
|
||||||
if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
|
if (!wasExposed && isExposed()) // Did setting mFrameCallbackTimedOut make the window exposed?
|
||||||
@ -735,7 +734,6 @@ void QWaylandWindow::doHandleFrameCallback()
|
|||||||
if (wasExposed && hasPendingUpdateRequest())
|
if (wasExposed && hasPendingUpdateRequest())
|
||||||
deliverUpdateRequest();
|
deliverUpdateRequest();
|
||||||
|
|
||||||
mWaitingForUpdateDelivery = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QWaylandWindow::waitForFrameSync(int timeout)
|
bool QWaylandWindow::waitForFrameSync(int timeout)
|
||||||
|
@ -283,7 +283,7 @@ protected:
|
|||||||
WId mWindowId;
|
WId mWindowId;
|
||||||
bool mWaitingForFrameCallback = false;
|
bool mWaitingForFrameCallback = false;
|
||||||
bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
|
bool mFrameCallbackTimedOut = false; // Whether the frame callback has timed out
|
||||||
bool mWaitingForUpdateDelivery = false;
|
QAtomicInt mWaitingForUpdateDelivery = false;
|
||||||
int mFrameCallbackCheckIntervalTimerId = -1;
|
int mFrameCallbackCheckIntervalTimerId = -1;
|
||||||
QElapsedTimer mFrameCallbackElapsedTimer;
|
QElapsedTimer mFrameCallbackElapsedTimer;
|
||||||
struct ::wl_callback *mFrameCallback = nullptr;
|
struct ::wl_callback *mFrameCallback = nullptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user