QThreadDataPrivate: fix data race on canWait boolean.
postEvent() accesses it with the postEventList mutex locked, but processEvent() was checking it without any mutex locked. Change-Id: I31bbb50f7a1c337067b8e3de16ee7cd11400b517 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>bb10
parent
49d7e71f77
commit
bf3a5ccef1
|
|
@ -259,10 +259,11 @@ static gboolean postEventSourcePrepare(GSource *s, gint *timeout)
|
|||
gint dummy;
|
||||
if (!timeout)
|
||||
timeout = &dummy;
|
||||
*timeout = data->canWait ? -1 : 0;
|
||||
const bool canWait = data->canWaitLocked();
|
||||
*timeout = canWait ? -1 : 0;
|
||||
|
||||
GPostEventSource *source = reinterpret_cast<GPostEventSource *>(s);
|
||||
return (!data->canWait
|
||||
return (!canWait
|
||||
|| (source->serialNumber.load() != source->lastSerialNumber));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -589,7 +589,7 @@ bool QEventDispatcherUNIX::processEvents(QEventLoop::ProcessEventsFlags flags)
|
|||
QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
|
||||
|
||||
int nevents = 0;
|
||||
const bool canWait = (d->threadData->canWait
|
||||
const bool canWait = (d->threadData->canWaitLocked()
|
||||
&& !d->interrupt.load()
|
||||
&& (flags & QEventLoop::WaitForMoreEvents));
|
||||
|
||||
|
|
|
|||
|
|
@ -231,6 +231,12 @@ public:
|
|||
void ref();
|
||||
void deref();
|
||||
|
||||
bool canWaitLocked()
|
||||
{
|
||||
QMutexLocker locker(&postEventList.mutex);
|
||||
return canWait;
|
||||
}
|
||||
|
||||
QThread *thread;
|
||||
Qt::HANDLE threadId;
|
||||
bool quitNow;
|
||||
|
|
|
|||
Loading…
Reference in New Issue