SingleInstance.h header
#include <ew/app/SingleInstance.h>
Namespace ew::app
LaunchArguments struct
struct ew::app::LaunchArguments
The forwarding-relevant parts of a command line, extracted from arguments (which includes the program name at index 0, as QCoreApplication::arguments() does).
Members
QString ew::app::workspace::LaunchArguments::projectPath
The positional project path (a double-clicked .ewriter file or a folder path), or empty.
bool ew::app::workspace::LaunchArguments::newInstance = false
True when --new-instance was passed: skip forwarding and always open a standalone window (so several projects can be worked side by side).
LaunchMessage struct
struct ew::app::LaunchMessage
A launch request forwarded from a second process to the already-running instance: a project to open, or – when the path is empty – just a nudge to raise the existing window (a bare second launch). One request is one UTF-8 line on the wire.
Members
QString ew::app::workspace::LaunchMessage::projectPath
The absolute project path to open; empty means "just raise the running window".
bool operator==(const LaunchMessage &, const LaunchMessage &)=default
Two messages are equal when they carry the same path.
Functions
LaunchMessage ew::app::workspace::decodeLaunchMessage(const QByteArray &bytes)
Decodes wire bytes back to a launch message, reading only the first line and tolerating a trailing CR/LF – so a partial or line-buffered read that ends the line decodes correctly.
QByteArray ew::app::workspace::encodeLaunchMessage(const LaunchMessage &message)
Encodes message to its wire bytes: the project path as one newline-terminated UTF-8 line (a path never contains a newline, so the line is unambiguous).
LaunchArguments ew::app::workspace::parseLaunchArguments(const QStringList &arguments)
Parses arguments for the project path and the --new-instance flag. --capture and --lang each consume the following argument as their value; any other --flag is ignored as a valueless option; the first remaining positional argument is the project path.
QString ew::app::workspace::singleInstanceServerName(const QString &userName)
The name of the per-user single-instance IPC channel (a QLocalServer pipe name). The desktop app's first process listens on this name; a second launch connects to it to forward its request instead of opening another window.
Two accounts on one machine never collide. That matters because a pipe name is machine-global on Windows, so a shared channel would forward one user's "open this project" into another user's window. The readable part of the name is the user name reduced to the characters a local-socket name safely allows – a lossy fold, which alone would make "J Smith" and "J_Smith" the same channel – so the name also carries a hash of the ORIGINAL userName, which distinguishes any two distinct names. The readable part is truncated, keeping the whole name within the OS limit for a long account name.