QThreadStorage: make the internal finish() function really private
This class is very old and hasn't been modernized since C++98 became a thing we could rely on. We hadn't come up with the concept of private headers yet. This commit moves the exported QThreadStorageData::finish() function from the public header to QThreadStoragePrivate in a private header and no longer exports it. It also removes the need to pass the QList as a void **. Task-number: QTBUG-135044 Change-Id: I736cb12a7c29716effd7fffd87c7b086a8cb7e19 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
parent
81a7a4c2d9
commit
eb8c09c104
@ -491,8 +491,7 @@ void QCoreApplicationPrivate::cleanupThreadData()
|
|||||||
|
|
||||||
if (thisThreadData && !threadData_clean) {
|
if (thisThreadData && !threadData_clean) {
|
||||||
#if QT_CONFIG(thread)
|
#if QT_CONFIG(thread)
|
||||||
void *data = &thisThreadData->tls;
|
QThreadStoragePrivate::finish(&thisThreadData->tls);
|
||||||
QThreadStorageData::finish((void **)data);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// need to clear the state of the mainData, just in case a new QCoreApplication comes along.
|
// need to clear the state of the mainData, just in case a new QCoreApplication comes along.
|
||||||
|
@ -460,8 +460,7 @@ void QThreadPrivate::finish()
|
|||||||
emit thr->finished(QThread::QPrivateSignal());
|
emit thr->finished(QThread::QPrivateSignal());
|
||||||
QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
|
QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
|
||||||
|
|
||||||
void *data = &d->data->tls;
|
QThreadStoragePrivate::finish(&d->data->tls);
|
||||||
QThreadStorageData::finish((void **)data);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if constexpr (QT_CONFIG(broken_threadlocal_dtors))
|
if constexpr (QT_CONFIG(broken_threadlocal_dtors))
|
||||||
|
@ -242,12 +242,11 @@ void QThreadPrivate::finish(bool lockAnyway) noexcept
|
|||||||
QMutexLocker locker(lockAnyway ? &d->mutex : nullptr);
|
QMutexLocker locker(lockAnyway ? &d->mutex : nullptr);
|
||||||
d->threadState = QThreadPrivate::Finishing;
|
d->threadState = QThreadPrivate::Finishing;
|
||||||
d->priority = QThread::InheritPriority;
|
d->priority = QThread::InheritPriority;
|
||||||
void **tls_data = reinterpret_cast<void **>(&d->data->tls);
|
|
||||||
if (lockAnyway)
|
if (lockAnyway)
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
emit thr->finished(QThread::QPrivateSignal());
|
emit thr->finished(QThread::QPrivateSignal());
|
||||||
QCoreApplicationPrivate::sendPostedEvents(nullptr, QEvent::DeferredDelete, d->data);
|
QCoreApplicationPrivate::sendPostedEvents(nullptr, QEvent::DeferredDelete, d->data);
|
||||||
QThreadStorageData::finish(tls_data);
|
QThreadStoragePrivate::finish(&d->data->tls);
|
||||||
if (lockAnyway)
|
if (lockAnyway)
|
||||||
locker.relock();
|
locker.relock();
|
||||||
|
|
||||||
|
@ -141,10 +141,9 @@ void QThreadStoragePrivate::init()
|
|||||||
destructors();
|
destructors();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QThreadStorageData::finish(void **p)
|
void QThreadStoragePrivate::finish(QList<void *> *tls)
|
||||||
{
|
{
|
||||||
QList<void *> *tls = reinterpret_cast<QList<void *> *>(p);
|
if (tls->isEmpty() || !destructors())
|
||||||
if (!tls || tls->isEmpty() || !destructors())
|
|
||||||
return; // nothing to do
|
return; // nothing to do
|
||||||
|
|
||||||
DEBUG_MSG("QThreadStorageData: Destroying storage for thread %p", QThread::currentThread());
|
DEBUG_MSG("QThreadStorageData: Destroying storage for thread %p", QThread::currentThread());
|
||||||
|
@ -35,7 +35,6 @@ public:
|
|||||||
void** get() const;
|
void** get() const;
|
||||||
void** set(void* p);
|
void** set(void* p);
|
||||||
|
|
||||||
static void finish(void**);
|
|
||||||
int id;
|
int id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
namespace QThreadStoragePrivate {
|
namespace QThreadStoragePrivate {
|
||||||
void init();
|
void init();
|
||||||
|
void finish(QList<void *> *tls);
|
||||||
} // namespace QThreadStoragePrivate
|
} // namespace QThreadStoragePrivate
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user