aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKarol Kosek <krkk@krkk.ct8.pl>2021-04-15 22:22:40 +0200
committerFelix Queißner <felix@ib-queissner.de>2021-04-17 08:36:10 +0200
commit2f74b60d0653c1fcc2d0e741052aa1173f6b6d7c (patch)
treec60a178420f7f51b7372242a5020fd7f491d18b9 /src
parent9ecc88dda38388871d3d316e93df7b5b629b3e47 (diff)
main.cpp: support sessions when multiple users have opened Kristall
Before this change, only the first user who had opened kristall had working ipc. The easiest fix was to prepend an username to the socket and that's exactly what it does on Windows. On Linux and other UNIX systems, we could do that too, but I came up with a bit different approach. I didn't like the fact that Qt puts sockets in /tmp, but luckily we can provide the full path for the socket (Windows uses pipes, so that's why it has its own case). I've changed it to put sockets in the runtime directory, because it's designed for that type of files and it's user-specific, so we don't even have to prepend the username to it.
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index c9a622c..358b91f 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -148,7 +148,13 @@ MainWindow * getFocusedAppWindow()
// the same machine.
namespace ipc
{
- static char const * socket_name = "net.random-projects.kristall";
+ static const QString socket_name =
+#ifdef Q_OS_UNIX
+ QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation) + "/"
+#elif defined Q_OS_WIN32
+ qEnvironmentVariable("USERNAME") + "-"
+#endif
+ "net.random-projects.kristall";
struct Message
{