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

Cleanup before returning from main

This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2015-02-06 19:38:08 +01:00
parent 331baa7447
commit 2e7c73dcb0
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
5 changed files with 21 additions and 3 deletions

View File

@ -123,7 +123,7 @@ int main(int argc, char *argv[])
AutoUpdater::installLocalUpdate(); ///< NORETURN AutoUpdater::installLocalUpdate(); ///< NORETURN
#endif #endif
Nexus::getInstance().start(); Nexus::getInstance().start();
#ifndef Q_OS_ANDROID #ifndef Q_OS_ANDROID
// Inter-process communication // Inter-process communication
@ -191,5 +191,7 @@ Nexus::getInstance().start();
logFile = nullptr; logFile = nullptr;
#endif #endif
Nexus::destroyInstance();
return errorcode; return errorcode;
} }

View File

@ -12,6 +12,8 @@
#include <src/widget/widget.h> #include <src/widget/widget.h>
#endif #endif
static Nexus* nexus{nullptr};
Nexus::Nexus(QObject *parent) : Nexus::Nexus(QObject *parent) :
QObject(parent), QObject(parent),
core{nullptr}, core{nullptr},
@ -113,8 +115,15 @@ void Nexus::start()
Nexus& Nexus::getInstance() Nexus& Nexus::getInstance()
{ {
static Nexus nexus; if (!nexus)
return nexus; nexus = new Nexus;
return *nexus;
}
void Nexus::destroyInstance()
{
delete nexus;
nexus = nullptr;
} }
Core* Nexus::getCore() Core* Nexus::getCore()

View File

@ -18,6 +18,7 @@ public:
void start(); ///< Will initialise the systems (GUI, Core, ...) void start(); ///< Will initialise the systems (GUI, Core, ...)
static Nexus& getInstance(); static Nexus& getInstance();
static void destroyInstance();
static Core* getCore(); ///< Will return 0 if not started static Core* getCore(); ///< Will return 0 if not started
static AndroidGUI* getAndroidGUI(); ///< Will return 0 if not started static AndroidGUI* getAndroidGUI(); ///< Will return 0 if not started
static Widget* getDesktopGUI(); ///< Will return 0 if not started static Widget* getDesktopGUI(); ///< Will return 0 if not started

View File

@ -42,6 +42,11 @@ SystemTrayIcon::SystemTrayIcon()
} }
} }
SystemTrayIcon::~SystemTrayIcon()
{
qDebug() << "Deleting SystemTrayIcon";
}
QString SystemTrayIcon::extractIconToFile(QIcon icon, QString name) QString SystemTrayIcon::extractIconToFile(QIcon icon, QString name)
{ {
QString iconPath; QString iconPath;

View File

@ -12,6 +12,7 @@ class SystemTrayIcon : public QObject
Q_OBJECT Q_OBJECT
public: public:
SystemTrayIcon(); SystemTrayIcon();
~SystemTrayIcon();
void setContextMenu(QMenu* menu); void setContextMenu(QMenu* menu);
void show(); void show();
void hide(); void hide();