Make use of the newly added Singleton mixon to remove the custom
handling of Quassel's instance pointer. Clearly define Quassel's
lifetime by making it a local instance in main(), rather than
relying on someone to call Quassel::instance() at the right time.
Now it is also clear that the instance is deleted after main()
returns (which was the case before, however there still was a no-op
Quassel::destroy() method too, which has now been removed). This
is fine, because Quassel does not own resources that should be deleted
before exiting the event loop.
#endif
// Instantiate early, so log messages are handled
#endif
// Instantiate early, so log messages are handled
#if QT_VERSION < 0x050000
// All our source files are in UTF-8, and Qt5 even requires that
#if QT_VERSION < 0x050000
// All our source files are in UTF-8, and Qt5 even requires that
#include "../../version.h"
#include "../../version.h"
-Quassel *Quassel::instance()
-{
- static Quassel instance;
- return &instance;
-}
-
-
- : _logger{new Logger{this}}
+ : Singleton<Quassel>{this}
+ , _logger{new Logger{this}}
-void Quassel::destroy()
-{
-}
-
-
Logger *Quassel::logger() const
{
return _logger;
Logger *Quassel::logger() const
{
return _logger;
#include <QStringList>
#include "abstractcliparser.h"
#include <QStringList>
#include "abstractcliparser.h"
class QFile;
class Logger;
class QFile;
class Logger;
-class Quassel : public QObject
+class Quassel : public QObject, public Singleton<Quassel>
{
// TODO Qt5: Use Q_GADGET
Q_OBJECT
{
// TODO Qt5: Use Q_GADGET
Q_OBJECT
- static Quassel *instance();
/**
* Provides access to the Logger instance.
/**
* Provides access to the Logger instance.
protected:
static bool init();
protected:
static bool init();
static void setRunMode(Quassel::RunMode runMode);
static void setRunMode(Quassel::RunMode runMode);
friend class MonolithicApplication;
private:
friend class MonolithicApplication;
private:
void setupEnvironment();
void registerMetaTypes();
void setupEnvironment();
void registerMetaTypes();
CoreApplication::~CoreApplication()
{
_core.reset();
CoreApplication::~CoreApplication()
{
_core.reset();
Client::destroy();
_coreThread.quit();
_coreThread.wait();
Client::destroy();
_coreThread.quit();
_coreThread.wait();
QtUiApplication::~QtUiApplication()
{
Client::destroy();
QtUiApplication::~QtUiApplication()
{
Client::destroy();