Qt 6.8.3 with BlackBerry 10 (QNX 8 / ARMv7) patches
 
 
 
 
 
 
Go to file
Thiago Macieira 334a3922c0 QThread/Unix: refactor to split QThreadPrivate::finish() in two phases
Commit 1ed0dd88a3 moved the finish()
functionality from immediately after run() returns to the time of
thread-local destruction, to make sure that user destructors didn't run
after our cleaning up. But as a side effect, it made other user code run
too late, after some thread-local statics had been destroyed.

This is a common practice, which causes the destructor for worker to run
too late:

    worker->moveToThread(thread);
...
    QObject::connect(thread, &QThread::finished, thread, &QObject::deleteLater);
    QObject::connect(thread, &QThread::finished, worker, &QObject::deleteLater);

This commit splits the cleanup in two phases: QThreadPrivate::finish(),
which runs immediately after run() and will call back out to user code
(finished() signal and delivery of deleteLater()), and cleanup() that
cleans up the QThread{Private,Data} state and destroys the event
dispatcher. That destruction is the only call out to user code.

I've removed the complex mix of pre-C++11 pthread_setspecific() content
and C++11 thread_local variables in favor of using one or the other, not
both. We prefer the thread-local for future-proofing and simplicity, on
platforms where we can verify this C++11 feature works, and because it
allows us to clean up QThreadData and the event dispatcher as late as
possible. (There's some code that runs even later, such as pthread TLS
destructors, used by Glib's GMainLoop)

Unfortunately, we can't use it everywhere. The commit above had already
noticed QNX has a problem and recent bug reports have shown other
platforms (Solaris, MUSL libc) that, 13 years after the ratification of
the standard, still have broken support, so we use pthread for them and
we call cleanup() from within finish() (that is, no late cleaning-up,
retaining the status quo from Qt 4 and 5). See QTBUG-129846 for an
analysis.

Drive-by moving the resetting of thread priority to after finished() is
emitted.

[ChangeLog][QtCore][QThread] Restored the Qt 6.7 timing of when the
finished() signal is emitted relative to the destruction of thread_local
variables. Qt 6.8.0 contained a change that moved this signal to a later
time on most Unix systems, which has caused problems with the order in
which those variables were accessed. The destruction of the event
dispatcher is kept at this late stage, wherever possible.

Fixes: QTBUG-129927
Fixes: QTBUG-129846
Fixes: QTBUG-130341
Task-number: QTBUG-117996
Change-Id: Ie5e40dd18faa05d8f777fffdf7dc30fc4fe0c7e9
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 4fabde349f16b59f37568da2a4c050c6dd53a34e)
2024-11-07 15:00:11 -07:00
.github/workflows Repair github action workflow 2021-11-10 18:57:33 +01:00
LICENSES Add REUSE.toml files 2024-11-07 08:38:49 +01:00
bin CMake: Don't hard-code "libexec" in qt-configure-module 2024-08-20 13:50:32 +02:00
cmake Add REUSE.toml files 2024-11-07 08:38:49 +01:00
coin coin: Build qdoc as part of repo instructions for CI doc building 2024-11-02 14:49:15 +01:00
config.tests QThread/Unix: refactor to split QThreadPrivate::finish() in two phases 2024-11-07 15:00:11 -07:00
dist Add REUSE.toml files 2024-11-07 08:38:49 +01:00
doc Docs: Update images for Widgets and remove unused images 2024-10-17 08:00:17 +00:00
examples Show Custom Completer example as part of UI Components category 2024-10-31 15:36:20 +00:00
lib Purge all fonts 2015-08-18 19:59:14 +00:00
libexec CMake:Android: add wrapper scripts to easily run apps 2024-11-04 11:00:57 +01:00
mkspecs Add REUSE.toml files 2024-11-07 08:38:49 +01:00
qmake QFactoryLoader: fix the ability to load symlinks to plugins 2024-10-17 17:01:41 -07:00
src QThread/Unix: refactor to split QThreadPrivate::finish() in two phases 2024-11-07 15:00:11 -07:00
tests QThread/Unix: refactor to split QThreadPrivate::finish() in two phases 2024-11-07 15:00:11 -07:00
util Add REUSE.toml files 2024-11-07 08:38:49 +01:00
.cmake.conf cmake: Set all Apple version defines in .cmake.conf 2024-11-02 13:49:14 +00:00
.gitattributes Give batch files CRLF line endings 2020-11-04 15:02:29 +00:00
.gitignore Git ignore Visual Studio CMake build directories 2023-11-24 23:42:05 +01:00
.lgtm.yml Skip LGTM analysis for the bootstrap library and tools 2020-07-16 01:04:34 +02:00
.tag
CMakeLists.txt cmake: add _extra_files IDE target from heuristics 2024-04-12 08:36:01 +08:00
REUSE.toml Add REUSE.toml files 2024-11-07 08:38:49 +01:00
config_help.txt CMake: Change SBOM generation to be enabled by default (mostly) 2024-10-21 08:37:20 +00:00
configure Change configure license 2024-02-02 15:23:02 +00:00
configure.bat configure.bat: Fix errors on Windows 2024-03-05 11:56:24 +01:00
configure.cmake CMake: Report success for 'separate_debug_info' where applicable 2024-11-02 16:25:06 +00:00
dependencies.yaml Re-add dependencies.yaml now that qt5.git wip/qt6 builds fine 2019-09-18 13:19:31 +02:00
licenseRule.json Include relevant Unicode Inc. copyright line in generated data files 2024-08-31 08:56:42 +00:00
qt_cmdline.cmake configure: accept -c++std c++17 again 2024-06-13 20:40:06 +00:00