Commit Graph

64 Commits

Author SHA1 Message Date
Yuriy Skalko
8cb728c2d7 Constify 2020-11-27 12:16:45 +02:00
Yuriy Skalko
11434df35d Fix warnings regarding switches on enum values 2020-11-25 23:16:56 +02:00
Enrico Forestieri
a73c2c2b93 Raise the window in single-instance mode
Other than issuing a warning on the console, now the LyX window is
raised when in single-instance mode and no files to load are specified.
In this way, the user is aware that something happened after double
clicking the program icon. To support this functionality the new lfun
window-raise has been introduced.
2020-04-21 21:55:20 +02:00
Richard Kimberly Heck
d550774772 Tell the user that LyX is already running when we do not start
because of 'use single instance'.
2020-04-18 14:41:26 -04:00
Richard Kimberly Heck
86a4c79dc4 Make it nicer, thanks to JMarc 2020-04-16 21:05:38 -04:00
Richard Kimberly Heck
46f1f6f1cb Fix bug #11635 2020-04-16 17:16:26 -04:00
Enrico Forestieri
cf5f2661dc Fix LyX server on Windows
On some recent Windows versions, GetLastError() may also return
NO_ERROR instead of ERROR_IO_PENDING during an overlapped write
operation to a pipe. This was confusing the state machine in
Server.cpp so that replies to commands were scheduled but were
never actually output.
2018-08-07 17:56:07 +02:00
Jean-Marc Lasgouttes
8e015f3cb2 Do not force lfun argument to be pure ascii
Fixes bug #11167.
2018-07-02 10:49:58 +02:00
Jean-Marc Lasgouttes
32f37250d5 Catch exception in replaceEnvironmentPath
This exception in the regex constructor is only theoretical (our regex
are hardcoded), but this is creating coverity noise.

Additionally, revert the following commits that are not needed anymore:
6b6fa94c: Catch exceptions to please coverity
c2ed75fd: Fixup 6b6fa94c: coverity says there are more possible exceptions.

This commit is better viewed with 'git show -b'.
2018-06-04 11:39:41 +02:00
Enrico Forestieri
7e9c4d4091 Fix bug #10927 2018-02-24 12:48:02 +01:00
Jean-Marc Lasgouttes
6b6fa94c91 Catch exceptions to please coverity
Actually, the possible exception path is from replaceEnvironmentPath.
It would be better if coverity was able to asses that our hardcoded
regexp:s are correct.
2018-01-29 13:50:09 +01:00
Juergen Spitzmueller
b498646b2e Fix some spelling errors reported by Sven
Fixes: #10678
2017-09-22 09:29:16 +02:00
Christian Ridderström
e30f3d76d2 Bulk cleanup/fix incorrect annotation at the end of namespaces.
This commit does a bulk fix of incorrect annotations (comments) at the
end of namespaces.

The commit was generated by initially running clang-format, and then
from the diff of the result extracting the hunks corresponding to
fixes of namespace comments. The changes being applied and all the
results have been manually reviewed. The source code successfully
builds on macOS.

Further details on the steps below, in case they're of interest to
someone else in the future.

1. Checkout a fresh and up to date version of src/

    git pull && git checkout -- src && git status src

2. Ensure there's a suitable .clang-format in place, i.e. with options
   to fix the comment at the end of namespaces, including:

    FixNamespaceComments:                           true
    SpacesBeforeTrailingComments:                   1

and that clang-format is >= 5.0.0, by doing e.g.:

    clang-format -dump-config | grep Comments:
    clang-format --version

3. Apply clang-format to the source:

    clang-format -i $(find src -name "*.cpp" -or -name "*.h")

4. Create and filter out hunks related to fixing the namespace

    git diff -U0 src > tmp.patch
    grepdiff '^} // namespace' --output-matching=hunk tmp.patch  > fix_namespace.patch

5. Filter out hunks corresponding to simple fixes into to a separate patch:

    pcregrep -M -e '^diff[^\n]+\nindex[^\n]+\n--- [^\n]+\n\+\+\+ [^\n]+\n'  \
        -e '^@@ -[0-9]+ \+[0-9]+ @@[^\n]*\n-\}[^\n]*\n\+\}[^\n]*\n'         \
        fix_namespace.patch > fix_namespace_simple.patch

6. Manually review the simple patch and then apply it, after first
   restoring the source.

    git checkout -- src
    patch -p1 < fix_namespace_simple.path

7. Manually review the (simple) changes and then stage the changes

    git diff src
    git add src

8. Again apply clang-format and filter out hunks related to any
   remaining fixes to the namespace, this time filter with more
   context. There will be fewer hunks as all the simple cases have
   already been handled:

    clang-format -i $(find src -name "*.cpp" -or -name "*.h")
    git diff src > tmp.patch
    grepdiff '^} // namespace' --output-matching=hunk tmp.patch  > fix_namespace2.patch

9. Manually review/edit the resulting patch file to remove hunks for files
   which need to be dealt with manually, noting the file names and
   line numbers. Then restore files to as before applying clang-format
   and apply the patch:

    git checkout src
    patch -p1 < fix_namespace2.patch

10. Manually fix the files noted in the previous step. Stage files,
    review changes and commit.
2017-07-23 13:11:54 +02:00
Jean-Marc Lasgouttes
02c9d2e67c Fix uninitialized members outfd and infd
Also move initialization of some variables to initializers list.

Only the non-win32 part has been tested, but it should be OK.

Spotted by coverity.
2017-07-06 14:52:19 +02:00
Guillaume MM
db58111360 Properly track the lifetime of signals2::slots (#8261)
Starting at 61b2bd5e, boost::bind was progressively replaced with
std::bind. They are not interchangeable though. boost::bind implements
the tracking of boost::signals{,2}::trackable objects. Now that
std::bind has completely replaced boost::bind, tracking never occurred.

This commit replaces boost::signals2::trackable with the new preferred
boost::signals2 methods: scoped_connections or slot::track_foreign. The
support::Trackable class introduced is less safe but easier for transitioning
old code.

Fixes the crash at #8261.
2017-06-11 19:51:17 +02:00
Richard Heck
fd4645c912 Whitespace only. 2016-06-27 18:54:14 -04:00
Richard Heck
4b64aaf4ce This patch does two closely related things.
The main thing it does is integrate mouse-modifiers into the
FuncRequest machinery. Previously, these had to be passed
separately, which led to some ugly function signatures.

There was also an unnecessary form of the constructor, which
can now be removed.

No change of behavior is intended.
2016-06-27 18:16:35 -04:00
Stephan Witt
a80e0cacb9 Use iostream instead of sstream and move it from header to cpp-source of LyX-Server 2016-06-12 13:03:06 +02:00
Georg Baum
d5d2aa9de9 Fix compiler warnings
Only the ones I understand (DWORD is always unsigned). There are more:

../../src/Server.cpp: In member function ‘bool lyx::LyXComm::pipeServer()’:
../../src/Server.cpp:280:10: warning: enumeration value ‘CONNECTING_STATE’ not handled in switch [-Wswitch]
   switch (pipe_[i].state) {
             ^
     ../../src/Server.cpp:347:8: warning: ‘success’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             && status == pipe_[i].iobuf.length()) {
             ^
2016-05-29 17:55:44 -04:00
Jean-Marc Lasgouttes
c559f85ccb Fix wrong test: boolean variable is never negative
This has been spotted by clang++.
2014-11-01 16:06:08 +01:00
Lars Gullik Bjønnes
6b2232a29c src/*.cpp: reformatting to increase consistency 2012-10-28 17:42:07 +01:00
Enrico Forestieri
ea31541848 Fix bugs #6871 and #8119.
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
right this, but does not return the result, while
GuiApplication::dispatch(FuncRequest const &, DispatchResult &)
is called by the former but does not return the result. 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.
2012-04-13 02:57:25 +02:00
Abdelrazak Younes
33f7c028a2 gcc 4.5 warning fix.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38687 a592a061-630c-0410-9148-cb99ea01b6c8
2011-05-10 15:03:49 +00:00
Enrico Forestieri
299745b635 Force a paragraph update after lyxserver communication (part of bug #6871)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37851 a592a061-630c-0410-9148-cb99ea01b6c8
2011-03-04 21:57:42 +00:00
Vincent van Ravesteijn
ff8ac45920 Compile fix for windows for r36278.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36297 a592a061-630c-0410-9148-cb99ea01b6c8
2010-11-14 16:27:08 +00:00
Enrico Forestieri
22ffc93467 The "single instance" patch.
By default, if the lyxpipe is set up and working, loading of documents
is deferred to an already running instance. Note that an already running
instance is only used for loading, such that export from command line
still works as usual.

The default behavior can be changed through a preference setting, and,
whatever the default is, it can be overridden by command line options.
Unticking the "Single instance" check box in the preferences, LyX behaves
exactly as before the introduction of this feature.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36278 a592a061-630c-0410-9148-cb99ea01b6c8
2010-11-13 11:55:05 +00:00
Peter Kümmel
61b2bd5e7f Using "using namespace std" with msvc10 makes also std::tr1::bind visible and generates conflicts with boost::bind.
Solution: don't use boost::bind for msvc10 (could also be extended  to several GCC versions)

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34257 a592a061-630c-0410-9148-cb99ea01b6c8
2010-04-22 11:16:58 +00:00
Enrico Forestieri
06122df30a Revert r33756 because lyx hangs on startup on some platforms.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33761 a592a061-630c-0410-9148-cb99ea01b6c8
2010-03-16 07:55:22 +00:00
Enrico Forestieri
61096546b3 The output pipe is only used for writing, and not also for reading.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33756 a592a061-630c-0410-9148-cb99ea01b6c8
2010-03-15 22:16:30 +00:00
Enrico Forestieri
e26331dd35 Remove obsolete source file.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33500 a592a061-630c-0410-9148-cb99ea01b6c8
2010-02-18 09:58:20 +00:00
Abdelrazak Younes
d77a22e2f9 Today is a sad day, LyXView has passed over... long live GuiView!
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33393 a592a061-630c-0410-9148-cb99ea01b6c8
2010-02-09 17:06:40 +00:00
Abdelrazak Younes
377cdd5f6c Transfer LyXfunc code to GuiApplication::dispatch() and getStatus(). Now
a lot of simplification is possible. Except some instability period...


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33389 a592a061-630c-0410-9148-cb99ea01b6c8
2010-02-09 16:11:13 +00:00
Jean-Marc Lasgouttes
a1e991a82e Get rid of the errorstat and dispatch_buffer members of LyXFunc.
This required to make Cursor::disp_ mutable.

Also, the server parts now pass a DispatchResult object to dispatch (which is
a good thing anyway).



git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33259 a592a061-630c-0410-9148-cb99ea01b6c8
2010-01-29 11:22:33 +00:00
Enrico Forestieri
68809af49b Properly reinitialise the OVERLAPPED structure (thanks Vincent!)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31371 a592a061-630c-0410-9148-cb99ea01b6c8
2009-09-11 18:19:59 +00:00
Enrico Forestieri
2c679d1481 The call to checkStopServer was only needed when we were asking Qt
to be notified on quit. Now it is superfluous.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31312 a592a061-630c-0410-9148-cb99ea01b6c8
2009-09-06 14:26:59 +00:00
Enrico Forestieri
50423d0e7c Interrupt the wait if the stopserver event is triggered.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31311 a592a061-630c-0410-9148-cb99ea01b6c8
2009-09-06 13:49:34 +00:00
Enrico Forestieri
9919ec3625 On Windows, shutdown the pipe server when an unrecoverable error occurs.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31296 a592a061-630c-0410-9148-cb99ea01b6c8
2009-09-05 16:39:33 +00:00
Abdelrazak Younes
3eb99bf4cb signed/unsigned warning fix.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31294 a592a061-630c-0410-9148-cb99ea01b6c8
2009-09-05 15:40:31 +00:00
Enrico Forestieri
71b8b37ac3 On Windows, use the same number of output pipe instances as that of
the input ones. In this way, two (or more) concurrent readers can each
get a reply, which otherwise would be stealed by only one of them.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31254 a592a061-630c-0410-9148-cb99ea01b6c8
2009-08-31 23:32:46 +00:00
Enrico Forestieri
c29028f94c During an emergency cleanup, better to not indefinitely wait for
the pipe server to finish.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31241 a592a061-630c-0410-9148-cb99ea01b6c8
2009-08-30 16:06:51 +00:00
Enrico Forestieri
2d09fff374 Quit notification from Qt is not needed anymore.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31240 a592a061-630c-0410-9148-cb99ea01b6c8
2009-08-30 15:31:22 +00:00
Enrico Forestieri
40620bd83f On Windows, use true asynchronous I/O for the pipe server.
Now, even the nasty JabRef works.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31239 a592a061-630c-0410-9148-cb99ea01b6c8
2009-08-29 23:42:06 +00:00
Enrico Forestieri
3ab2267014 Don't start the pipe server if the pipe is already in use.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31213 a592a061-630c-0410-9148-cb99ea01b6c8
2009-08-23 14:40:26 +00:00
Enrico Forestieri
736d7f82a1 Properly stop the pipe server when LyX is quitting
but the answer to a client is still pending.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31212 a592a061-630c-0410-9148-cb99ea01b6c8
2009-08-23 13:27:08 +00:00
Enrico Forestieri
cd475bad39 Perform the clean up at the right place. Also put the event in the
nonsignaled state, otherwise after a shutdown the server would be
continually stopped...


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31194 a592a061-630c-0410-9148-cb99ea01b6c8
2009-08-22 12:22:46 +00:00
Enrico Forestieri
96a8d85c7c Correct clean up on pipe server shutdown.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31192 a592a061-630c-0410-9148-cb99ea01b6c8
2009-08-22 11:23:11 +00:00
Enrico Forestieri
fc97861803 Implement the LyXServer on Windows.
Only for autotools, I don't know how to update cmake and scons, sorry.
For cmake and scons, you should make sure that moc is called on Server.h
using the -D_WIN32 option.

In order to enable the server, specify the LyXServer pipe in
Tools->Preferences->Paths. The path to be entered there must have the
form "\\.\pipe\nameofyourchoice" (without quotes). After that, you can
send commands to LyX. For example, if the pipe path is \\.\pipe\lyxpipe,
typing the following in a terminal:

echo LYXCMD:test:file-open > \\.\pipe\lyxpipe.in
type \\.\pipe\lyxpipe.out

brings up the file dialog and returns the acknowledgment from LyX.
Beware of spaces when using cmd.exe. For example, the following:
echo LYXCMD:test:file-open:foo.lyx> \\.\pipe\lyxpipe.in
will correctly load the document named foo.lyx, but
echo LYXCMD:test:file-open:foo.lyx > \\.\pipe\lyxpipe.in
(notice the space before the redirection) will try to load a
document whose name is "foo.lyx .lyx" because cmd.exe will also
pass the space (sigh).


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@31189 a592a061-630c-0410-9148-cb99ea01b6c8
2009-08-21 22:58:38 +00:00
Enrico Forestieri
4e12c4327a Avoid useless assignment to errno and add scope operator for safety.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27713 a592a061-630c-0410-9148-cb99ea01b6c8
2008-11-26 19:05:35 +00:00
Enrico Forestieri
077baded5c Fix bug 641 (Detect stale lyxpipes after crash)
http://bugzilla.lyx.org/show_bug.cgi?id=641


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27708 a592a061-630c-0410-9148-cb99ea01b6c8
2008-11-26 01:22:05 +00:00
André Pönitz
f1cba8ff64 more latin1..utf8 schanges. all of src/* should be utf8 now
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27425 a592a061-630c-0410-9148-cb99ea01b6c8
2008-11-14 15:58:50 +00:00