From fdc0a6a514714019c2b80a2a216af1bec35ec3f6 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Sat, 14 Jul 2018 19:12:15 +0200 Subject: [PATCH] Fix code to determine the total row number before a SQL dump Before running the actual SQL dump we need to determine the total number of rows in the database in order to show a progress bar. This code didn't work as expected since the multithreading changes. On the one hand it would produce occasional error messages in the console and maybe even crash. On the other hand the resulting value would always be zero which in turn leads to the progress bar not working. Both issues are fixed by rewriting the code here. See issue #1476. --- src/sqlitedb.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index 4547c48c..2dbe5112 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -628,9 +628,11 @@ bool DBBrowserDB::dump(const QString& filePath, it.remove(); } else { // Otherwise get the number of records in this table - SqliteTableModel tableModel(*this); - tableModel.setTable(sqlb::ObjectIdentifier("main", it.value()->name())); - numRecordsTotal += tableModel.rowCount(); + SqliteTableModel m(*this); + m.setQuery(QString("SELECT COUNT(*) FROM %1;") + .arg(sqlb::ObjectIdentifier("main", it.value()->name()).toString())); + if(m.completeCache()) + numRecordsTotal += m.data(m.index(0, 0)).toUInt(); } }