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 QT_CONFIG(thread)
|
||||
void *data = &thisThreadData->tls;
|
||||
QThreadStorageData::finish((void **)data);
|
||||
QThreadStoragePrivate::finish(&thisThreadData->tls);
|
||||
#endif
|
||||
|
||||
// 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());
|
||||
QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
|
||||
|
||||
void *data = &d->data->tls;
|
||||
QThreadStorageData::finish((void **)data);
|
||||
QThreadStoragePrivate::finish(&d->data->tls);
|
||||
});
|
||||
|
||||
if constexpr (QT_CONFIG(broken_threadlocal_dtors))
|
||||
|
@ -242,12 +242,11 @@ void QThreadPrivate::finish(bool lockAnyway) noexcept
|
||||
QMutexLocker locker(lockAnyway ? &d->mutex : nullptr);
|
||||
d->threadState = QThreadPrivate::Finishing;
|
||||
d->priority = QThread::InheritPriority;
|
||||
void **tls_data = reinterpret_cast<void **>(&d->data->tls);
|
||||
if (lockAnyway)
|
||||
locker.unlock();
|
||||
emit thr->finished(QThread::QPrivateSignal());
|
||||
QCoreApplicationPrivate::sendPostedEvents(nullptr, QEvent::DeferredDelete, d->data);
|
||||
QThreadStorageData::finish(tls_data);
|
||||
QThreadStoragePrivate::finish(&d->data->tls);
|
||||
if (lockAnyway)
|
||||
locker.relock();
|
||||
|
||||
|
@ -141,10 +141,9 @@ void QThreadStoragePrivate::init()
|
||||
destructors();
|
||||
}
|
||||
|
||||
void QThreadStorageData::finish(void **p)
|
||||
void QThreadStoragePrivate::finish(QList<void *> *tls)
|
||||
{
|
||||
QList<void *> *tls = reinterpret_cast<QList<void *> *>(p);
|
||||
if (!tls || tls->isEmpty() || !destructors())
|
||||
if (tls->isEmpty() || !destructors())
|
||||
return; // nothing to do
|
||||
|
||||
DEBUG_MSG("QThreadStorageData: Destroying storage for thread %p", QThread::currentThread());
|
||||
|
@ -35,7 +35,6 @@ public:
|
||||
void** get() const;
|
||||
void** set(void* p);
|
||||
|
||||
static void finish(void**);
|
||||
int id;
|
||||
};
|
||||
|
||||
|
@ -22,6 +22,7 @@ QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace QThreadStoragePrivate {
|
||||
void init();
|
||||
void finish(QList<void *> *tls);
|
||||
} // namespace QThreadStoragePrivate
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
Loading…
x
Reference in New Issue
Block a user