1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix(ipc): handle ipc failure gracefully

Allows running qTox inside jails that block IPC.

Fix #5740
This commit is contained in:
Anthony Bilinski 2019-08-28 21:47:26 -07:00
parent 64aa3eae4d
commit 9dd083978e
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C

View File

@ -219,13 +219,12 @@ int main(int argc, char* argv[])
uint32_t profileId = settings.getCurrentProfileId();
IPC ipc(profileId);
if (!ipc.isAttached()) {
qCritical() << "Can't init IPC";
return EXIT_FAILURE;
if (ipc.isAttached()) {
QObject::connect(&settings, &Settings::currentProfileIdChanged, &ipc, &IPC::setProfileId);
} else {
qWarning() << "Can't init IPC, maybe we're in a jail? Continuing with reduced multi-client functionality.";
}
QObject::connect(&settings, &Settings::currentProfileIdChanged, &ipc, &IPC::setProfileId);
// For the auto-updater
if (sodium_init() < 0) {
qCritical() << "Can't init libsodium";
@ -278,7 +277,7 @@ int main(int argc, char* argv[])
bool autoLogin = settings.getAutoLogin();
uint32_t ipcDest = 0;
bool doIpc = true;
bool doIpc = ipc.isAttached();
QString eventType, firstParam;
if (parser.isSet("p")) {
profileName = parser.value("p");
@ -359,10 +358,12 @@ int main(int argc, char* argv[])
}
}
// Start to accept Inter-process communication
ipc.registerEventHandler("uri", &toxURIEventHandler);
ipc.registerEventHandler("save", &toxSaveEventHandler);
ipc.registerEventHandler("activate", &toxActivateEventHandler);
if (ipc.isAttached()) {
// Start to accept Inter-process communication
ipc.registerEventHandler("uri", &toxURIEventHandler);
ipc.registerEventHandler("save", &toxSaveEventHandler);
ipc.registerEventHandler("activate", &toxActivateEventHandler);
}
// Event was not handled by already running instance therefore we handle it ourselves
if (eventType == "uri")