Skip to content

Commit b3b3ddd

Browse files
committed
Fix crash in Value model
1 parent 015da47 commit b3b3ddd

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

src/app/models/key-models/abstractkey.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ template < typename T > class KeyModel : public ValueEditor::Model
3232
m_fullLoadingCmdSupportsRanges(fullLoadingCmdSupportsRanges),
3333
m_notifier(new ValueEditor::ModelSignals())
3434
{
35-
loadRowsCount();
35+
try {
36+
loadRowsCount();
37+
} catch (const ValueEditor::Model::Exception& e) {
38+
qDebug() << "Connection error:" << e.what(); // TODO(u_glide): Notify user about error
39+
}
3640
}
3741

3842
virtual QString getKeyName() override

src/modules/value-editor/valueviewmodel.cpp

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,29 @@ void ValueEditor::ValueViewModel::loadRows(int start, int count)
8686
return;
8787
}
8888

89-
m_model->loadRows(start, count, [this, start, count](const QString& error)
90-
{
91-
int loaded = totalRowCount() - start;
92-
loaded = (loaded > count) ? count : loaded;
89+
QString msg = QString("Cannot load key value: %1");
9390

94-
m_lastLoadedRowFrameSize = loaded;
95-
m_startFramePosition = start;
91+
try {
92+
m_model->loadRows(start, count, [this, start, count, msg](const QString& err)
93+
{
94+
if (!err.isEmpty()) {
95+
emit error(msg.arg(err));
96+
return;
97+
}
9698

97-
emit layoutAboutToBeChanged();
98-
emit rowsLoaded(start, loaded);
99-
emit layoutChanged();
100-
});
99+
int loaded = totalRowCount() - start;
100+
loaded = (loaded > count) ? count : loaded;
101+
102+
m_lastLoadedRowFrameSize = loaded;
103+
m_startFramePosition = start;
104+
105+
emit layoutAboutToBeChanged();
106+
emit rowsLoaded(start, loaded);
107+
emit layoutChanged();
108+
});
109+
} catch (const ValueEditor::Model::Exception& e) {
110+
emit error(msg.arg(e.what()));
111+
}
101112
}
102113

103114
void ValueEditor::ValueViewModel::addRow(const QVariantMap &row)

0 commit comments

Comments
 (0)