From 9fd4ebe0e0ba6bc48509d4d8b9a27205c60d81a1 Mon Sep 17 00:00:00 2001 From: mgrojo Date: Thu, 26 Oct 2017 00:11:13 +0200 Subject: [PATCH] Fixed crashed when editing the display format and the currently browsed table name is actually a view. Now it is checked the object type before the cast. This avoids the crash and the field name is obtained for each case. --- src/MainWindow.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 8da7e4f5..85fcaef8 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -2400,8 +2400,11 @@ void MainWindow::editDataColumnDisplayFormat() // column is always the rowid column. Ultimately, get the column name from the column object sqlb::ObjectIdentifier current_table = currentlyBrowsedTableName(); int field_number = sender()->property("clicked_column").toInt(); - QString field_name = db.getObjectByName(current_table).dynamicCast()->fields().at(field_number-1)->name(); - + QString field_name; + if (db.getObjectByName(current_table)->type() == sqlb::Object::Table) + field_name = db.getObjectByName(current_table).dynamicCast()->fields().at(field_number-1)->name(); + else + field_name = db.getObjectByName(current_table).dynamicCast()->fieldNames().at(field_number-1); // Get the current display format of the field QString current_displayformat = browseTableSettings[current_table].displayFormats[field_number];