X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2FWordList.cpp;h=762e1b93c620411af87688dea91cbe0267eb2612;hb=4db3e641ed6765e005343010cb90ee8af26f8f99;hp=7dc620e0898e2fba99101d23a546021b118982bf;hpb=9b4a26a252b2da164fcd6aa84feed0a738b16c10;p=lyx.git diff --git a/src/WordList.cpp b/src/WordList.cpp index 7dc620e089..762e1b93c6 100644 --- a/src/WordList.cpp +++ b/src/WordList.cpp @@ -12,6 +12,8 @@ #include "WordList.h" +#include "Language.h" + #include "support/convert.h" #include "support/debug.h" #include "support/docstring.h" @@ -19,16 +21,36 @@ #include "support/lassert.h" +#include + +using namespace std; + namespace lyx { /// -WordList theGlobalWordList; +map theGlobalWordList; -WordList & theWordList() + +WordList * theWordList(Language const & lang) { - return theGlobalWordList; + map::iterator it = theGlobalWordList.find(lang); + if (it != theGlobalWordList.end()) + return it->second; + else + theGlobalWordList[lang] = new WordList; + return theGlobalWordList[lang]; } + +void WordList::cleanupWordLists() +{ + map::const_iterator it = theGlobalWordList.begin(); + for (; it != theGlobalWordList.end(); ++it) + delete it->second; + theGlobalWordList.clear(); +} + + /// struct WordList::Impl { /// @@ -62,7 +84,7 @@ WordList::~WordList() docstring const & WordList::word(size_t idx) const { Impl::Words::const_iterator it = d->words_.find_summed_weight(idx); - LASSERT(it != d->words_.end(), /**/); + LASSERT(it != d->words_.end(), { static docstring dummy; return dummy; }); // We use the key() method here, and not something like it->first // because the btree only returns (iterator-) temporary value pairs.