]> git.lyx.org Git - lyx.git/blobdiff - src/Server.cpp
Add a member to TocItem that tells us whether the item in question
[lyx.git] / src / Server.cpp
index 76ee88060bd980af2e92234ab1ebffbddb9c5f15..1de758a5f46bd1b9507c9e2ad9b213d9a015c550 100644 (file)
@@ -59,6 +59,7 @@
 #include "support/bind.h"
 
 #ifdef _WIN32
+#include <io.h>
 #include <QCoreApplication>
 #endif
 #include <QThread>
@@ -694,6 +695,7 @@ string const LyXComm::pipeName(DWORD index) const
 LyXComm::LyXComm(string const &, Server *, ClientCallbackfct)
 {}
 
+
 void LyXComm::openConnection()
 {}
 
@@ -715,6 +717,7 @@ void LyXComm::endPipe(int & fd, string const & filename, bool write)
 void LyXComm::emergencyCleanup()
 {}
 
+
 void LyXComm::read_ready()
 {}
 
@@ -725,7 +728,6 @@ void LyXComm::send(string const & msg)
 
 #else // defined (HAVE_MKFIFO)
 
-
 LyXComm::LyXComm(string const & pip, Server * cli, ClientCallbackfct ccb)
        : pipename_(pip), client_(cli), clientcb_(ccb)
 {
@@ -914,7 +916,6 @@ void LyXComm::read_ready()
        int status;
        // the single = is intended here.
        while ((status = ::read(infd_, charbuf, charbuf_size - 1))) {
-
                if (status > 0) {
                        charbuf[status] = '\0'; // turn it into a c string
                        read_buffer_ += rtrim(charbuf, "\r");
@@ -965,7 +966,8 @@ void LyXComm::send(string const & msg)
 
        LYXERR(Debug::LYXSERVER, "LyXComm: Sending '" << msg << '\'');
 
-       if (pipename_.empty()) return;
+       if (pipename_.empty())
+               return;
 
        if (!ready_) {
                LYXERR0("LyXComm: Pipes are closed. Could not send " << msg);
@@ -1014,7 +1016,8 @@ bool LyXComm::loadFilesInOtherInstance()
                        break;
                string const cmd = "LYXCMD:pipe:file-open:" +
                                        fname.absFileName() + '\n';
-               ::write(pipefd, cmd.c_str(), cmd.length());
+               if (::write(pipefd, cmd.c_str(), cmd.length()) < 0)
+                       LYXERR0("Cannot write to pipe!");
                ::close(pipefd);
                ++loaded_files;
                it = theFilesToLoad().erase(it);
@@ -1066,7 +1069,6 @@ Server::~Server()
 
 int compare(char const * a, char const * b, unsigned int len)
 {
-       using namespace std;
        return strncmp(a, b, len);
 }
 
@@ -1171,7 +1173,8 @@ 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);
                        string const rval = to_utf8(dr.message());