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();
