diff options
Diffstat (limited to 'SQLiteStudio3/coreSQLiteStudio/sqlitestudio.cpp')
| -rw-r--r-- | SQLiteStudio3/coreSQLiteStudio/sqlitestudio.cpp | 104 |
1 files changed, 78 insertions, 26 deletions
diff --git a/SQLiteStudio3/coreSQLiteStudio/sqlitestudio.cpp b/SQLiteStudio3/coreSQLiteStudio/sqlitestudio.cpp index c38f528..4e966fd 100644 --- a/SQLiteStudio3/coreSQLiteStudio/sqlitestudio.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/sqlitestudio.cpp @@ -1,5 +1,6 @@ #include "sqlitestudio.h" #include "plugins/plugin.h" +#include "services/codesnippetmanager.h" #include "services/pluginmanager.h" #include "common/utils.h" #include "common/utils_sql.h" @@ -34,13 +35,14 @@ #include "services/extralicensemanager.h" #include "services/sqliteextensionmanager.h" #include "translations.h" +#include "chillout/chillout.h" #include <QProcessEnvironment> #include <QThreadPool> #include <QCoreApplication> DEFINE_SINGLETON(SQLiteStudio) -static const int sqlitestudioVersion = 30303; +static const int sqlitestudioVersion = 30404; SQLiteStudio::SQLiteStudio() { @@ -51,6 +53,25 @@ SQLiteStudio::SQLiteStudio() SQLiteStudio::~SQLiteStudio() { } + +void SQLiteStudio::setupCrashHandler() +{ + auto &chillout = Debug::Chillout::getInstance(); + +#ifdef _WIN32 + chillout.init(qApp->applicationName().toStdWString(), qApp->applicationDirPath().toStdWString()); +#else + chillout.init(qApp->applicationName().toStdString(), qApp->applicationDirPath().toStdString()); +#endif + + chillout.setBacktraceCallback([](const char * const) {}); + + chillout.setCrashCallback([this]() { + for (CrashHandler& hnd : crashHandlers) + hnd(); + }); +} + QStringList SQLiteStudio::getInitialTranslationFiles() const { return initialTranslationFiles; @@ -61,6 +82,11 @@ void SQLiteStudio::setInitialTranslationFiles(const QStringList& value) initialTranslationFiles = value; } +void SQLiteStudio::installCrashHandler(SQLiteStudio::CrashHandler handler) +{ + crashHandlers << handler; +} + QString SQLiteStudio::getCurrentLang() const { @@ -182,6 +208,16 @@ void SQLiteStudio::setExportManager(ExportManager* value) exportManager = value; } +CodeSnippetManager* SQLiteStudio::getCodeSnippetManager() const +{ + return codeSnippetManager; +} + +void SQLiteStudio::setCodeSnippetManager(CodeSnippetManager* newCodeSnippetManager) +{ + codeSnippetManager = newCodeSnippetManager; +} + int SQLiteStudio::getVersion() const { return sqlitestudioVersion; @@ -280,7 +316,7 @@ void SQLiteStudio::init(const QStringList& cmdListArguments, bool guiAvailable) QThreadPool::globalInstance()->setMaxThreadCount(10); - Q_INIT_RESOURCE(coreSQLiteStudio); + SQLS_INIT_RESOURCE(coreSQLiteStudio); CfgLazyInitializer::init(); @@ -345,6 +381,7 @@ void SQLiteStudio::init(const QStringList& cmdListArguments, bool guiAvailable) updateManager = new UpdateManager(); #endif extraLicenseManager = new ExtraLicenseManager(); + codeSnippetManager = new CodeSnippetManager(config); extraLicenseManager->addLicense("SQLiteStudio license (GPL v3)", ":/docs/licenses/sqlitestudio_license.txt"); extraLicenseManager->addLicense("Fugue icons", ":/docs/licenses/fugue_icons.txt"); @@ -352,6 +389,9 @@ void SQLiteStudio::init(const QStringList& cmdListArguments, bool guiAvailable) extraLicenseManager->addLicense("diff_match (Apache License v2.0)", ":/docs/licenses/diff_match.txt"); extraLicenseManager->addLicense("RSA library (GPL v3)", ":/docs/licenses/gpl.txt"); extraLicenseManager->addLicense("SingleApplication (The MIT License)", ":/docs/licenses/mit.txt"); + extraLicenseManager->addLicense("ICU (ICU License)", ":/docs/licenses/icu.txt"); + + setupCrashHandler(); } void SQLiteStudio::initPlugins() @@ -365,31 +405,43 @@ void SQLiteStudio::initPlugins() void SQLiteStudio::cleanUp() { + if (finalCleanupDone) + return; + + finalCleanupDone = true; emit aboutToQuit(); - disconnect(pluginManager, SIGNAL(aboutToUnload(Plugin*,PluginType*)), this, SLOT(pluginToBeUnloaded(Plugin*,PluginType*))); - disconnect(pluginManager, SIGNAL(unloaded(QString,PluginType*)), this, SLOT(pluginUnloaded(QString,PluginType*))); - if (!immediateQuit) - { - if (pluginManager) - pluginManager->deinit(); - - safe_delete(pluginManager); // PluginManager before DbManager, so Db objects are deleted while DbManager still exists -#ifdef PORTABLE_CONFIG - safe_delete(updateManager); -#endif - safe_delete(populateManager); - safe_delete(importManager); - safe_delete(exportManager); - safe_delete(functionManager); - safe_delete(extraLicenseManager); - safe_delete(dbManager); - safe_delete(config); - safe_delete(codeFormatter); - safe_delete(dbAttacherFactory); - safe_delete(env); - NotifyManager::destroy(); - } - Q_CLEANUP_RESOURCE(coreSQLiteStudio); + // Deleting all singletons contained in this object, alongside with plugin deinitialization & unloading + // causes QTranslator to crash randomly during shutdown, due to some issue in Qt itself, because it tries to refresh + // some internal translators state after the translator is uninstalled, but at the same time many message resources + // are being unloaded together with plugins and it somehow causes the crash (randomly). + // At the same time if hardly find any reason to execute proper deinitialization of all singletons, when the application stops. + // The session (UI) is saved anyway independently in the UI code. + // Explicit deletion of singletons does not really have any benefits. + // Leaving this code here for some time, just to understand it later if needed, but eventually it will be deleted. +// disconnect(pluginManager, SIGNAL(aboutToUnload(Plugin*,PluginType*)), this, SLOT(pluginToBeUnloaded(Plugin*,PluginType*))); +// disconnect(pluginManager, SIGNAL(unloaded(QString,PluginType*)), this, SLOT(pluginUnloaded(QString,PluginType*))); +// if (!immediateQuit) +// { +// if (pluginManager) +// pluginManager->deinit(); + +// safe_delete(pluginManager); // PluginManager before DbManager, so Db objects are deleted while DbManager still exists +//#ifdef PORTABLE_CONFIG +// safe_delete(updateManager); +//#endif +// safe_delete(populateManager); +// safe_delete(importManager); +// safe_delete(exportManager); +// safe_delete(functionManager); +// safe_delete(extraLicenseManager); +// safe_delete(dbManager); +// safe_delete(config); +// safe_delete(codeFormatter); +// safe_delete(dbAttacherFactory); +// safe_delete(env); +// NotifyManager::destroy(); +// } +// SQLS_CLEANUP_RESOURCE(coreSQLiteStudio); } void SQLiteStudio::updateCodeFormatter() |
