From: Stephan Witt Date: Sat, 2 Jul 2011 10:41:36 +0000 (+0000) Subject: #7661 check buffer of cursors before using compare operator to avoid a crash X-Git-Tag: 2.1.0beta1~2979 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=7252ebbb3495c498ffcac0b037e0859cb6b306a0;p=lyx.git #7661 check buffer of cursors before using compare operator to avoid a crash git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@39227 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/frontends/qt4/GuiSpellchecker.cpp b/src/frontends/qt4/GuiSpellchecker.cpp index f6da10a9eb..5e7305e75a 100644 --- a/src/frontends/qt4/GuiSpellchecker.cpp +++ b/src/frontends/qt4/GuiSpellchecker.cpp @@ -79,6 +79,8 @@ struct SpellcheckerWidget::Private return false; } void canCheck() { incheck_ = false; } + /// check for wrap around of current position + bool isWrapAround(DocIterator cursor) const; /// Ui::SpellcheckerUi ui; /// @@ -200,6 +202,11 @@ bool SpellcheckerWidget::Private::continueFromBeginning() return true; } +bool SpellcheckerWidget::Private::isWrapAround(DocIterator cursor) const +{ + return wrap_around_ && start_.buffer() == cursor.buffer() && start_ < cursor; +} + void SpellcheckerWidget::Private::forward() { @@ -216,7 +223,7 @@ void SpellcheckerWidget::Private::forward() //FIXME we must be at the end of a cell dispatch(FuncRequest(LFUN_CHAR_FORWARD)); } - if (wrap_around_ && start_ < bv->cursor()) { + if (isWrapAround(bv->cursor())) { dv_->hide(); } } @@ -397,7 +404,7 @@ void SpellcheckerWidget::Private::check() return; } - if (wrap_around_ && start_ < from) { + if (isWrapAround(from)) { dv_->hide(); return; }