Cursor Doesn't Change After Importing Database SQL File #1526

restoreOverrideCursor() is called before asking the user to accept the
warning or information message.
This commit is contained in:
mgrojo
2018-09-06 21:30:20 +02:00
parent d02d98ed22
commit 2081af207b

View File

@@ -1628,14 +1628,16 @@ void MainWindow::importDatabaseFromSQL()
QApplication::setOverrideCursor(Qt::WaitCursor);
QFile f(fileName);
f.open(QIODevice::ReadOnly);
if(!db.executeMultiSQL(f.readAll(), newDbFile.size() == 0))
bool ok = db.executeMultiSQL(f.readAll(), newDbFile.size() == 0);
// Restore cursor before asking the user to accept the message
QApplication::restoreOverrideCursor();
if(!ok)
QMessageBox::warning(this, QApplication::applicationName(), tr("Error importing data: %1").arg(db.lastError()));
else if(db.getPragma("foreign_keys") == "1" && !db.querySingeValueFromDb(QString("PRAGMA foreign_key_check")).isNull())
QMessageBox::warning(this, QApplication::applicationName(), tr("Import completed. Some foreign key constraints are violated. Please fix them before saving."));
else
QMessageBox::information(this, QApplication::applicationName(), tr("Import completed."));
f.close();
QApplication::restoreOverrideCursor();
// Restore the former foreign key settings
db.setPragma("defer_foreign_keys", foreignKeysOldSettings);