Author: tommaso
Date: Sat Oct 15 15:38:52 2011
New Revision: 39865
URL: http://www.lyx.org/trac/changeset/39865

Log:
Clean up word lists on exit. Not really a concrete issue, but just
get less "noise" when debugging for memory leaks.

Modified:
   lyx-devel/trunk/src/LyX.cpp
   lyx-devel/trunk/src/WordList.cpp
   lyx-devel/trunk/src/WordList.h

Modified: lyx-devel/trunk/src/LyX.cpp
==============================================================================
--- lyx-devel/trunk/src/LyX.cpp Sat Oct 15 15:34:14 2011        (r39864)
+++ lyx-devel/trunk/src/LyX.cpp Sat Oct 15 15:38:52 2011        (r39865)
@@ -44,6 +44,7 @@
 #include "Server.h"
 #include "ServerSocket.h"
 #include "Session.h"
+#include "WordList.h"
 
 #include "frontends/alert.h"
 #include "frontends/Application.h"
@@ -217,6 +218,7 @@
 {
        delete pimpl_;
        singleton_ = 0;
+       WordList::cleanupWordLists();
 }
 
 
@@ -446,8 +448,7 @@
 
        // Kill the application object before exiting. This avoids crashes
        // when exiting on Linux.
-       if (pimpl_->application_)
-               pimpl_->application_.reset();
+       pimpl_->application_.reset();
 }
 
 

Modified: lyx-devel/trunk/src/WordList.cpp
==============================================================================
--- lyx-devel/trunk/src/WordList.cpp    Sat Oct 15 15:34:14 2011        (r39864)
+++ lyx-devel/trunk/src/WordList.cpp    Sat Oct 15 15:38:52 2011        (r39865)
@@ -30,6 +30,7 @@
 ///
 map<Language, WordList *> theGlobalWordList;
 
+
 WordList * theWordList(Language const & lang)
 {
        map<Language, WordList *>::iterator it = theGlobalWordList.find(lang);
@@ -40,6 +41,15 @@
        return theGlobalWordList[lang];
 }
 
+
+void WordList::cleanupWordLists() {
+       map<Language, WordList *>::const_iterator it = 
theGlobalWordList.begin();
+       for (; it != theGlobalWordList.end(); ++it)
+               delete it->second;
+       theGlobalWordList.clear();
+}
+
+
 ///
 struct WordList::Impl {
        ///

Modified: lyx-devel/trunk/src/WordList.h
==============================================================================
--- lyx-devel/trunk/src/WordList.h      Sat Oct 15 15:34:14 2011        (r39864)
+++ lyx-devel/trunk/src/WordList.h      Sat Oct 15 15:38:52 2011        (r39865)
@@ -33,7 +33,9 @@
        void insert(docstring const & w);
        ///
        void remove(docstring const & w);
-       
+       ///
+       static void cleanupWordLists();
+
 private:
        struct Impl;
        Impl * d;

Reply via email to