From: Abdelrazak Younes Date: Sun, 20 Sep 2009 21:41:21 +0000 (+0000) Subject: Try to dispatch to document BufferView in case dispatch to current BufferView fails... X-Git-Tag: 2.0.0~5476 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=53797b653a7c6952bcbc0d3f73bd74a078f9b0b0;p=features.git Try to dispatch to document BufferView in case dispatch to current BufferView fails. This is needed for the LFUNs introduced in r31412 URL: http://www.lyx.org/trac/changeset/31412 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31419 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/BufferView.cpp b/src/BufferView.cpp index e929f789f2..fbecee4c92 100644 --- a/src/BufferView.cpp +++ b/src/BufferView.cpp @@ -1095,6 +1095,8 @@ bool BufferView::dispatch(FuncRequest const & cmd) switch (cmd.action) { case LFUN_BUFFER_PARAMS_APPLY: { + if (buffer_.isInternal()) + return false; DocumentClass const * const oldClass = buffer_.params().documentClassPtr(); cur.recordUndoFullDocument(); istringstream ss(to_utf8(cmd.argument())); @@ -1116,6 +1118,8 @@ bool BufferView::dispatch(FuncRequest const & cmd) } case LFUN_LAYOUT_MODULES_CLEAR: { + if (buffer_.isInternal()) + return false; DocumentClass const * const oldClass = buffer_.params().documentClassPtr(); cur.recordUndoFullDocument(); @@ -1127,6 +1131,8 @@ bool BufferView::dispatch(FuncRequest const & cmd) } case LFUN_LAYOUT_MODULE_ADD: { + if (buffer_.isInternal()) + return false; BufferParams const & params = buffer_.params(); if (!params.moduleCanBeAdded(argument)) { LYXERR0("Module `" << argument << @@ -1144,6 +1150,8 @@ bool BufferView::dispatch(FuncRequest const & cmd) } case LFUN_TEXTCLASS_APPLY: { + if (buffer_.isInternal()) + return false; if (!LayoutFileList::get().load(argument, buffer_.temppath()) && !LayoutFileList::get().load(argument, buffer_.filePath())) break; @@ -1167,11 +1175,15 @@ bool BufferView::dispatch(FuncRequest const & cmd) } case LFUN_TEXTCLASS_LOAD: + if (buffer_.isInternal()) + return false; LayoutFileList::get().load(argument, buffer_.temppath()) || LayoutFileList::get().load(argument, buffer_.filePath()); break; case LFUN_LAYOUT_RELOAD: { + if (buffer_.isInternal()) + return false; DocumentClass const * const oldClass = buffer_.params().documentClassPtr(); LayoutFileIndex bc = buffer_.params().baseClassID(); LayoutFileList::get().reset(bc); diff --git a/src/LyXFunc.cpp b/src/LyXFunc.cpp index b53f2d2c2d..13f0ab3ba0 100644 --- a/src/LyXFunc.cpp +++ b/src/LyXFunc.cpp @@ -1091,6 +1091,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd) if (lyx_view_ == 0) break; + BufferView * bv = lyx_view_->documentBufferView(); + BufferView * doc_bv = lyx_view_->documentBufferView(); + // Start an undo group. This may be needed for // some stuff like inset-apply on labels. if (theBufferList().isLoaded(buffer)) @@ -1098,38 +1101,44 @@ void LyXFunc::dispatch(FuncRequest const & cmd) // Let the current LyXView dispatch its own actions. if (lyx_view_->dispatch(cmd)) { - if (lyx_view_->currentBufferView()) { - updateFlags = lyx_view_->currentBufferView()->cursor().result().update(); + if (bv) { + updateFlags = bv->cursor().result().update(); if (theBufferList().isLoaded(buffer)) buffer->undo().endUndoGroup(); } break; } - LASSERT(lyx_view_->currentBufferView(), /**/); + LASSERT(bv, /**/); // Let the current BufferView dispatch its own actions. - if (lyx_view_->currentBufferView()->dispatch(cmd)) { + if (bv->dispatch(cmd)) { + // The BufferView took care of its own updates if needed. + updateFlags = Update::None; + if (theBufferList().isLoaded(buffer)) + buffer->undo().endUndoGroup(); + break; + } + // Try with the document BufferView dispatch if any. + if (doc_bv && doc_bv->dispatch(cmd)) { // The BufferView took care of its own updates if needed. + buffer = &(doc_bv->buffer()); updateFlags = Update::None; if (theBufferList().isLoaded(buffer)) buffer->undo().endUndoGroup(); break; } - // OK, so try the Buffer itself + // OK, so try the current Buffer itself... DispatchResult dr; - BufferView * bv = lyx_view_->currentBufferView(); bv->buffer().dispatch(cmd, dr); if (dr.dispatched()) { updateFlags = dr.update(); break; } - // OK, so try with the document Buffer. - BufferView * doc_bv = lyx_view_->documentBufferView(); + // and with the document Buffer. if (doc_bv) { - buffer = &(doc_bv->buffer()); - buffer->dispatch(cmd, dr); + doc_bv->buffer().dispatch(cmd, dr); if (dr.dispatched()) { updateFlags = dr.update(); break;