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
This commit is contained in:
Abdelrazak Younes 2007-11-26 22:45:17 +00:00
parent bfec9543b3
commit 1060f922f0
10 changed files with 19 additions and 21 deletions

View File

@ -197,7 +197,8 @@ bool import(LyXView * lv, FileName const & filename,
: changeExtension(filename.absFilename(), : changeExtension(filename.absFilename(),
formats.extension(loader_format)); formats.extension(loader_format));
lv->view()->insertPlaintextFile(filename2, as_paragraphs); 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 // we are done
@ -1823,7 +1824,7 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
// Let the current LyXView dispatch its own actions. // Let the current LyXView dispatch its own actions.
BOOST_ASSERT(lyx_view_); BOOST_ASSERT(lyx_view_);
if (lyx_view_->dispatch(cmd, false)) { if (lyx_view_->dispatch(cmd)) {
if (lyx_view_->view()) if (lyx_view_->view())
updateFlags = lyx_view_->view()->cursor().result().update(); updateFlags = lyx_view_->view()->cursor().result().update();
break; break;

View File

@ -78,7 +78,7 @@ public:
/// \param propagate: indicate if the dispatch should be probagated to /// \param propagate: indicate if the dispatch should be probagated to
/// the main lyx::dispatch(). /// the main lyx::dispatch().
/// \return true if the \c FuncRequest has been dispatched. /// \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; virtual void restartCursor() = 0;

View File

@ -62,7 +62,8 @@ void Action::update()
void Action::action() void Action::action()
{ {
//LYXERR(Debug::ACTION, "calling LyXFunc::dispatch: func_: "); //LYXERR(Debug::ACTION, "calling LyXFunc::dispatch: func_: ");
lyxView_.dispatch(func_); theLyXFunc().setLyXView(&lyxView_);
lyx::dispatch(func_);
triggered(this); triggered(this);
} }

View File

@ -49,7 +49,8 @@ bool Dialog::canApply() const
void Dialog::dispatch(FuncRequest const & fr) const void Dialog::dispatch(FuncRequest const & fr) const
{ {
lyxview_->dispatch(fr); theLyXFunc().setLyXView(lyxview_);
lyx::dispatch(fr);
} }

View File

@ -273,7 +273,8 @@ docstring const GuiCommandBuffer::getCurrentState() const
void GuiCommandBuffer::hide() const void GuiCommandBuffer::hide() const
{ {
FuncRequest cmd(LFUN_COMMAND_EXECUTE, "off"); 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(); history_pos_ = history_.end();
FuncRequest func = lyxaction.lookupFunc(str); FuncRequest func = lyxaction.lookupFunc(str);
func.origin = FuncRequest::COMMANDBUFFER; func.origin = FuncRequest::COMMANDBUFFER;
view_->dispatch(func); theLyXFunc().setLyXView(view_);
lyx::dispatch(func);
} }
} // namespace frontend } // namespace frontend

View File

@ -113,7 +113,7 @@ void GuiToc::goTo(int type, QModelIndex const & index)
LYXERR(Debug::GUI, "GuiToc::goTo " << to_utf8(it->str())); LYXERR(Debug::GUI, "GuiToc::goTo " << to_utf8(it->str()));
string const tmp = convert<string>(it->id()); string const tmp = convert<string>(it->id());
lyxview().dispatch(FuncRequest(LFUN_PARAGRAPH_GOTO, tmp)); dispatch(FuncRequest(LFUN_PARAGRAPH_GOTO, tmp));
} }

View File

@ -352,7 +352,8 @@ void GuiLayoutBox::selected(const QString & str)
if (translateIfPossible(itname) == name) { if (translateIfPossible(itname) == name) {
FuncRequest const func(LFUN_LAYOUT, itname, FuncRequest const func(LFUN_LAYOUT, itname,
FuncRequest::TOOLBAR); FuncRequest::TOOLBAR);
owner_.dispatch(func); theLyXFunc().setLyXView(&owner_);
lyx::dispatch(func);
return; return;
} }
} }

View File

@ -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(); BufferView * bv = view();
// By default we won't need any update. // By default we won't need any update.
@ -1161,18 +1161,9 @@ bool GuiView::dispatch(FuncRequest const & cmd, bool propagate)
} }
default: default:
if (propagate) {
theLyXFunc().setLyXView(this);
lyx::dispatch(cmd);
}
return false; return false;
} }
if (bv) {
bv->processUpdateFlags(bv->cursor().result().update());
// We won't need any new update.
bv->cursor().updateFlags(Update::None);
}
return true; return true;
} }

View File

@ -76,7 +76,7 @@ public:
void updateToolbars(); void updateToolbars();
QMenu * createPopupMenu(); QMenu * createPopupMenu();
FuncStatus getStatus(FuncRequest const & cmd); FuncStatus getStatus(FuncRequest const & cmd);
bool dispatch(FuncRequest const & cmd, bool propagate = true); bool dispatch(FuncRequest const & cmd);
/// ///
void setLayoutDialog(GuiLayoutBox *); void setLayoutDialog(GuiLayoutBox *);

View File

@ -108,7 +108,8 @@ void InsertTableWidget::mouseReleaseEvent(QMouseEvent * /*event*/)
{ {
if (underMouse_) { if (underMouse_) {
QString const data = QString("%1 %2").arg(bottom_).arg(right_); 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 // emit signal
visible(false); visible(false);