Fix crash when clicking Create Index in empty database

This fixes a crash that would happen if you click the Create Index
button while having opened an empty database file, i.e. without any
table to create an index on yet.
This commit is contained in:
Martin Kleusberg
2017-01-31 18:56:42 +01:00
parent 8da626250d
commit 036e4349e0

View File

@@ -68,6 +68,14 @@ void EditIndexDialog::tableChanged(const QString& new_table, bool initialLoad)
index.clearColumns();
}
// Stop here if table name is empty
if(new_table.isEmpty())
{
// Call checkInput() before to make sure the OK button is disabled
checkInput();
return;
}
// And fill the table again
QStringList fields = pdb.getObjectByName(new_table).dynamicCast<sqlb::Table>()->fieldNames();
ui->tableIndexColumns->setRowCount(fields.size());