[*] a050d42e
replacement - add a thread local event dispatcher provider instead
Change-Id: Idca428809312dc95c80096e2a08a21ff233c03cb
This commit is contained in:
parent
a95f64ef44
commit
c37f6d7e03
@ -160,7 +160,7 @@ void QBasicTimer::start(std::chrono::milliseconds duration, Qt::TimerType timerT
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gGlobalEventDispatcher)
|
||||
if (!gGetLocalEventDispatcher)
|
||||
{
|
||||
if (Q_UNLIKELY(obj && obj->thread() != eventDispatcher->thread())) {
|
||||
qWarning("QBasicTimer::start: Timers cannot be started from another thread");
|
||||
@ -183,21 +183,11 @@ void QBasicTimer::stop()
|
||||
if (id) {
|
||||
QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance();
|
||||
|
||||
if (!gGlobalEventDispatcher)
|
||||
{
|
||||
if (eventDispatcher && !eventDispatcher->unregisterTimer(id)) {
|
||||
qWarning("QBasicTimer::stop: Failed. Possibly trying to stop from a different thread");
|
||||
return;
|
||||
}
|
||||
if (eventDispatcher && !eventDispatcher->unregisterTimer(id)) {
|
||||
qWarning("QBasicTimer::stop: Failed. Possibly trying to stop from a different thread");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!gGlobalEventDispatcher->unregisterTimer(id)) {
|
||||
qWarning("QBasicTimer::stop: Failed. Possibly trying to stop from a different thread");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QAbstractEventDispatcherPrivate::releaseTimerId(id);
|
||||
}
|
||||
id = 0;
|
||||
|
@ -509,10 +509,6 @@ void QCoreApplicationPrivate::createEventDispatcher()
|
||||
{
|
||||
Q_Q(QCoreApplication);
|
||||
|
||||
if (gGlobalEventDispatcher) {
|
||||
return;
|
||||
}
|
||||
|
||||
QThreadData *data = QThreadData::current();
|
||||
Q_ASSERT(!data->hasEventDispatcher());
|
||||
eventDispatcher = data->createEventDispatcher();
|
||||
@ -907,8 +903,8 @@ void Q_TRACE_INSTRUMENT(qtcore) QCoreApplicationPrivate::init()
|
||||
auto thisThreadData = threadData.loadRelaxed();
|
||||
eventDispatcher = thisThreadData->eventDispatcher.loadRelaxed();
|
||||
|
||||
if (gGlobalEventDispatcher) {
|
||||
eventDispatcher = gGlobalEventDispatcher;
|
||||
if (gGetLocalEventDispatcher) {
|
||||
eventDispatcher = gGetLocalEventDispatcher();
|
||||
} else {
|
||||
// otherwise we create one
|
||||
if (!eventDispatcher)
|
||||
|
@ -1,3 +1,3 @@
|
||||
#include "qthreadawareeventdispatcher_i.hpp"
|
||||
|
||||
SECRET_PLATFORM_EXPORT QAbstractEventDispatcher *gGlobalEventDispatcher = {};
|
||||
SECRET_PLATFORM_EXPORT QAbstractEventDispatcher *(*gGetLocalEventDispatcher)() = {};
|
||||
|
@ -4,5 +4,4 @@
|
||||
#define SECRET_PLATFORM_EXPORT __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
|
||||
extern SECRET_PLATFORM_EXPORT QAbstractEventDispatcher *gGlobalEventDispatcher;
|
||||
extern SECRET_PLATFORM_EXPORT QAbstractEventDispatcher *(*gGetLocalEventDispatcher)();
|
@ -113,8 +113,8 @@ void QThreadData::deref()
|
||||
|
||||
QAbstractEventDispatcher *QThreadData::createEventDispatcher()
|
||||
{
|
||||
QAbstractEventDispatcher *ed = gGlobalEventDispatcher ?
|
||||
gGlobalEventDispatcher :
|
||||
QAbstractEventDispatcher *ed = gGetLocalEventDispatcher ?
|
||||
gGetLocalEventDispatcher() :
|
||||
QThreadPrivate::createEventDispatcher(this);
|
||||
eventDispatcher.storeRelease(ed);
|
||||
return ed;
|
||||
|
@ -330,7 +330,7 @@ void QThreadPrivate::finish(void *arg, bool lockAnyway) noexcept
|
||||
locker.unlock();
|
||||
eventDispatcher->closingDown();
|
||||
|
||||
if (gGlobalEventDispatcher != eventDispatcher)
|
||||
if (!gGetLocalEventDispatcher)
|
||||
{
|
||||
delete eventDispatcher;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user