From 81a21e6ce040e7740de86340c8ea4dba30e69bc3 Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Thu, 16 Jan 2025 01:57:37 -0500 Subject: New upstream version 3.4.13+dfsg. --- .../coreSQLiteStudio/services/collationmanager.h | 7 ++++++ SQLiteStudio3/coreSQLiteStudio/services/config.h | 2 +- .../coreSQLiteStudio/services/dbmanager.h | 8 ++++++- .../coreSQLiteStudio/services/exportmanager.cpp | 2 +- .../coreSQLiteStudio/services/exportmanager.h | 2 +- .../services/impl/collationmanagerimpl.cpp | 15 +++++++++++++ .../services/impl/collationmanagerimpl.h | 1 + .../coreSQLiteStudio/services/impl/configimpl.cpp | 11 +++++++++- .../coreSQLiteStudio/services/impl/configimpl.h | 1 + .../services/impl/dbmanagerimpl.cpp | 12 +++++++++++ .../coreSQLiteStudio/services/impl/dbmanagerimpl.h | 1 + .../services/impl/functionmanagerimpl.cpp | 25 +++++++++++++--------- .../coreSQLiteStudio/services/importmanager.cpp | 3 +++ .../coreSQLiteStudio/services/importmanager.h | 1 + 14 files changed, 76 insertions(+), 15 deletions(-) (limited to 'SQLiteStudio3/coreSQLiteStudio/services') diff --git a/SQLiteStudio3/coreSQLiteStudio/services/collationmanager.h b/SQLiteStudio3/coreSQLiteStudio/services/collationmanager.h index ef1f57a..02e2bda 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/collationmanager.h +++ b/SQLiteStudio3/coreSQLiteStudio/services/collationmanager.h @@ -14,9 +14,15 @@ class API_EXPORT CollationManager : public QObject Q_OBJECT public: + enum CollationType + { + FUNCTION_BASED = 0, + EXTENSION_BASED = 1 + }; struct API_EXPORT Collation { QString name; + CollationType type; QString lang; QString code; QStringList databases; @@ -30,6 +36,7 @@ class API_EXPORT CollationManager : public QObject virtual QList getCollationsForDatabase(const QString& dbName) const = 0; virtual int evaluate(const QString& name, const QString& value1, const QString& value2) = 0; virtual int evaluateDefault(const QString& value1, const QString& value2) = 0; + virtual CollationPtr getCollation(const QString &name) const = 0; signals: void collationListChanged(); diff --git a/SQLiteStudio3/coreSQLiteStudio/services/config.h b/SQLiteStudio3/coreSQLiteStudio/services/config.h index bd001c2..2410761 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/config.h +++ b/SQLiteStudio3/coreSQLiteStudio/services/config.h @@ -12,7 +12,7 @@ #include #include -const int SQLITESTUDIO_CONFIG_VERSION = 3; +const int SQLITESTUDIO_CONFIG_VERSION = 4; CFG_CATEGORIES(Core, CFG_CATEGORY(General, diff --git a/SQLiteStudio3/coreSQLiteStudio/services/dbmanager.h b/SQLiteStudio3/coreSQLiteStudio/services/dbmanager.h index 2b5fa41..6336eb7 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/dbmanager.h +++ b/SQLiteStudio3/coreSQLiteStudio/services/dbmanager.h @@ -107,7 +107,7 @@ class API_EXPORT DbManager : public QObject /** * @brief Gives list of valid databases. - * @return List of open databases. + * @return List of valid databases. */ virtual QList getValidDbList() = 0; @@ -123,6 +123,12 @@ class API_EXPORT DbManager : public QObject */ virtual QStringList getDbNames() = 0; + /** + * @brief Gives list of valid database names. + * @return List of database names that are registered and valid (no errors) in the application. + */ + virtual QStringList getValidDbNames() = 0; + /** * @brief Gives database object by its name. * @param name Symbolic name of the database. diff --git a/SQLiteStudio3/coreSQLiteStudio/services/exportmanager.cpp b/SQLiteStudio3/coreSQLiteStudio/services/exportmanager.cpp index c9b272d..35d9048 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/exportmanager.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/services/exportmanager.cpp @@ -2,7 +2,6 @@ #include "services/pluginmanager.h" #include "plugins/exportplugin.h" #include "services/notifymanager.h" -#include "db/queryexecutor.h" #include "exportworker.h" #include #include @@ -194,6 +193,7 @@ ExportWorker* ExportManager::prepareExport() ExportWorker* worker = new ExportWorker(plugin, config, output); connect(worker, SIGNAL(finished(bool,QIODevice*)), this, SLOT(finalizeExport(bool,QIODevice*))); + connect(worker, SIGNAL(finishedStep(int)), this, SIGNAL(finishedStep(int))); connect(this, SIGNAL(orderWorkerToInterrupt()), worker, SLOT(interrupt())); return worker; } diff --git a/SQLiteStudio3/coreSQLiteStudio/services/exportmanager.h b/SQLiteStudio3/coreSQLiteStudio/services/exportmanager.h index 64d1136..7abcc70 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/exportmanager.h +++ b/SQLiteStudio3/coreSQLiteStudio/services/exportmanager.h @@ -9,7 +9,6 @@ #include class ExportPlugin; -class QueryExecutor; class ExportWorker; class QBuffer; class CfgEntry; @@ -220,6 +219,7 @@ class API_EXPORT ExportManager : public PluginServiceBase void exportFinished(); void exportSuccessful(); void exportFailed(); + void finishedStep(int step); void storeInClipboard(const QString& str); void storeInClipboard(const QByteArray& bytes, const QString& mimeType); void orderWorkerToInterrupt(); diff --git a/SQLiteStudio3/coreSQLiteStudio/services/impl/collationmanagerimpl.cpp b/SQLiteStudio3/coreSQLiteStudio/services/impl/collationmanagerimpl.cpp index 1cdc59f..668eb72 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/impl/collationmanagerimpl.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/services/impl/collationmanagerimpl.cpp @@ -34,6 +34,16 @@ QList CollationManagerImpl::getAllCollations() c return collations; } +CollationManager::CollationPtr CollationManagerImpl::getCollation(const QString &name) const +{ + if (!collationsByKey.contains(name)) + { + qCritical() << "Could not find requested collation" << name << "."; + return nullptr; + } + return collationsByKey[name]; +} + QList CollationManagerImpl::getCollationsForDatabase(const QString& dbName) const { QList results; @@ -98,6 +108,7 @@ void CollationManagerImpl::storeInConfig() for (CollationPtr coll : collations) { collHash["name"] = coll->name; + collHash["type"] = coll->type; collHash["lang"] = coll->lang; collHash["code"] = coll->code; collHash["allDatabases"] = coll->allDatabases; @@ -119,6 +130,10 @@ void CollationManagerImpl::loadFromConfig() collHash = var.toHash(); coll = CollationPtr::create(); coll->name = collHash["name"].toString(); + if (collHash.contains("type") && collHash["type"].toInt() == CollationType::EXTENSION_BASED) + coll->type = CollationType::EXTENSION_BASED; + else + coll->type = CollationType::FUNCTION_BASED; coll->lang = updateScriptingQtLang(collHash["lang"].toString()); coll->code = collHash["code"].toString(); coll->databases = collHash["databases"].toStringList(); diff --git a/SQLiteStudio3/coreSQLiteStudio/services/impl/collationmanagerimpl.h b/SQLiteStudio3/coreSQLiteStudio/services/impl/collationmanagerimpl.h index 27adffb..5ce47c6 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/impl/collationmanagerimpl.h +++ b/SQLiteStudio3/coreSQLiteStudio/services/impl/collationmanagerimpl.h @@ -17,6 +17,7 @@ class API_EXPORT CollationManagerImpl : public CollationManager QList getCollationsForDatabase(const QString& dbName) const; int evaluate(const QString& name, const QString& value1, const QString& value2); int evaluateDefault(const QString& value1, const QString& value2); + CollationPtr getCollation(const QString &name) const; private: void init(); diff --git a/SQLiteStudio3/coreSQLiteStudio/services/impl/configimpl.cpp b/SQLiteStudio3/coreSQLiteStudio/services/impl/configimpl.cpp index a7f8d2b..bcd6df8 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/impl/configimpl.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/services/impl/configimpl.cpp @@ -478,6 +478,7 @@ QVariant ConfigImpl::getPopulateHistory(const QString& pluginName) const void ConfigImpl::addDdlHistory(const QString& queries, const QString& dbName, const QString& dbFile) { + ddlHistoryMutex.lock(); QtConcurrent::run(this, &ConfigImpl::asyncAddDdlHistory, queries, dbName, dbFile); } @@ -1030,6 +1031,7 @@ void ConfigImpl::asyncAddDdlHistory(const QString& queries, const QString& dbNam } } db->commit(); + ddlHistoryMutex.unlock(); emit ddlHistoryRefreshNeeded(); } @@ -1122,12 +1124,19 @@ void ConfigImpl::updateConfigDb() // 1->2 db->exec("UPDATE settings SET [key] = 'DataUncommittedError' WHERE [key] = 'DataUncommitedError'"); db->exec("UPDATE settings SET [key] = 'DataUncommitted' WHERE [key] = 'DataUncommited'"); - __attribute__((__fallthrough__)); + [[fallthrough]]; } case 2: { // 2->3 db->exec("ALTER TABLE groups ADD db_expanded INTEGER DEFAULT 0"); + [[fallthrough]]; + } + case 3: + { + // 3->4 + db->exec("DELETE FROM settings WHERE [group] = 'DialogDimensions'"); // #5161 + //[[fallthrough]]; } // Add cases here for next versions, // without a "break" instruction, diff --git a/SQLiteStudio3/coreSQLiteStudio/services/impl/configimpl.h b/SQLiteStudio3/coreSQLiteStudio/services/impl/configimpl.h index 9f0f36e..14d42e0 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/impl/configimpl.h +++ b/SQLiteStudio3/coreSQLiteStudio/services/impl/configimpl.h @@ -154,6 +154,7 @@ class API_EXPORT ConfigImpl : public Config SqlHistoryModel* sqlHistoryModel = nullptr; DdlHistoryModel* ddlHistoryModel = nullptr; QMutex sqlHistoryMutex; + QMutex ddlHistoryMutex; QString sqlite3Version; public slots: diff --git a/SQLiteStudio3/coreSQLiteStudio/services/impl/dbmanagerimpl.cpp b/SQLiteStudio3/coreSQLiteStudio/services/impl/dbmanagerimpl.cpp index 6258f71..46c8178 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/impl/dbmanagerimpl.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/services/impl/dbmanagerimpl.cpp @@ -247,6 +247,18 @@ QStringList DbManagerImpl::getDbNames() return nameToDb.keys(); } +QStringList DbManagerImpl::getValidDbNames() +{ + QReadLocker lock(&listLock); + QStringList result; + for (Db* db : dbList) + { + if (db->isValid()) + result << db->getName(); + } + return result; +} + Db* DbManagerImpl::getByName(const QString &name, Qt::CaseSensitivity cs) { QReadLocker lock(&listLock); diff --git a/SQLiteStudio3/coreSQLiteStudio/services/impl/dbmanagerimpl.h b/SQLiteStudio3/coreSQLiteStudio/services/impl/dbmanagerimpl.h index 5f99f86..867dd92 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/impl/dbmanagerimpl.h +++ b/SQLiteStudio3/coreSQLiteStudio/services/impl/dbmanagerimpl.h @@ -40,6 +40,7 @@ class API_EXPORT DbManagerImpl : public DbManager QList getValidDbList(); QList getConnectedDbList(); QStringList getDbNames(); + QStringList getValidDbNames(); Db* getByName(const QString& name, Qt::CaseSensitivity cs = Qt::CaseInsensitive); Db* getByPath(const QString& path); Db* createInMemDb(bool pureInit = false); diff --git a/SQLiteStudio3/coreSQLiteStudio/services/impl/functionmanagerimpl.cpp b/SQLiteStudio3/coreSQLiteStudio/services/impl/functionmanagerimpl.cpp index 1b49f3b..ef0fbc9 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/impl/functionmanagerimpl.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/services/impl/functionmanagerimpl.cpp @@ -721,35 +721,40 @@ QVariant FunctionManagerImpl::nativeImport(const QList &args, Db *db, ImportManager::StandardImportConfig stdConfig; stdConfig.inputFileName = args[0].toString(); stdConfig.ignoreErrors = true; - stdConfig.skipTransaction = true; + stdConfig.noDbLock = true; if (args.size() > 3) stdConfig.codec = args[3].toString(); if (args.size() > 4) { // Parsing plugin options - int idx; - QString option; - QString value; - CfgEntry* cfg; QStringList lines = args[4].toString().split(QRegExp("[\r\n]+")); for (const QString& line : lines) { - idx = line.indexOf("="); + int idx = line.indexOf("="); if (idx == -1) { qDebug() << "Invalid options entry for import() function call:" << line; continue; } - option = line.left(idx).trimmed(); - cfg = CfgMain::getEntryByPath(option); + QString option = line.left(idx).trimmed(); + CfgEntry* cfg = CfgMain::getEntryByPath(option); if (!cfg) { qDebug() << "Invalid option name for import() function call:" << option; continue; } - value = line.mid(idx + 1); - cfg->set(value); + + QVariant varValue = line.mid(idx + 1); + QVariant defValue = cfg->getDefaultValue(); + QVariant::Type expectedType = defValue.type(); + if (varValue.type() != expectedType && !varValue.convert(expectedType)) + { + qDebug() << "Invalid option value for import() function call:" << option << ", invalid value was:" << varValue.toString() + << ", expected value type was:" << defValue.typeName() << ", but given value could not be converted to that type."; + continue; + } + cfg->set(varValue); } } diff --git a/SQLiteStudio3/coreSQLiteStudio/services/importmanager.cpp b/SQLiteStudio3/coreSQLiteStudio/services/importmanager.cpp index a06a743..7b38211 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/importmanager.cpp +++ b/SQLiteStudio3/coreSQLiteStudio/services/importmanager.cpp @@ -74,7 +74,10 @@ void ImportManager::importToTable(Db* db, const QString& table, bool async) if (async) QThreadPool::globalInstance()->start(worker); else + { worker->run(); + delete worker; + } } void ImportManager::interrupt() diff --git a/SQLiteStudio3/coreSQLiteStudio/services/importmanager.h b/SQLiteStudio3/coreSQLiteStudio/services/importmanager.h index 9e9b160..c812ee8 100644 --- a/SQLiteStudio3/coreSQLiteStudio/services/importmanager.h +++ b/SQLiteStudio3/coreSQLiteStudio/services/importmanager.h @@ -39,6 +39,7 @@ class API_EXPORT ImportManager : public PluginServiceBase bool ignoreErrors = false; bool skipTransaction = false; + bool noDbLock = false; }; enum StandardConfigFlag -- cgit v1.2.3