From 5d0e49d4dcd5666feeddc5b9d5fa14dd4b654219 Mon Sep 17 00:00:00 2001 From: Stefan Schimanski Date: Thu, 28 Feb 2008 14:46:47 +0000 Subject: [PATCH] * fix a memory corruption due to sligtly different semantics of btree iterators: // We use the key() method here, and not something like it->first // because the btree only returns (iterator-) temporary value pairs. // If we returned the first component of those here, we get an // invalid reference and therefore strange crashes. return it.key(); * This should fix the completion for Windows users hopefully. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23321 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/WordList.cpp | 7 ++++++- src/frontends/qt4/GuiCompleter.cpp | 7 +++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/WordList.cpp b/src/WordList.cpp index 30ba5b63af..558ddf8a18 100644 --- a/src/WordList.cpp +++ b/src/WordList.cpp @@ -63,7 +63,12 @@ docstring const & WordList::word(size_t idx) const { Impl::Words::const_iterator it = d->words_.find_summed_weight(idx); BOOST_ASSERT(it != d->words_.end()); - return it->first; + + // We use the key() method here, and not something like it->first + // because the btree only returns (iterator-) temporary value pairs. + // If we returned the first component of those here, we get an + // invalid reference and therefore strange crashes. + return it.key(); } diff --git a/src/frontends/qt4/GuiCompleter.cpp b/src/frontends/qt4/GuiCompleter.cpp index aa54d93d1d..1456fe9f4d 100644 --- a/src/frontends/qt4/GuiCompleter.cpp +++ b/src/frontends/qt4/GuiCompleter.cpp @@ -130,10 +130,9 @@ public: if (role != Qt::DisplayRole && role != Qt::EditRole) return QVariant(); - if (index.column() == 0) { - docstring const word = list_->data(index.row()); - return toqstr(word); - } else if (index.column() == 1) { + if (index.column() == 0) + return toqstr(list_->data(index.row())); + else if (index.column() == 1) { // get icon from cache QPixmap scaled; QString const name = ":" + toqstr(list_->icon(index.row())); -- 2.39.5