]> git.lyx.org Git - features.git/commitdiff
Fix bugs #6871 and #8119.
authorEnrico Forestieri <forenr@lyx.org>
Fri, 13 Apr 2012 00:57:25 +0000 (02:57 +0200)
committerEnrico Forestieri <forenr@lyx.org>
Sun, 15 Apr 2012 22:19:22 +0000 (00:19 +0200)
Both bugs above were due to a missing screen update. This patch
updates the current view after dispatching a lyxserver command
and thus solves both.

The patch is quite strightforward and the only difficulty was due
to the fact that the lyxserver needs the result of the dispatched
command. Now, GuiApplication::dispatch(FuncRequest const &)
does update the view, but does not return any result, while
GuiApplication::dispatch(FuncRequest const &, DispatchResult &),
which is also called by the former, does not update the view.
So, I split the first one, isolating the code performing the update,
such that the second one can also update the current view when
the caller is the lyx server. When the action is initiated by
anything different from the lyx server, the behavior is unchanged.

(cherry picked from commit ea3154184833f4f2426eb2a956878e83ddd822d9)

src/FuncRequest.h
src/Server.cpp
src/ServerSocket.cpp
src/frontends/qt4/GuiApplication.cpp
src/frontends/qt4/GuiApplication.h
status.20x

index 7fd3e1222f290cfaa143594361eb95724212be3c..175eb59fd134085d4cd67e4e39d388491887f73c 100644 (file)
@@ -35,6 +35,7 @@ public:
                TOOLBAR, // A toolbar icon
                KEYBOARD, // a keyboard binding
                COMMANDBUFFER, 
+               LYXSERVER, 
                TOC
        };
 
index b6ae8d8b1fece30f7e71df4dea4b5213421e9c84..7ec096e25d9251a11f25a863d6a07b3258ff2f01 100644 (file)
@@ -1172,10 +1172,10 @@ void Server::callback(string const & msg)
                        // connect to the lyxfunc in the single GuiView we
                        // support currently. (Lgb)
 
-                       FuncRequest const fr(lyxaction.lookupFunc(cmd), arg);
+                       FuncRequest fr(lyxaction.lookupFunc(cmd), arg);
+                       fr.setOrigin(FuncRequest::LYXSERVER);
                        DispatchResult dr;
                        theApp()->dispatch(fr, dr);
-                       theApp()->dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
                        string const rval = to_utf8(dr.message());
 
                        // all commands produce an INFO or ERROR message
index 7940b7fc3886d2e3c5017c8c9894da437f237e32..7b9d6df5af71c81d885c36c29045127a2964ae47 100644 (file)
@@ -141,9 +141,10 @@ void ServerSocket::dataCallback(int fd)
                string const key = line.substr(0, pos);
                if (key == "LYXCMD") {
                        string const cmd = line.substr(pos + 1);
+                       FuncRequest fr(lyxaction.lookupFunc(cmd));
+                       fr.setOrigin(FuncRequest::LYXSERVER);
                        DispatchResult dr;
-                       theApp()->dispatch(lyxaction.lookupFunc(cmd), dr);
-                       theApp()->dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
+                       theApp()->dispatch(fr, dr);
                        string const rval = to_utf8(dr.message());
                        if (dr.error())
                                client->writeln("ERROR:" + cmd + ':' + rval);
index a2c60c9d29f8ee972c8da8604296eca0a3a6d247..fe6bf955267f5886a44f0e4aa44bf98102937159 100644 (file)
@@ -1097,7 +1097,12 @@ void GuiApplication::dispatch(FuncRequest const & cmd)
        // This is done unless explicitly requested otherwise
        dr.screenUpdate(Update::FitCursor);
        dispatch(cmd, dr);
+       updateCurrentView(cmd, dr);
+}
+
 
+void GuiApplication::updateCurrentView(FuncRequest const & cmd, DispatchResult & dr)
+{
        if (!current_view_)
                return;
 
@@ -1268,6 +1273,13 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                return;
        };
 
+       if (cmd.origin() == FuncRequest::LYXSERVER) {
+               if (current_view_ && current_view_->currentBufferView())
+                       current_view_->currentBufferView()->cursor().saveBeforeDispatchPosXY();
+               // we will also need to redraw the screen at the end
+               dr.screenUpdate(Update::FitCursor);
+       }
+
        // Assumes that the action will be dispatched.
        dr.dispatched(true);
 
@@ -1620,6 +1632,9 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        current_view_->dispatch(cmd, dr);
                break;
        }
+
+       if (cmd.origin() == FuncRequest::LYXSERVER)
+               updateCurrentView(cmd, dr);
 }
 
 
index d1a10784b8bf4c476e04590919a30ade0468aaa5..380507f7bfa3f11d725ea4816322ea0caf7d469e 100644 (file)
@@ -185,6 +185,8 @@ private:
        ///
        void validateCurrentView();
        ///
+       void updateCurrentView(FuncRequest const & cmd, DispatchResult & dr);
+       ///
        bool closeAllViews();
        /// read the given ui (menu/toolbar) file
        bool readUIFile(QString const & name, bool include = false);
index b7bd859347a598198b2018e7a6a4306f5fcabf19..dd98a18523c940f093551e8735fe416ae177b515 100644 (file)
@@ -89,9 +89,6 @@ What's new
   flag by using the same latex backend used for previewing the document
   instead of always using the plain latex backend.
 
-- Fix crash when dissolving a math macro whose first argument is another
-  parameterless macro (bug 8105).
-
 
 * USER INTERFACE
 
@@ -134,6 +131,13 @@ What's new
 
 - Made it possible to delete local layout in Document>Settings.
 
+- Fix crash when dissolving a math macro whose first argument is another
+  parameterless macro (bug 8105).
+
+- Update the current view after dispatching a command through the lyxserver.
+  The missing screen update could cause either a failure in executing the
+  command or could even crash LyX (bugs 6871 and 8119).
+
 
 * DOCUMENTATION AND LOCALIZATION