diff --git a/src/ipc.cpp b/src/ipc.cpp index 29c4178bc..bd58e474c 100644 --- a/src/ipc.cpp +++ b/src/ipc.cpp @@ -81,6 +81,15 @@ IPC::~IPC() } } +IPC& IPC::getInstance() +{ +#ifdef Q_OS_ANDROID + Q_ASSERT(0 && "IPC can not be used on android"); +#endif + static IPC instance; + return instance; +} + time_t IPC::postEvent(const QString &name, const QByteArray& data/*=QByteArray()*/, uint32_t dest/*=0*/) { QByteArray binName = name.toUtf8(); diff --git a/src/ipc.h b/src/ipc.h index 13de0918b..28b1c7be6 100644 --- a/src/ipc.h +++ b/src/ipc.h @@ -34,6 +34,7 @@ using IPCEventHandler = std::function; class IPC : public QThread { Q_OBJECT + IPC(); protected: static const int EVENT_TIMER_MS = 1000; static const int EVENT_GC_TIMEOUT = 5; @@ -41,9 +42,10 @@ protected: static const int OWNERSHIP_TIMEOUT_S = 5; public: - IPC(); ~IPC(); + static IPC& getInstance(); + struct IPCEvent { uint32_t dest; diff --git a/src/main.cpp b/src/main.cpp index 6cca408a2..b0d42ebc4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -70,6 +70,9 @@ int main(int argc, char *argv[]) parser.addOption(QCommandLineOption("p", QObject::tr("Starts new instance and loads specified profile."), QObject::tr("profile"))); parser.process(a); +#ifndef Q_OS_ANDROID + IPC::getInstance(); +#endif Settings::getInstance(); // Build our Settings singleton as soon as QApplication is ready, not before if (parser.isSet("p")) @@ -126,7 +129,7 @@ int main(int argc, char *argv[]) #ifndef Q_OS_ANDROID // Inter-process communication - IPC ipc; + IPC& ipc = IPC::getInstance(); ipc.registerEventHandler("uri", &toxURIEventHandler); ipc.registerEventHandler("save", &toxSaveEventHandler); ipc.registerEventHandler("activate", &toxActivateEventHandler); diff --git a/src/misc/settings.cpp b/src/misc/settings.cpp index 86df23913..797aa769e 100644 --- a/src/misc/settings.cpp +++ b/src/misc/settings.cpp @@ -23,6 +23,7 @@ #ifdef QTOX_PLATFORM_EXT #include "src/platform/autorun.h" #endif +#include "src/ipc.h" #include #include @@ -333,7 +334,18 @@ void Settings::save(bool writePersonal) void Settings::save(QString path, bool writePersonal) { - qDebug() << "Settings: Saving in "<