mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Fix crashes in Edit Index dialog when database has no tables
Fix some crashes in the Edit Index dialog which happen if you try to add a new index when there are no tables in the database yet. See issue #1293.
This commit is contained in:
@@ -112,7 +112,10 @@ void EditIndexDialog::tableChanged(const QString& new_table, bool initialLoad)
|
||||
void EditIndexDialog::updateColumnLists()
|
||||
{
|
||||
// Fill the table column list
|
||||
sqlb::FieldInfoList tableFields = pdb.getObjectByName(sqlb::ObjectIdentifier(ui->comboTableName->currentData())).dynamicCast<sqlb::Table>()->fieldInformation();
|
||||
sqlb::TablePtr table = pdb.getObjectByName(sqlb::ObjectIdentifier(ui->comboTableName->currentData())).dynamicCast<sqlb::Table>();
|
||||
if(!table)
|
||||
return;
|
||||
sqlb::FieldInfoList tableFields = table->fieldInformation();
|
||||
ui->tableTableColumns->setRowCount(tableFields.size());
|
||||
int tableRows = 0;
|
||||
for(int i=0;i<tableFields.size();++i)
|
||||
@@ -236,6 +239,10 @@ void EditIndexDialog::checkInput()
|
||||
if(ui->editIndexName->text().isEmpty())
|
||||
valid = false;
|
||||
|
||||
// Check if a table is selected (this is especially important in the case where there are no tables in the database yet).
|
||||
if(ui->comboTableName->currentText().isNull())
|
||||
valid = false;
|
||||
|
||||
// Check if index has any columns
|
||||
if(index.columns().size() == 0)
|
||||
valid = false;
|
||||
|
||||
@@ -40,8 +40,12 @@ public:
|
||||
explicit ObjectIdentifier(QVariant variant)
|
||||
{
|
||||
QStringList str = variant.toStringList();
|
||||
m_schema = str.first();
|
||||
m_name = str.last();
|
||||
if(str.size())
|
||||
{
|
||||
m_schema = str.first();
|
||||
if(str.size() >= 2)
|
||||
m_name = str.last();
|
||||
}
|
||||
}
|
||||
|
||||
bool operator==(const ObjectIdentifier& rhs) const
|
||||
|
||||
Reference in New Issue
Block a user