From b0985a2740454a4448a92bcefa5320185b48ac1e Mon Sep 17 00:00:00 2001 From: Nick Bolton Date: Thu, 26 Mar 2026 11:28:16 +0000 Subject: [PATCH] fix(unix): Add foreign Qt threds in legacy POSIX thread impl --- src/lib/arch/unix/ArchMultithreadPosix.cpp | 16 +++++++++++++++- src/lib/arch/unix/ArchMultithreadPosix.h | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/lib/arch/unix/ArchMultithreadPosix.cpp b/src/lib/arch/unix/ArchMultithreadPosix.cpp index 44e00b0c5..154cd975b 100644 --- a/src/lib/arch/unix/ArchMultithreadPosix.cpp +++ b/src/lib/arch/unix/ArchMultithreadPosix.cpp @@ -517,13 +517,27 @@ void ArchMultithreadPosix::startSignalHandler() ArchThreadImpl *ArchMultithreadPosix::find(pthread_t thread) { - ArchThreadImpl *impl = findNoRef(thread); + ArchThreadImpl *impl = findNoRefOrInsert(thread); if (impl != nullptr) { refThread(impl); } return impl; } +ArchThreadImpl *ArchMultithreadPosix::findNoRefOrInsert(pthread_t thread) +{ + ArchThreadImpl *impl = findNoRef(thread); + if (impl == nullptr) { + // create thread for calling thread which isn't in our list and + // add it to the list. this can happen when a foreign thread + // (e.g. a Qt thread) calls into the arch layer. + impl = new ArchThreadImpl; + impl->m_thread = thread; + insert(impl); + } + return impl; +} + ArchThreadImpl *ArchMultithreadPosix::findNoRef(pthread_t thread) { // linear search diff --git a/src/lib/arch/unix/ArchMultithreadPosix.h b/src/lib/arch/unix/ArchMultithreadPosix.h index 893a6519b..4d22afaeb 100644 --- a/src/lib/arch/unix/ArchMultithreadPosix.h +++ b/src/lib/arch/unix/ArchMultithreadPosix.h @@ -84,6 +84,7 @@ private: ArchThreadImpl *find(pthread_t thread); ArchThreadImpl *findNoRef(pthread_t thread); + ArchThreadImpl *findNoRefOrInsert(pthread_t thread); void insert(ArchThreadImpl *thread); void erase(const ArchThreadImpl *thread);