|
10 | 10 | #include <QHeaderView> |
11 | 11 | #include <QLineEdit> |
12 | 12 | #include <QMenu> |
| 13 | +#include <QMessageBox> |
13 | 14 | #include <QPushButton> |
14 | 15 | #include <QString> |
15 | 16 | #include <QVariant> |
@@ -85,24 +86,29 @@ void SelectedItemModel::updateObject() |
85 | 86 |
|
86 | 87 | auto editors = object_.getEditors(); |
87 | 88 |
|
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 | + } |
105 | 108 | } |
| 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()))}); |
106 | 112 | } |
107 | 113 |
|
108 | 114 | endResetModel(); |
|
0 commit comments