From a4fc781dcc03c3fbf9811841db6b244ba511e436 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Thu, 28 Jul 2005 10:26:33 +0000 Subject: [PATCH] fix bug 1950: Spellchecker runs twice git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@10367 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/controllers/ChangeLog | 12 ++++++++++++ src/frontends/controllers/ControlSpellchecker.C | 4 +++- src/frontends/controllers/ControlSpellchecker.h | 6 ++++++ src/frontends/controllers/Dialog.h | 6 ++++++ src/frontends/gtk/ChangeLog | 5 +++++ src/frontends/gtk/GViewBase.C | 3 +++ src/frontends/qt2/ChangeLog | 5 +++++ src/frontends/qt2/QDialogView.C | 2 ++ src/frontends/xforms/ChangeLog | 5 +++++ src/frontends/xforms/FormDialogView.C | 2 ++ 10 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/frontends/controllers/ChangeLog b/src/frontends/controllers/ChangeLog index 9461c9c9b7..c9f19d8d17 100644 --- a/src/frontends/controllers/ChangeLog +++ b/src/frontends/controllers/ChangeLog @@ -1,3 +1,15 @@ +2005-07-28 Jean-Marc Lasgouttes + + bug 1950. + + * Dialog.h (exitEarly): virtual function, returns false as a + default. + + * ControlSpellchecker.h (exitEarly): return exitEarly_ + + * ControlSpellchecker.C (check): set exitEarly_ to true when + spell-checking is finished, false otherwise. + 2005-07-27 Jürgen Spitzmüller * ControlBibtex.C: sort bst files (bug 1936) diff --git a/src/frontends/controllers/ControlSpellchecker.C b/src/frontends/controllers/ControlSpellchecker.C index 161fba9d27..e08c7df620 100644 --- a/src/frontends/controllers/ControlSpellchecker.C +++ b/src/frontends/controllers/ControlSpellchecker.C @@ -54,7 +54,7 @@ namespace frontend { ControlSpellchecker::ControlSpellchecker(Dialog & parent) - : Dialog::Controller(parent), + : Dialog::Controller(parent), exitEarly_(false), oldval_(0), newvalue_(0), count_(0) {} @@ -202,6 +202,7 @@ void ControlSpellchecker::check() ++start; BufferParams & bufferparams = kernel().buffer().params(); + exitEarly_ = false; while (res == SpellBase::OK || res == SpellBase::IGNORED_WORD) { word_ = nextWord(cur, start, bufferparams); @@ -209,6 +210,7 @@ void ControlSpellchecker::check() // end of document if (getWord().empty()) { showSummary(); + exitEarly_ = true; return; } diff --git a/src/frontends/controllers/ControlSpellchecker.h b/src/frontends/controllers/ControlSpellchecker.h index e04435bd75..c187bc5d98 100644 --- a/src/frontends/controllers/ControlSpellchecker.h +++ b/src/frontends/controllers/ControlSpellchecker.h @@ -40,6 +40,8 @@ public: virtual void dispatchParams() {} /// virtual bool isBufferDependent() const { return true; } + /// + virtual bool exitEarly() const { return exitEarly_; } /// replace word with replacement void replace(std::string const &); @@ -76,6 +78,10 @@ private: /// show count of checked words at normal exit void showSummary(); +private: + /// set to true when spellchecking is finished + bool exitEarly_; + /// current word being checked and lang code WordLangTuple word_; diff --git a/src/frontends/controllers/Dialog.h b/src/frontends/controllers/Dialog.h index 9408ab3166..e0219eeb4e 100644 --- a/src/frontends/controllers/Dialog.h +++ b/src/frontends/controllers/Dialog.h @@ -186,6 +186,12 @@ public: * return true. */ virtual bool disconnectOnApply() const { return false; } + + /** \return true if Dialog::View::show() should not display the dialog + * after running update. Currently, only ControlSpellchecker + * makes use of that. + */ + virtual bool exitEarly() const { return false; } //@} protected: diff --git a/src/frontends/gtk/ChangeLog b/src/frontends/gtk/ChangeLog index 73b26950d7..c0189e6fa6 100644 --- a/src/frontends/gtk/ChangeLog +++ b/src/frontends/gtk/ChangeLog @@ -1,3 +1,8 @@ +2005-07-28 Jean-Marc Lasgouttes + + * GViewBase.C (show): exit after update if Controller::exitEarly() + is true. (bug 1950) + 2005-07-27 Jürgen Spitzmüller * GTexInfo.C: Load and display full-path and no-path diff --git a/src/frontends/gtk/GViewBase.C b/src/frontends/gtk/GViewBase.C index dbee44c9df..bb45a5fc3e 100644 --- a/src/frontends/gtk/GViewBase.C +++ b/src/frontends/gtk/GViewBase.C @@ -62,6 +62,9 @@ void GViewBase::show() build(); } update(); + if (dialog().controller().exitEarly()) + return; + window()->show(); } diff --git a/src/frontends/qt2/ChangeLog b/src/frontends/qt2/ChangeLog index 58b1a7bcc9..477a8eada1 100644 --- a/src/frontends/qt2/ChangeLog +++ b/src/frontends/qt2/ChangeLog @@ -1,3 +1,8 @@ +2005-07-28 Jean-Marc Lasgouttes + + * QDialogView.C (show): exit after update if Controller::exitEarly() + is true. (bug 1950) + 2005-07-27 Jürgen Spitzmüller * QBibTeX.C: Do not insert empty items to bst combo. diff --git a/src/frontends/qt2/QDialogView.C b/src/frontends/qt2/QDialogView.C index 087a7de99e..6251a689ad 100644 --- a/src/frontends/qt2/QDialogView.C +++ b/src/frontends/qt2/QDialogView.C @@ -51,6 +51,8 @@ void QDialogView::show() form()->setMinimumSize(form()->sizeHint()); update(); // make sure its up-to-date + if (dialog().controller().exitEarly()) + return; form()->setCaption(toqstr("LyX: " + getTitle())); diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index 6619a1bc44..4dff0cadaf 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,8 @@ +2005-07-28 Jean-Marc Lasgouttes + + * FormDialogView.C (show): exit after update if Controller::exitEarly() + is true. (bug 1950) + 2005-07-27 Jürgen Spitzmüller * FormTexInfo.C: Load and display full-path and no-path diff --git a/src/frontends/xforms/FormDialogView.C b/src/frontends/xforms/FormDialogView.C index 5e742bdaa5..13b0822ade 100644 --- a/src/frontends/xforms/FormDialogView.C +++ b/src/frontends/xforms/FormDialogView.C @@ -145,6 +145,8 @@ void FormDialogView::show() fl_freeze_form(form()); update(); fl_unfreeze_form(form()); + if (dialog().controller().exitEarly()) + return; if (form()->visible) { fl_raise_form(form());