From 36945644e70db39a8316570bb44fabc7a3bd3d49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Wed, 15 Feb 2006 11:13:37 +0000 Subject: [PATCH] fix crash due to invalidated iterator git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13241 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt2/ChangeLog | 5 +++++ src/frontends/qt2/QCitationDialog.C | 7 +++---- src/frontends/xforms/ChangeLog | 5 +++++ src/frontends/xforms/FormCitation.C | 7 +++---- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 2ac7c57589..e1a3072666 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,8 @@ +2006-02-15 Jürgen Spitzmüller + + * QCitationDialog.C (up, down): fix crash due to invalidated + iterator. + 2006-01-29 Jürgen Spitzmüller * ui/LanguageModuleBase.ui: fix layout. diff --git a/src/frontends/qt2/QCitationDialog.C b/src/frontends/qt2/QCitationDialog.C index f34ff10e14..0e9f320570 100644 --- a/src/frontends/qt2/QCitationDialog.C +++ b/src/frontends/qt2/QCitationDialog.C @@ -29,6 +29,7 @@ using std::vector; using std::string; +using std::swap; namespace lyx { namespace frontend { @@ -193,11 +194,10 @@ void QCitationDialog::up() string const tmp = *it; selectedLB->removeItem(sel); - form_->citekeys.erase(it); + swap(form_->citekeys[sel - 1], form_->citekeys[sel]); selectedLB->insertItem(toqstr(tmp), sel - 1); selectedLB->setSelected(sel - 1, true); - form_->citekeys.insert(it - 1, tmp); form_->changed(); form_->fillStyles(); @@ -214,11 +214,10 @@ void QCitationDialog::down() string const tmp = *it; selectedLB->removeItem(sel); - form_->citekeys.erase(it); + swap(form_->citekeys[sel + 1], form_->citekeys[sel]); selectedLB->insertItem(toqstr(tmp), sel + 1); selectedLB->setSelected(sel + 1, true); - form_->citekeys.insert(it + 1, tmp); form_->changed(); form_->fillStyles(); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 4ddd7a89ab..06b8da0f36 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,8 @@ +2006-02-15 Jürgen Spitzmüller + + * FormCitation.C (input): fix crash due to invalidated + iterator. + 2005-12-12 Jürgen Spitzmüller * FormPreferences.C: fix off-by-x errors in paper size setting diff --git a/src/frontends/xforms/FormCitation.C b/src/frontends/xforms/FormCitation.C index 6e2c7d5dca..5664f836e8 100644 --- a/src/frontends/xforms/FormCitation.C +++ b/src/frontends/xforms/FormCitation.C @@ -30,6 +30,7 @@ using std::max; using std::vector; using std::string; +using std::swap; namespace lyx { @@ -384,11 +385,10 @@ ButtonPolicy::SMInput FormCitation::input(FL_OBJECT * ob, long) string const tmp = *it; fl_delete_browser_line(dialog_->browser_cite, sel); - citekeys.erase(it); + swap(citekeys[sel - 2], citekeys[sel - 1]); fl_insert_browser_line(dialog_->browser_cite, sel - 1, tmp.c_str()); fl_select_browser_line(dialog_->browser_cite, sel - 1); - citekeys.insert(it - 1, tmp); setCiteButtons(ON); activate = ButtonPolicy::SMI_VALID; @@ -402,11 +402,10 @@ ButtonPolicy::SMInput FormCitation::input(FL_OBJECT * ob, long) string const tmp = *it; fl_delete_browser_line(dialog_->browser_cite, sel); - citekeys.erase(it); + swap(citekeys[sel], citekeys[sel - 1]); fl_insert_browser_line(dialog_->browser_cite, sel+1, tmp.c_str()); fl_select_browser_line(dialog_->browser_cite, sel+1); - citekeys.insert(it+1, tmp); setCiteButtons(ON); activate = ButtonPolicy::SMI_VALID;