Fix exit
This commit is contained in:
@@ -229,7 +229,10 @@ Database::Database(Application *app, QObject *parent, const QString &database_na
|
||||
mutex_(QMutex::Recursive),
|
||||
injected_database_name_(database_name),
|
||||
query_hash_(0),
|
||||
startup_schema_version_(-1) {
|
||||
startup_schema_version_(-1),
|
||||
original_thread_(nullptr) {
|
||||
|
||||
original_thread_ = thread();
|
||||
|
||||
{
|
||||
QMutexLocker l(&sNextConnectionIdMutex);
|
||||
@@ -259,6 +262,19 @@ Database::~Database() {
|
||||
|
||||
}
|
||||
|
||||
void Database::ExitAsync() {
|
||||
metaObject()->invokeMethod(this, "Exit", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void Database::Exit() {
|
||||
|
||||
assert(QThread::currentThread() == thread());
|
||||
Close();
|
||||
moveToThread(original_thread_);
|
||||
emit ExitFinished();
|
||||
|
||||
}
|
||||
|
||||
QSqlDatabase Database::Connect() {
|
||||
|
||||
QMutexLocker l(&connect_mutex_);
|
||||
|
||||
Reference in New Issue
Block a user