From 1d1b204eb2ba7cdcf0023bc9e16b639d85772199 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Wed, 7 Apr 2010 12:35:32 +0000 Subject: [PATCH] Fix bug #6519. This is some of the "instability" that resulted from Abdel's moving the LyXFunc code to GuiApplication. This restores some of the structure of that code: The early returns bypassed the code that marked the buffer dirty. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34071 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/frontends/qt4/GuiApplication.cpp | 135 +++++++++++++-------------- 1 file changed, 63 insertions(+), 72 deletions(-) diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index 4daecb0e42..74fcb23a06 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -1225,6 +1225,7 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr) // Assumes that the action will be dispatched. dr.dispatched(true); + GuiView * lv = current_view_; switch (cmd.action) { case LFUN_WINDOW_NEW: @@ -1558,81 +1559,71 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr) break; default: - // Notify the caller that the action has not been dispatched. - dr.dispatched(false); - break; - } - - // The action has been dispatched in this method, nothing more to do. - if (dr.dispatched()) - return; - - GuiView * lv = current_view_; - - // Everything below is only for active window - if (lv == 0) - return; - - // Let the current GuiView dispatch its own actions. - lv->dispatch(cmd, dr); - if (dr.dispatched() && lv ) - return; - - BufferView * bv = lv->currentBufferView(); - LASSERT(bv, /**/); - - // Let the current BufferView dispatch its own actions. - bv->dispatch(cmd, dr); - if (dr.dispatched()) - return; - - BufferView * doc_bv = lv->documentBufferView(); - // Try with the document BufferView dispatch if any. - if (doc_bv) { - doc_bv->dispatch(cmd, dr); + // Everything below is only for active window + if (lv == 0) + break; + + // Let the current GuiView dispatch its own actions. + lv->dispatch(cmd, dr); if (dr.dispatched()) - return; - } - - // OK, so try the current Buffer itself... - bv->buffer().dispatch(cmd, dr); - if (dr.dispatched()) - return; - - // and with the document Buffer. - if (doc_bv) { - doc_bv->buffer().dispatch(cmd, dr); + break; + + BufferView * bv = lv->currentBufferView(); + LASSERT(bv, /**/); + + // Let the current BufferView dispatch its own actions. + bv->dispatch(cmd, dr); if (dr.dispatched()) - return; - } - - // Let the current Cursor dispatch its own actions. - Cursor old = bv->cursor(); - bv->cursor().dispatch(cmd); - - // notify insets we just left - if (bv->cursor() != old) { - old.fixIfBroken(); - bool badcursor = notifyCursorLeavesOrEnters(old, bv->cursor()); - if (badcursor) - bv->cursor().fixIfBroken(); - } - - // update completion. We do it here and not in - // processKeySym to avoid another redraw just for a - // changed inline completion - if (cmd.origin == FuncRequest::KEYBOARD) { - if (cmd.action == LFUN_SELF_INSERT - || (cmd.action == LFUN_ERT_INSERT && bv->cursor().inMathed())) - lv->updateCompletion(bv->cursor(), true, true); - else if (cmd.action == LFUN_CHAR_DELETE_BACKWARD) - lv->updateCompletion(bv->cursor(), false, true); - else - lv->updateCompletion(bv->cursor(), false, false); + break; + + BufferView * doc_bv = lv->documentBufferView(); + // Try with the document BufferView dispatch if any. + if (doc_bv) { + doc_bv->dispatch(cmd, dr); + if (dr.dispatched()) + break; + } + + // OK, so try the current Buffer itself... + bv->buffer().dispatch(cmd, dr); + if (dr.dispatched()) + break; + + // and with the document Buffer. + if (doc_bv) { + doc_bv->buffer().dispatch(cmd, dr); + if (dr.dispatched()) + break; + } + + // Let the current Cursor dispatch its own actions. + Cursor old = bv->cursor(); + bv->cursor().dispatch(cmd); + + // notify insets we just left + if (bv->cursor() != old) { + old.fixIfBroken(); + bool badcursor = notifyCursorLeavesOrEnters(old, bv->cursor()); + if (badcursor) + bv->cursor().fixIfBroken(); + } + + // update completion. We do it here and not in + // processKeySym to avoid another redraw just for a + // changed inline completion + if (cmd.origin == FuncRequest::KEYBOARD) { + if (cmd.action == LFUN_SELF_INSERT + || (cmd.action == LFUN_ERT_INSERT && bv->cursor().inMathed())) + lv->updateCompletion(bv->cursor(), true, true); + else if (cmd.action == LFUN_CHAR_DELETE_BACKWARD) + lv->updateCompletion(bv->cursor(), false, true); + else + lv->updateCompletion(bv->cursor(), false, false); + } + + dr = bv->cursor().result(); } - - dr = bv->cursor().result(); - + // if we executed a mutating lfun, mark the buffer as dirty Buffer * doc_buffer = (lv && lv->documentBufferView()) ? &(lv->documentBufferView()->buffer()) : 0; -- 2.39.2