Commit Graph

15 Commits

Author SHA1 Message Date
Martchus 9f2e2819c6 Use generic `toInt()` function which relies less on compiler optimizations 2023-05-18 00:53:37 +02:00
Martchus d3a559446f Apply clang-format 2023-05-11 17:57:22 +02:00
Martchus e703ddd524 Allow overriding single instance ID via env variable 2023-05-03 21:18:03 +02:00
Martchus 884ead9760 Improve startup code further to fix problems showing expecially on Windows
* Avoid overriding argv/argc via `CMD_UTILS_CONVERT_ARGS_TO_UTF8` in
  Windows-specific code when processing arguments from a 2nd instance
* Move the other startup code to main as well as they are not needed when
  processing arguments from a 2nd instance
* Improve debug logging
* Use `waitForBytesWritten()` instead of `flush()` when passing args as
  recommended by the documentation
* Avoid use of `bytesAvailable()` as it doesn't work as expected in this
  situation on Windows (likely it doesn't really work reliably on all
  platforms); calling `readAll()` works and is simpler anyways
* Tested that `--replace` works as well; also the
  `waitUntilGone && QFile::exists(fullServerName)` block is entered and if
  the previous instance is taking some time it really waits until it is
  gone
2023-05-01 21:10:09 +02:00
Martchus c9cd81311d Improve startup/shutdown behavior; add `--replace` CLI option
* Make functions in `main.cpp` static as they are not used by
  other units
* Delete the `TrayIcon` via an extra parent object that is
  deleted before the `QNetworkAccessManager` is deleted; otherwise
  the destruction of `SyncthingConnection` (which aborts pending
  replies) might access dangling `QNetworkReply` objects
* Improve error handling in `SingleInstance` code
* Allow to replace the current instance via the new `--replace`
  argument; this may be useful when creating an installer/updater
2023-04-29 21:07:30 +02:00
Martchus dea8e5ae68 Fix single instance behavior if multiple users use syncthingtray in parallel
Create a distinct server for each user so they don't interfere with each
other. Otherwise the instance of the second user tries to connect to the
instance started by the first user which fails and therefore breaks the
single instance behavior for the second user.
2022-06-17 21:46:06 +02:00
Martchus a4f6b62a62 Move code for passing args to already running instance into own function 2020-10-19 19:04:18 +02:00
Martchus 6122b54210 Add an opt-out for the single-process behavior
This would have been useful for testing multiple times and now even came up
in a forum discussion.
2020-10-19 19:03:42 +02:00
Martchus 64473df5ba Adapt to changes in c++utilities 2019-06-10 22:48:26 +02:00
Martchus d88df866d2 Adapt to c++utilities v5 2019-05-04 21:05:21 +02:00
Martchus b81c316d4a Improve message formatting in SingleInstance 2018-04-02 20:23:54 +02:00
Martchus 69ffaeb1f3 Apply tidy after updating to clang-format 5.0.0
The behavior of clang-format slightly changed in Clang 5.0.0:
http://releases.llvm.org/5.0.0/tools/clang/docs/ReleaseNotes.html#clang-format
2017-09-17 21:48:15 +02:00
Martchus 732a5fdd8d Apply clang-format 2017-05-01 03:34:43 +02:00
Martchus 873660f0a9 Use C++14 std::make_unique 2017-02-11 02:42:45 +01:00
Martchus 6470038fc7 Refactor to allow sharing backend with other apps
Intended for creating command line tool and plasmoid
2016-09-30 23:58:45 +02:00