Skip to content

Commit

Permalink
Fixed crash when editing the display format while the currently brows…
Browse files Browse the repository at this point in the history
…ed table name is actually a view (#1196)

* Added an option in the context menu for using the currently selected cell
as filter in this column. This allows quick filtering by selected values.

* Changes to pull request #1182 requested by @MKleusberg: get internal cell data and check for the NULL special case.

* Updated Spanish translation.
Reviewed translation following guidelines the KDE Spanish Translation Team: https://es.l10n.kde.org/
Warnings raised by linguist have been solved.

* 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.
  • Loading branch information
mgrojo authored and MKleusberg committed Oct 27, 2017
1 parent c69314f commit 926bb3c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<sqlb::Table>()->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<sqlb::Table>()->fields().at(field_number-1)->name();
else
field_name = db.getObjectByName(current_table).dynamicCast<sqlb::View>()->fieldNames().at(field_number-1);
// Get the current display format of the field
QString current_displayformat = browseTableSettings[current_table].displayFormats[field_number];

Expand Down

0 comments on commit 926bb3c

Please sign in to comment.