Clean up word lists on exit. Not really a concrete issue, but just

get less "noise" when debugging for memory leaks.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39865 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Tommaso Cucinotta 2011-10-15 13:38:52 +00:00
parent f4400845af
commit 79716cbcd0
3 changed files with 16 additions and 3 deletions

View File

@ -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 @@ LyX::~LyX()
{
delete pimpl_;
singleton_ = 0;
WordList::cleanupWordLists();
}
@ -446,8 +448,7 @@ void LyX::prepareExit()
// Kill the application object before exiting. This avoids crashes
// when exiting on Linux.
if (pimpl_->application_)
pimpl_->application_.reset();
pimpl_->application_.reset();
}

View File

@ -30,6 +30,7 @@ namespace lyx {
///
map<Language, WordList *> theGlobalWordList;
WordList * theWordList(Language const & lang)
{
map<Language, WordList *>::iterator it = theGlobalWordList.find(lang);
@ -40,6 +41,15 @@ WordList * theWordList(Language const & lang)
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 {
///

View File

@ -33,7 +33,9 @@ public:
void insert(docstring const & w);
///
void remove(docstring const & w);
///
static void cleanupWordLists();
private:
struct Impl;
Impl * d;