mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 19:07:45 +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 itl = d->words_.begin();
|
||||||
Private::LangWordsMap::const_iterator ite = d->words_.end();
|
Private::LangWordsMap::const_iterator ite = d->words_.end();
|
||||||
for (; itl != ite; ++itl) {
|
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 it = (itl->second).begin();
|
||||||
Private::Words::const_iterator et = (itl->second).end();
|
Private::Words::const_iterator et = (itl->second).end();
|
||||||
for (; it != et; ++it)
|
for (; it != et; ++it)
|
||||||
wl->remove(*it);
|
wl.remove(*it);
|
||||||
}
|
}
|
||||||
d->words_.clear();
|
d->words_.clear();
|
||||||
}
|
}
|
||||||
@ -3785,11 +3785,11 @@ void Paragraph::registerWords()
|
|||||||
Private::LangWordsMap::const_iterator itl = d->words_.begin();
|
Private::LangWordsMap::const_iterator itl = d->words_.begin();
|
||||||
Private::LangWordsMap::const_iterator ite = d->words_.end();
|
Private::LangWordsMap::const_iterator ite = d->words_.end();
|
||||||
for (; itl != ite; ++itl) {
|
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 it = (itl->second).begin();
|
||||||
Private::Words::const_iterator et = (itl->second).end();
|
Private::Words::const_iterator et = (itl->second).end();
|
||||||
for (; it != et; ++it)
|
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:
|
public:
|
||||||
///
|
///
|
||||||
TextCompletionList(Cursor const & cur, WordList const * list)
|
TextCompletionList(Cursor const & cur, WordList const & list)
|
||||||
: buffer_(cur.buffer()), list_(list)
|
: buffer_(cur.buffer()), list_(list)
|
||||||
{}
|
{}
|
||||||
///
|
///
|
||||||
@ -597,19 +597,19 @@ public:
|
|||||||
///
|
///
|
||||||
virtual size_t size() const
|
virtual size_t size() const
|
||||||
{
|
{
|
||||||
return list_->size();
|
return list_.size();
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
virtual docstring const & data(size_t idx) const
|
virtual docstring const & data(size_t idx) const
|
||||||
{
|
{
|
||||||
return list_->word(idx);
|
return list_.word(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
///
|
///
|
||||||
Buffer const * buffer_;
|
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
|
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);
|
return new TextCompletionList(cur, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,18 +34,18 @@ typedef map<string, WordList *> GlobalWordList;
|
|||||||
QThreadStorage<GlobalWordList *> theGlobalWordList;
|
QThreadStorage<GlobalWordList *> theGlobalWordList;
|
||||||
|
|
||||||
|
|
||||||
WordList * theWordList(string const & lang)
|
WordList & theWordList(string const & lang)
|
||||||
{
|
{
|
||||||
if (!theGlobalWordList.hasLocalData())
|
if (!theGlobalWordList.hasLocalData())
|
||||||
theGlobalWordList.setLocalData(new GlobalWordList);
|
theGlobalWordList.setLocalData(new GlobalWordList);
|
||||||
GlobalWordList * globalWordList = theGlobalWordList.localData();
|
GlobalWordList * globalWordList = theGlobalWordList.localData();
|
||||||
GlobalWordList::iterator it = globalWordList->find(lang);
|
GlobalWordList::iterator it = globalWordList->find(lang);
|
||||||
if (it != globalWordList->end())
|
if (it != globalWordList->end())
|
||||||
return it->second;
|
return *it->second;
|
||||||
else {
|
else {
|
||||||
WordList * wl = new WordList;
|
WordList * wl = new WordList;
|
||||||
(*globalWordList)[lang] = wl;
|
(*globalWordList)[lang] = wl;
|
||||||
return wl;
|
return *wl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ private:
|
|||||||
std::unique_ptr<Impl> d;
|
std::unique_ptr<Impl> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
WordList * theWordList(std::string const & lang);
|
WordList & theWordList(std::string const & lang);
|
||||||
|
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user