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