Skip to content

Commit d714667

Browse files
committed
gui: guard getProperties failure
Signed-off-by: Peter Gadfort <[email protected]>
1 parent 29b70ac commit d714667

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

src/gui/src/inspector.cpp

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <QHeaderView>
1111
#include <QLineEdit>
1212
#include <QMenu>
13+
#include <QMessageBox>
1314
#include <QPushButton>
1415
#include <QString>
1516
#include <QVariant>
@@ -85,24 +86,29 @@ void SelectedItemModel::updateObject()
8586

8687
auto editors = object_.getEditors();
8788

88-
for (const auto& prop : object_.getProperties()) {
89-
QStandardItem* name_item = nullptr;
90-
QStandardItem* value_item = nullptr;
91-
92-
makePropertyItem(prop, name_item, value_item);
93-
94-
appendRow({name_item, value_item});
95-
96-
// make editor if found
97-
auto editor_found = editors.find(prop.name);
98-
if (editor_found != editors.end()) {
99-
auto& editor = (*editor_found).second;
100-
makeItemEditor(prop.name,
101-
value_item,
102-
object_,
103-
EditorItemDelegate::getEditorType(prop.value),
104-
editor);
89+
try {
90+
for (const auto& prop : object_.getProperties()) {
91+
QStandardItem* name_item = nullptr;
92+
QStandardItem* value_item = nullptr;
93+
94+
makePropertyItem(prop, name_item, value_item);
95+
96+
appendRow({name_item, value_item});
97+
98+
// make editor if found
99+
auto editor_found = editors.find(prop.name);
100+
if (editor_found != editors.end()) {
101+
auto& editor = (*editor_found).second;
102+
makeItemEditor(prop.name,
103+
value_item,
104+
object_,
105+
EditorItemDelegate::getEditorType(prop.value),
106+
editor);
107+
}
105108
}
109+
} catch (const std::runtime_error& error) {
110+
QMessageBox::critical(qobject_cast<QWidget*>(parent()), error.what(), "Failed to populate properties.");
111+
appendRow({makeItem(QString::fromStdString("error")), makeItem(QString(error.what()))});
106112
}
107113

108114
endResetModel();

0 commit comments

Comments
 (0)