diff --git a/src/CutterApplication.h b/src/CutterApplication.h index f8dc01e3..cd27a26a 100644 --- a/src/CutterApplication.h +++ b/src/CutterApplication.h @@ -50,6 +50,7 @@ private: private: bool m_FileAlreadyDropped; + CutterCore core; MainWindow *mainWindow; CutterCommandLineOptions clOptions; }; diff --git a/src/core/Cutter.cpp b/src/core/Cutter.cpp index f3c0f0de..e2d85297 100644 --- a/src/core/Cutter.cpp +++ b/src/core/Cutter.cpp @@ -24,7 +24,7 @@ #include #include -Q_GLOBAL_STATIC(CutterCore, uniqueInstance) +static CutterCore *uniqueInstance; #define RZ_JSON_KEY(name) static const QString name = QStringLiteral(#name) @@ -182,6 +182,10 @@ CutterCore::CutterCore(QObject *parent) coreMutex(QMutex::Recursive) #endif { + if (uniqueInstance) { + throw std::logic_error("Only one instance of CutterCore must exist"); + } + uniqueInstance = this; } CutterCore *CutterCore::instance() @@ -238,6 +242,8 @@ CutterCore::~CutterCore() rz_core_task_sync_end(&core_->tasks); rz_core_free(this->core_); rz_cons_free(); + assert(uniqueInstance == this); + uniqueInstance = nullptr; } RzCoreLocked CutterCore::core()