From 08ac5cce693a7634341db8f4da4d729a64b0af46 Mon Sep 17 00:00:00 2001 From: Michele Calgaro Date: Fri, 23 Aug 2024 23:40:14 +0900 Subject: Improve handling of the global post event list in order to minimize possible crashes on exit. Key points: 1. a TQPostEventList can now have an associated mutex, which is used in case of the global post event list (GPEL) 2. the lifetime of the GPEL is no longer associated to the lifetime of the TQApplication object, but rather extended to the lifetime of the main thread. The GPEL is a static local initialized on first access and destroyed when the global static object destructor is invoked 3. access to the GPEL after the TQApplication object has been destroyed has been minimized by protecting calls in ~TQObject() and ~TQWidget(). 4. special care was taken not to affect performances or unnecessarily create tons of unused TQMutexes This replaces PR #182. Technically it is still possibly unsafe due to the order of destruction of the globat static objects not being guaranteed across multiple compilation units, but the aforementioned changes should minimize (possible to zero) the chances of a SEGV happening. Signed-off-by: Michele Calgaro (cherry picked from commit ddce1c91f8582885497b463b24bac59f6fdfdf63) --- src/kernel/qobject.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/kernel/qobject.cpp') diff --git a/src/kernel/qobject.cpp b/src/kernel/qobject.cpp index bb4c848b8..7692e9c21 100644 --- a/src/kernel/qobject.cpp +++ b/src/kernel/qobject.cpp @@ -747,7 +747,10 @@ TQObject::~TQObject() if ( pendTimer ) { // might be pending timers qKillTimer( this ); } - TQApplication::removePostedEvents( this ); + if ( tqApp ) + { + TQApplication::removePostedEvents( this ); + } if ( isTree ) { remove_tree( this ); // remove from global root list isTree = FALSE; -- cgit v1.2.3