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:
mgrojo
2018-11-04 23:55:24 +01:00
parent bcf2c660b6
commit dadccef861
2 changed files with 7 additions and 1 deletions

View File

@@ -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);

View File

@@ -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();
}