[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-core-devel
Subject: [patch] KTextEditorFactoryList: make qAddPostRoutine play well with
From: Jarosław Staniek <js () iidea ! pl>
Date: 2008-04-11 13:16:16
Message-ID: 47FF64A0.4060908 () iidea ! pl
[Download RAW message or body]
for review;
KTextEditorFactoryList: make qAddPostRoutine play well with K_GLOBAL_STATIC.
(like in KProtocolManagerPrivate)
I've encountered a crash related to double deletion of the list's memory, at
least on Windows, on app's exit.
The code is now cleaner too.
--
regards / pozdrawiam, Jaroslaw Staniek
Sponsored by OpenOffice Polska (http://www.openoffice.com.pl/en) to work on
Kexi & KOffice (http://www.kexi.pl/en, http://www.koffice.org/kexi)
KDE Libraries for MS Windows (http://windows.kde.org)
["ktexteditor.patch" (text/plain)]
Index: interfaces/ktexteditor/ktexteditor.cpp
===================================================================
--- interfaces/ktexteditor/ktexteditor.cpp (wersja 795732)
+++ interfaces/ktexteditor/ktexteditor.cpp (kopia robocza)
@@ -190,15 +190,19 @@
struct KTextEditorFactoryList : public QList<KPluginFactory*>
{
- KTextEditorFactoryList() {}
- ~KTextEditorFactoryList() { qDeleteAll(*this); }
+ KTextEditorFactoryList();
+ ~KTextEditorFactoryList();
};
K_GLOBAL_STATIC(KTextEditorFactoryList, s_factoryList)
-static void cleanupKTextEditorFactoryList()
-{
- qDeleteAll(*s_factoryList);
- s_factoryList->clear();
+KTextEditorFactoryList::KTextEditorFactoryList() {
+ // K_GLOBAL_STATIC is cleaned up *after* Q(Core)Application is gone
+ // but we have to cleanup before -> use qAddPostRoutine
+ qAddPostRoutine(s_factoryList.destroy);
}
+KTextEditorFactoryList::~KTextEditorFactoryList() {
+ qRemovePostRoutine(s_factoryList.destroy); // post routine is installed!
+ qDeleteAll(*this);
+}
Editor *KTextEditor::editor(const char *libname)
{
@@ -211,10 +215,6 @@
return 0;
}
- // K_GLOBAL_STATIC is cleaned up *after* Q(Core)Application is gone
- // but we have to cleanup before -> use qAddPostRoutine
- if(s_factoryList->count() == 0)
- qAddPostRoutine(cleanupKTextEditorFactoryList);
s_factoryList->append(fact);
return ef->editor();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic