summaryrefslogtreecommitdiffstats
path: root/src/kernel/tqwidget.cpp
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2024-08-23 23:40:14 +0900
committerMichele Calgaro <[email protected]>2024-08-23 23:57:24 +0900
commitddce1c91f8582885497b463b24bac59f6fdfdf63 (patch)
tree52d4570fdcb8c1c2d21245fad88940b0020a2b88 /src/kernel/tqwidget.cpp
parent82ecd83484c9fa1ede059986ab771e74e33e68ef (diff)
downloadtqt3-ddce1c91f8582885497b463b24bac59f6fdfdf63.tar.gz
tqt3-ddce1c91f8582885497b463b24bac59f6fdfdf63.zip
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 <[email protected]>
Diffstat (limited to 'src/kernel/tqwidget.cpp')
-rw-r--r--src/kernel/tqwidget.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/kernel/tqwidget.cpp b/src/kernel/tqwidget.cpp
index ddc34c0ec..0b27e2564 100644
--- a/src/kernel/tqwidget.cpp
+++ b/src/kernel/tqwidget.cpp
@@ -1003,7 +1003,10 @@ TQWidget::~TQWidget()
childObjects = 0;
}
- TQApplication::removePostedEvents( this );
+ if ( tqApp )
+ {
+ TQApplication::removePostedEvents( this );
+ }
destroy(); // platform-dependent cleanup
if ( extra )