Multi-threading patch

This was done by Michael Krause.
https://lists.sqlitebrowser.org/pipermail/db4s-dev/2018-February/000305.html

In this commit I only fixed two compiler warnings, some whitespace
issues and removed some debug messages.
This commit is contained in:
Martin Kleusberg
2018-05-21 18:13:56 +02:00
parent 9c2cec628b
commit 51dbe72e23
19 changed files with 1466 additions and 344 deletions

View File

@@ -388,7 +388,7 @@ void EditTableDialog::itemChanged(QTreeWidgetItem *item, int column)
.arg(sqlb::escapeIdentifier(pdb.getObjectByName(curTable).dynamicCast<sqlb::Table>()->rowidColumn()))
.arg(curTable.toString())
.arg(sqlb::escapeIdentifier(field->name())));
m.waitForFetchingFinished();
m.completeCache();
if(m.data(m.index(0, 0)).toInt() > 0)
{
// There is a NULL value, so print an error message, uncheck the combobox, and return here
@@ -416,7 +416,7 @@ void EditTableDialog::itemChanged(QTreeWidgetItem *item, int column)
.arg(curTable.toString())
.arg(sqlb::escapeIdentifier(field->name()))
.arg(sqlb::escapeIdentifier(field->name())));
m.waitForFetchingFinished();
m.completeCache();
if(m.data(m.index(0, 0)).toInt() > 0)
{
// There is a non-integer value, so print an error message, uncheck the combobox, and return here
@@ -458,10 +458,10 @@ void EditTableDialog::itemChanged(QTreeWidgetItem *item, int column)
// Because our renameColumn() function fails when setting a column to unique when it already contains the same values
SqliteTableModel m(pdb, this);
m.setQuery(QString("SELECT COUNT(%2) FROM %1;").arg(curTable.toString()).arg(sqlb::escapeIdentifier(field->name())));
m.waitForFetchingFinished();
m.completeCache();
int rowcount = m.data(m.index(0, 0)).toInt();
m.setQuery(QString("SELECT COUNT(DISTINCT %2) FROM %1;").arg(curTable.toString()).arg(sqlb::escapeIdentifier(field->name())));
m.waitForFetchingFinished();
m.completeCache();
int uniquecount = m.data(m.index(0, 0)).toInt();
if(rowcount != uniquecount)
{