mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-06-12 05:07:46 +02:00
Shorten LocalPeer socket names
On most systems supporting Unix sockets, the maximum length of a socket name is quite low (e.g. on macOS 104 characters and on Linux 108). If the name is too long, the sockets will not work and thus sending messages to a running instance of the launcher will not work. Signed-off-by: Kenneth Chew <79120643+kthchew@users.noreply.github.com>
This commit is contained in:
@ -375,19 +375,20 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||
m_peerInstance = new LocalPeer(this, appID);
|
||||
connect(m_peerInstance, &LocalPeer::messageReceived, this, &Application::messageReceived);
|
||||
if (m_peerInstance->isClient()) {
|
||||
bool sentMessage = false;
|
||||
int timeout = 2000;
|
||||
|
||||
if (m_instanceIdToLaunch.isEmpty()) {
|
||||
ApplicationMessage activate;
|
||||
activate.command = "activate";
|
||||
m_peerInstance->sendMessage(activate.serialize(), timeout);
|
||||
sentMessage = m_peerInstance->sendMessage(activate.serialize(), timeout);
|
||||
|
||||
if (!m_urlsToImport.isEmpty()) {
|
||||
for (auto url : m_urlsToImport) {
|
||||
ApplicationMessage import;
|
||||
import.command = "import";
|
||||
import.args.insert("url", url.toString());
|
||||
m_peerInstance->sendMessage(import.serialize(), timeout);
|
||||
sentMessage = m_peerInstance->sendMessage(import.serialize(), timeout);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -407,10 +408,16 @@ Application::Application(int& argc, char** argv) : QApplication(argc, argv)
|
||||
launch.args["offline_enabled"] = "true";
|
||||
launch.args["offline_name"] = m_offlineName;
|
||||
}
|
||||
m_peerInstance->sendMessage(launch.serialize(), timeout);
|
||||
sentMessage = m_peerInstance->sendMessage(launch.serialize(), timeout);
|
||||
}
|
||||
if (sentMessage) {
|
||||
m_status = Application::Succeeded;
|
||||
return;
|
||||
} else {
|
||||
std::cerr << "Unable to redirect command to already running instance\n";
|
||||
// C function not Qt function - event loop not started yet
|
||||
::exit(1);
|
||||
}
|
||||
m_status = Application::Succeeded;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user