mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-25 22:06:15 +00:00
Convert a pointer to a reference
The validity of the reference is guaranteed by QThreadLocalStorage
This commit is contained in:
parent
832b99a394
commit
0eb0b8531a
@ -3705,11 +3705,11 @@ void Paragraph::deregisterWords()
|
||||
Private::LangWordsMap::const_iterator itl = d->words_.begin();
|
||||
Private::LangWordsMap::const_iterator ite = d->words_.end();
|
||||
for (; itl != ite; ++itl) {
|
||||
WordList * wl = theWordList(itl->first);
|
||||
WordList & wl = theWordList(itl->first);
|
||||
Private::Words::const_iterator it = (itl->second).begin();
|
||||
Private::Words::const_iterator et = (itl->second).end();
|
||||
for (; it != et; ++it)
|
||||
wl->remove(*it);
|
||||
wl.remove(*it);
|
||||
}
|
||||
d->words_.clear();
|
||||
}
|
||||
@ -3785,11 +3785,11 @@ void Paragraph::registerWords()
|
||||
Private::LangWordsMap::const_iterator itl = d->words_.begin();
|
||||
Private::LangWordsMap::const_iterator ite = d->words_.end();
|
||||
for (; itl != ite; ++itl) {
|
||||
WordList * wl = theWordList(itl->first);
|
||||
WordList & wl = theWordList(itl->first);
|
||||
Private::Words::const_iterator it = (itl->second).begin();
|
||||
Private::Words::const_iterator et = (itl->second).end();
|
||||
for (; it != et; ++it)
|
||||
wl->insert(*it);
|
||||
wl.insert(*it);
|
||||
}
|
||||
}
|
||||
|
||||
|
10
src/Text.cpp
10
src/Text.cpp
@ -586,7 +586,7 @@ class TextCompletionList : public CompletionList
|
||||
{
|
||||
public:
|
||||
///
|
||||
TextCompletionList(Cursor const & cur, WordList const * list)
|
||||
TextCompletionList(Cursor const & cur, WordList const & list)
|
||||
: buffer_(cur.buffer()), list_(list)
|
||||
{}
|
||||
///
|
||||
@ -597,19 +597,19 @@ public:
|
||||
///
|
||||
virtual size_t size() const
|
||||
{
|
||||
return list_->size();
|
||||
return list_.size();
|
||||
}
|
||||
///
|
||||
virtual docstring const & data(size_t idx) const
|
||||
{
|
||||
return list_->word(idx);
|
||||
return list_.word(idx);
|
||||
}
|
||||
|
||||
private:
|
||||
///
|
||||
Buffer const * buffer_;
|
||||
///
|
||||
WordList const * list_;
|
||||
WordList const & list_;
|
||||
};
|
||||
|
||||
|
||||
@ -2156,7 +2156,7 @@ bool Text::completionSupported(Cursor const & cur) const
|
||||
|
||||
CompletionList const * Text::createCompletionList(Cursor const & cur) const
|
||||
{
|
||||
WordList const * list = theWordList(cur.getFont().language()->lang());
|
||||
WordList const & list = theWordList(cur.getFont().language()->lang());
|
||||
return new TextCompletionList(cur, list);
|
||||
}
|
||||
|
||||
|
@ -34,18 +34,18 @@ typedef map<string, WordList *> GlobalWordList;
|
||||
QThreadStorage<GlobalWordList *> theGlobalWordList;
|
||||
|
||||
|
||||
WordList * theWordList(string const & lang)
|
||||
WordList & theWordList(string const & lang)
|
||||
{
|
||||
if (!theGlobalWordList.hasLocalData())
|
||||
theGlobalWordList.setLocalData(new GlobalWordList);
|
||||
GlobalWordList * globalWordList = theGlobalWordList.localData();
|
||||
GlobalWordList::iterator it = globalWordList->find(lang);
|
||||
if (it != globalWordList->end())
|
||||
return it->second;
|
||||
return *it->second;
|
||||
else {
|
||||
WordList * wl = new WordList;
|
||||
(*globalWordList)[lang] = wl;
|
||||
return wl;
|
||||
return *wl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ private:
|
||||
std::unique_ptr<Impl> d;
|
||||
};
|
||||
|
||||
WordList * theWordList(std::string const & lang);
|
||||
WordList & theWordList(std::string const & lang);
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user