]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt4/GuiApplication.cpp
Fix reloading of local layout file (bug #11120)
[lyx.git] / src / frontends / qt4 / GuiApplication.cpp
index 35b639c9ac490e27e09ee25c123afce961eb9840..79f14d64582840a3bf00600734b47369b3429a72 100644 (file)
@@ -1395,21 +1395,19 @@ DispatchResult const & GuiApplication::dispatch(FuncRequest const & cmd)
        if (current_view_ && current_view_->currentBufferView()) {
                current_view_->currentBufferView()->cursor().saveBeforeDispatchPosXY();
                buffer = &current_view_->currentBufferView()->buffer();
-               if (buffer)
-                       buffer->undo().beginUndoGroup();
        }
 
        DispatchResult dr;
+       dr.screenUpdate(Update::FitCursor);
+       {
+               // This handles undo groups automagically
+               UndoGroupHelper ugh(buffer);
+               dispatch(cmd, dr);
+       }
+
        // redraw the screen at the end (first of the two drawing steps).
        // This is done unless explicitly requested otherwise
-       dr.screenUpdate(Update::FitCursor);
-       dispatch(cmd, dr);
        updateCurrentView(cmd, dr);
-
-       // the buffer may have been closed by one action
-       if (theBufferList().isLoaded(buffer) || theBufferList().isInternal(buffer))
-               buffer->undo().endUndoGroup();
-
        d->dispatch_result_ = dr;
        return d->dispatch_result_;
 }
@@ -1439,7 +1437,7 @@ void GuiApplication::updateCurrentView(FuncRequest const & cmd, DispatchResult &
                theSelection().haveSelection(bv->cursor().selection());
 
                // update gui
-               current_view_->restartCursor();
+               current_view_->restartCaret();
        }
        if (dr.needMessageUpdate()) {
                // Some messages may already be translated, so we cannot use _()
@@ -1633,14 +1631,7 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
        case LFUN_SCREEN_FONT_UPDATE: {
                // handle the screen font changes.
                d->font_loader_.update();
-               // Backup current_view_
-               GuiView * view = current_view_;
-               // Set current_view_ to zero to forbid GuiWorkArea::redraw()
-               // to skip the refresh.
-               current_view_ = 0;
-               theBufferList().changed(false);
-               // Restore current_view_
-               current_view_ = view;
+               dr.screenUpdate(Update::Force | Update::FitCursor);
                break;
        }
 
@@ -1733,8 +1724,8 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
        }
 
        case LFUN_SET_COLOR: {
-               string lyx_name;
-               string const x11_name = split(to_utf8(cmd.argument()), lyx_name, ' ');
+               string const lyx_name = cmd.getArg(0);
+               string const x11_name = cmd.getArg(1);
                if (lyx_name.empty() || x11_name.empty()) {
                        if (current_view_)
                                current_view_->message(
@@ -1861,8 +1852,11 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        dr.setMessage(bformat(_("Cannot iterate more than %1$d times"), max_iter));
                        dr.setError(true);
                } else {
-                       for (int i = 0; i < count; ++i)
-                               dispatch(lyxaction.lookupFunc(rest));
+                       for (int i = 0; i < count; ++i) {
+                               FuncRequest lfun = lyxaction.lookupFunc(rest);
+                               lfun.allowAsync(false);
+                               dispatch(lfun);
+                       }
                }
                break;
        }
@@ -1873,18 +1867,16 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                // FIXME: this LFUN should also work without any view.
                Buffer * buffer = (current_view_ && current_view_->documentBufferView())
                                  ? &(current_view_->documentBufferView()->buffer()) : 0;
-               if (buffer)
-                       buffer->undo().beginUndoGroup();
+               // This handles undo groups automagically
+               UndoGroupHelper ugh(buffer);
                while (!arg.empty()) {
                        string first;
                        arg = split(arg, first, ';');
                        FuncRequest func(lyxaction.lookupFunc(first));
+                       func.allowAsync(false);
                        func.setOrigin(cmd.origin());
                        dispatch(func);
                }
-               // the buffer may have been closed by one action
-               if (theBufferList().isLoaded(buffer) || theBufferList().isInternal(buffer))
-                       buffer->undo().endUndoGroup();
                break;
        }
 
@@ -2158,7 +2150,7 @@ void GuiApplication::processKeySym(KeySymbol const & keysym, KeyModifier state)
                if (!keysym.isOK())
                        LYXERR(Debug::KEY, "Empty kbd action (probably composing)");
                if (current_view_)
-                       current_view_->restartCursor();
+                       current_view_->restartCaret();
                return;
        }
 
@@ -2218,7 +2210,7 @@ void GuiApplication::processKeySym(KeySymbol const & keysym, KeyModifier state)
                        if (!isPrintable(encoded_last_key)) {
                                LYXERR(Debug::KEY, "Non-printable character! Omitting.");
                                if (current_view_)
-                                       current_view_->restartCursor();
+                                       current_view_->restartCaret();
                                return;
                        }
                        // The following modifier check is not needed on Mac.
@@ -2240,7 +2232,7 @@ void GuiApplication::processKeySym(KeySymbol const & keysym, KeyModifier state)
                        {
                                if (current_view_) {
                                        current_view_->message(_("Unknown function."));
-                                       current_view_->restartCursor();
+                                       current_view_->restartCaret();
                                }
                                return;
                        }
@@ -2255,7 +2247,7 @@ void GuiApplication::processKeySym(KeySymbol const & keysym, KeyModifier state)
                        LYXERR(Debug::KEY, "Unknown Action and not isText() -- giving up");
                        if (current_view_) {
                                current_view_->message(_("Unknown function."));
-                               current_view_->restartCursor();
+                               current_view_->restartCaret();
                        }
                        return;
                }