From 1060f922f06f1906e49d68498e1e8dc8d919a3f0 Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Mon, 26 Nov 2007 22:45:17 +0000 Subject: [PATCH] Please JMarc: Make sure we always pass through LyXFunc::dispatch() even if this is a waste of CPU. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21807 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LyXFunc.cpp | 5 +++-- src/frontends/LyXView.h | 2 +- src/frontends/qt4/Action.cpp | 3 ++- src/frontends/qt4/Dialog.cpp | 3 ++- src/frontends/qt4/GuiCommandBuffer.cpp | 6 ++++-- src/frontends/qt4/GuiToc.cpp | 2 +- src/frontends/qt4/GuiToolbar.cpp | 3 ++- src/frontends/qt4/GuiView.cpp | 11 +---------- src/frontends/qt4/GuiView.h | 2 +- src/frontends/qt4/InsertTableWidget.cpp | 3 ++- 10 files changed, 19 insertions(+), 21 deletions(-) diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index 891d40b010..af5cf05e11 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -197,7 +197,8 @@ bool import(LyXView * lv, FileName const & filename, : changeExtension(filename.absFilename(), formats.extension(loader_format)); lv->view()->insertPlaintextFile(filename2, as_paragraphs); - lv->dispatch(FuncRequest(LFUN_MARK_OFF), true); + theLyXFunc().setLyXView(lv); + lyx::dispatch(FuncRequest(LFUN_MARK_OFF)); } // we are done @@ -1823,7 +1824,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd) // Let the current LyXView dispatch its own actions. BOOST_ASSERT(lyx_view_); - if (lyx_view_->dispatch(cmd, false)) { + if (lyx_view_->dispatch(cmd)) { if (lyx_view_->view()) updateFlags = lyx_view_->view()->cursor().result().update(); break; diff --git a/src/frontends/LyXView.h b/src/frontends/LyXView.h index da93d5d4d4..9c610ccffb 100644 --- a/src/frontends/LyXView.h +++ b/src/frontends/LyXView.h @@ -78,7 +78,7 @@ public: /// \param propagate: indicate if the dispatch should be probagated to /// the main lyx::dispatch(). /// \return true if the \c FuncRequest has been dispatched. - virtual bool dispatch(FuncRequest const & cmd, bool propagate) = 0; + virtual bool dispatch(FuncRequest const & cmd) = 0; /// virtual void restartCursor() = 0; diff --git a/src/frontends/qt4/Action.cpp b/src/frontends/qt4/Action.cpp index 16996b410f..d15bdaecdd 100644 --- a/src/frontends/qt4/Action.cpp +++ b/src/frontends/qt4/Action.cpp @@ -62,7 +62,8 @@ void Action::update() void Action::action() { //LYXERR(Debug::ACTION, "calling LyXFunc::dispatch: func_: "); - lyxView_.dispatch(func_); + theLyXFunc().setLyXView(&lyxView_); + lyx::dispatch(func_); triggered(this); } diff --git a/src/frontends/qt4/Dialog.cpp b/src/frontends/qt4/Dialog.cpp index cc3d3999c5..40b4f37632 100644 --- a/src/frontends/qt4/Dialog.cpp +++ b/src/frontends/qt4/Dialog.cpp @@ -49,7 +49,8 @@ bool Dialog::canApply() const void Dialog::dispatch(FuncRequest const & fr) const { - lyxview_->dispatch(fr); + theLyXFunc().setLyXView(lyxview_); + lyx::dispatch(fr); } diff --git a/src/frontends/qt4/GuiCommandBuffer.cpp b/src/frontends/qt4/GuiCommandBuffer.cpp index a18515cff4..ce6896ef9f 100644 --- a/src/frontends/qt4/GuiCommandBuffer.cpp +++ b/src/frontends/qt4/GuiCommandBuffer.cpp @@ -273,7 +273,8 @@ docstring const GuiCommandBuffer::getCurrentState() const void GuiCommandBuffer::hide() const { FuncRequest cmd(LFUN_COMMAND_EXECUTE, "off"); - view_->dispatch(cmd); + theLyXFunc().setLyXView(view_); + lyx::dispatch(cmd); } @@ -325,7 +326,8 @@ void GuiCommandBuffer::dispatch(string const & str) history_pos_ = history_.end(); FuncRequest func = lyxaction.lookupFunc(str); func.origin = FuncRequest::COMMANDBUFFER; - view_->dispatch(func); + theLyXFunc().setLyXView(view_); + lyx::dispatch(func); } } // namespace frontend diff --git a/src/frontends/qt4/GuiToc.cpp b/src/frontends/qt4/GuiToc.cpp index 7e3ca23da1..f366a1ffcc 100644 --- a/src/frontends/qt4/GuiToc.cpp +++ b/src/frontends/qt4/GuiToc.cpp @@ -113,7 +113,7 @@ void GuiToc::goTo(int type, QModelIndex const & index) LYXERR(Debug::GUI, "GuiToc::goTo " << to_utf8(it->str())); string const tmp = convert(it->id()); - lyxview().dispatch(FuncRequest(LFUN_PARAGRAPH_GOTO, tmp)); + dispatch(FuncRequest(LFUN_PARAGRAPH_GOTO, tmp)); } diff --git a/src/frontends/qt4/GuiToolbar.cpp b/src/frontends/qt4/GuiToolbar.cpp index c7de616f96..a2e0618710 100644 --- a/src/frontends/qt4/GuiToolbar.cpp +++ b/src/frontends/qt4/GuiToolbar.cpp @@ -352,7 +352,8 @@ void GuiLayoutBox::selected(const QString & str) if (translateIfPossible(itname) == name) { FuncRequest const func(LFUN_LAYOUT, itname, FuncRequest::TOOLBAR); - owner_.dispatch(func); + theLyXFunc().setLyXView(&owner_); + lyx::dispatch(func); return; } } diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index 46c59a3804..efb877ffe4 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -1018,7 +1018,7 @@ FuncStatus GuiView::getStatus(FuncRequest const & cmd) } -bool GuiView::dispatch(FuncRequest const & cmd, bool propagate) +bool GuiView::dispatch(FuncRequest const & cmd) { BufferView * bv = view(); // By default we won't need any update. @@ -1161,18 +1161,9 @@ bool GuiView::dispatch(FuncRequest const & cmd, bool propagate) } default: - if (propagate) { - theLyXFunc().setLyXView(this); - lyx::dispatch(cmd); - } return false; } - if (bv) { - bv->processUpdateFlags(bv->cursor().result().update()); - // We won't need any new update. - bv->cursor().updateFlags(Update::None); - } return true; } diff --git a/src/frontends/qt4/GuiView.h b/src/frontends/qt4/GuiView.h index 4078683878..a1c05f6ecd 100644 --- a/src/frontends/qt4/GuiView.h +++ b/src/frontends/qt4/GuiView.h @@ -76,7 +76,7 @@ public: void updateToolbars(); QMenu * createPopupMenu(); FuncStatus getStatus(FuncRequest const & cmd); - bool dispatch(FuncRequest const & cmd, bool propagate = true); + bool dispatch(FuncRequest const & cmd); /// void setLayoutDialog(GuiLayoutBox *); diff --git a/src/frontends/qt4/InsertTableWidget.cpp b/src/frontends/qt4/InsertTableWidget.cpp index c385d02a8d..4ff38099ed 100644 --- a/src/frontends/qt4/InsertTableWidget.cpp +++ b/src/frontends/qt4/InsertTableWidget.cpp @@ -108,7 +108,8 @@ void InsertTableWidget::mouseReleaseEvent(QMouseEvent * /*event*/) { if (underMouse_) { QString const data = QString("%1 %2").arg(bottom_).arg(right_); - lyxView_.dispatch(FuncRequest(LFUN_TABULAR_INSERT, fromqstr(data))); + theLyXFunc().setLyXView(&lyxView_); + lyx::dispatch(FuncRequest(LFUN_TABULAR_INSERT, fromqstr(data))); } // emit signal visible(false);