diff options
author | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2011-09-13 15:29:14 (GMT) |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@digia.com> | 2011-09-13 15:43:20 (GMT) |
commit | acfa2011d2d472f029d30286a36586e16b9bade8 (patch) | |
tree | f7390a39be4aba1bdc8cfcb24193f8800c30b69f /src/corelib | |
parent | 6144cd83d3bcc9783da54e0538c00642690d515d (diff) | |
download | Qt-acfa2011d2d472f029d30286a36586e16b9bade8.zip Qt-acfa2011d2d472f029d30286a36586e16b9bade8.tar.gz Qt-acfa2011d2d472f029d30286a36586e16b9bade8.tar.bz2 |
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
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
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<QSettings> +{ +public: + QGlobalStatic<QSettings> &globalStatic; + QGlobalStaticDeleter(QGlobalStatic<QSettings> &_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 |