mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Avoid deadlock and cancel dialog when using conditional formats
When a conditional format is used and the table does not load all the rows at once, a deadlock ocurred when scrolling to a not yet loaded area. This avoids the deadlock by unlocking before the conditional format query is performed. Additionally the cancel-query dialog is avoided when the threading mode of SQLite is Serialize, since in that case the queries can be sent to SQLite concurrently. See discussion in PR #1503
This commit is contained in:
@@ -988,10 +988,14 @@ bool DBBrowserDB::executeMultiSQL(const QString& statement, bool dirty, bool log
|
||||
|
||||
QByteArray DBBrowserDB::querySingleValueFromDb(const QString& sql, bool log)
|
||||
{
|
||||
waitForDbRelease();
|
||||
if(!_db)
|
||||
return QByteArray();
|
||||
|
||||
// If the threading mode is Single-thread or Multi-thread then wait for
|
||||
// the DB release.
|
||||
if (sqlite3_db_mutex(_db) == nullptr)
|
||||
waitForDbRelease();
|
||||
|
||||
if(log)
|
||||
logSQL(sql, kLogMsg_App);
|
||||
|
||||
|
||||
@@ -314,6 +314,8 @@ QVariant SqliteTableModel::data(const QModelIndex &index, int role) const
|
||||
else
|
||||
sql = QString("SELECT '%1' %2").arg(value, eachCondFormat.sqlCondition());
|
||||
|
||||
// Unlock before querying from DB
|
||||
lock.unlock();
|
||||
if (m_db.querySingleValueFromDb(sql, false) == "1")
|
||||
return eachCondFormat.color();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user