From acfa2011d2d472f029d30286a36586e16b9bade8 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 13 Sep 2011 18:29:14 +0300 Subject: Fix panic when global QSettings instance needs flusing at app exit The lack of cleanup stack caused panic when the global static QSettings instance in QCoreApplication was deleted if there was pending update in the QSettings instance. Task-number: QTBUG-21421 Reviewed-by: Murray Read --- src/corelib/kernel/qcoreapplication.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 18a5eae..752bbaa 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -273,6 +273,29 @@ bool QCoreApplicationPrivate::is_app_closing = false; // initialized in qcoreapplication and in qtextstream autotest when setlocale is called. Q_CORE_EXPORT bool qt_locale_initialized = false; +#ifdef Q_OS_SYMBIAN +// The global QSettings needs to be cleaned where cleanup stack is available, which is not +// normally the case when global static destructors are run. +// Declare a custom QGlobalStaticDeleter for QSettings to handle that case. +template<> +class QGlobalStaticDeleter +{ +public: + QGlobalStatic &globalStatic; + QGlobalStaticDeleter(QGlobalStatic &_globalStatic) + : globalStatic(_globalStatic) + { } + + inline ~QGlobalStaticDeleter() + { + CTrapCleanup *cleanup = CTrapCleanup::New(); + delete globalStatic.pointer; + delete cleanup; + globalStatic.pointer = 0; + globalStatic.destroyed = true; + } +}; +#endif /* Create an instance of Trolltech.conf. This ensures that the settings will not -- cgit v0.12