summaryrefslogtreecommitdiffstats
path: root/src/corelib/thread/qthread.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2024-11-14 15:10:06 -0700
committerThiago Macieira <thiago.macieira@intel.com>2024-11-26 16:35:47 -0800
commit38f77d09e89c93cedf6da4144fc8aafe95975891 (patch)
treeee73b8fdd35fb86d2109267901149e7782feb90f /src/corelib/thread/qthread.cpp
parent32ee5539fd0a24d65490017b2f448bf1e9ba96e3 (diff)
QThreadData: refactor current() now that it never returns null
Simplying the body of the function to rely less on the exception handling too. The implementations for Unix and Windows are now literally identical, but duplicated because they call different static functions Change-Id: Ia14910a1c778ff5e606afffdabb8035e4603edda Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/corelib/thread/qthread.cpp')
-rw-r--r--src/corelib/thread/qthread.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index 0574386dacd..f804ab8b9d3 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -1119,9 +1119,9 @@ void QThread::setTerminationEnabled(bool)
// No threads: so we can just use static variables
Q_CONSTINIT static QThreadData *data = nullptr;
-QThreadData *QThreadData::current(bool createIfNecessary)
+QThreadData *QThreadData::current()
{
- if (!data && createIfNecessary) {
+ if (!data) {
data = new QThreadData;
data->thread = new QAdoptedThread(data);
}