Use QRecursiveMutex
This commit is contained in:
parent
204508478f
commit
3166ca2127
@ -63,7 +63,9 @@ QMutex Database::sNextConnectionIdMutex;
|
||||
Database::Database(Application *app, QObject *parent, const QString &database_name) :
|
||||
QObject(parent),
|
||||
app_(app),
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
|
||||
mutex_(QMutex::Recursive),
|
||||
#endif
|
||||
injected_database_name_(database_name),
|
||||
query_hash_(0),
|
||||
startup_schema_version_(-1),
|
||||
|
@ -34,6 +34,9 @@
|
||||
#include <QSqlQuery>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
# include <QRecursiveMutex>
|
||||
#endif
|
||||
|
||||
class QThread;
|
||||
class Application;
|
||||
@ -63,7 +66,12 @@ class Database : public QObject {
|
||||
QSqlDatabase Connect();
|
||||
void Close();
|
||||
bool CheckErrors(const QSqlQuery &query);
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
QRecursiveMutex *Mutex() { return &mutex_; }
|
||||
#else
|
||||
QMutex *Mutex() { return &mutex_; }
|
||||
#endif
|
||||
|
||||
void RecreateAttachedDb(const QString &database_name);
|
||||
void ExecSchemaCommands(QSqlDatabase &db, const QString &schema, int schema_version, bool in_transaction = false);
|
||||
@ -106,7 +114,11 @@ class Database : public QObject {
|
||||
|
||||
QString directory_;
|
||||
QMutex connect_mutex_;
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
|
||||
QRecursiveMutex mutex_;
|
||||
#else
|
||||
QMutex mutex_;
|
||||
#endif
|
||||
|
||||
// This ID makes the QSqlDatabase name unique to the object as well as the thread
|
||||
int connection_id_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user