Skip to content

Commit bb2b36f

Browse files
authored
Merge pull request #8511 from gadfort/gui-fix-instance-loop
gui: guard getProperties failure
2 parents 5ea7a72 + 2d3efab commit bb2b36f

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

src/gui/src/inspector.cpp

Lines changed: 26 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,32 @@ 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()),
111+
error.what(),
112+
"Failed to populate properties.");
113+
appendRow({makeItem(QString::fromStdString("error")),
114+
makeItem(QString(error.what()))});
106115
}
107116

108117
endResetModel();

0 commit comments

Comments
 (0)