Fix crash when editing table after changing its schema

Fix a crash which happened when opening a table in the Edit Table dialog
for modification and changing its schema and then (without reopening the
dialog) change the schema again or doing some other modifications to the
table.

See issue #1131.
This commit is contained in:
Martin Kleusberg
2017-10-06 00:04:06 +02:00
parent 3e02420256
commit 8a7b662435

View File

@@ -749,8 +749,11 @@ void EditTableDialog::changeSchema(const QString& schema)
// Update table if we're editing an existing table
if(!m_bNewTable)
{
if(!pdb.renameColumn(curTable, m_table, QString(), sqlb::FieldPtr(), 0, schema))
if(pdb.renameColumn(curTable, m_table, QString(), sqlb::FieldPtr(), 0, schema))
{
// Save the new schema name to use it from now on
curTable.setSchema(schema);
} else {
QMessageBox::warning(this, QApplication::applicationName(), tr("Changing the table schema failed. Error message:\n%1").arg(pdb.lastError()));
ui->comboSchema->setCurrentText(curTable.schema()); // Set it back to the original schema
}