Skip to content

Commit f319f70

Browse files
committed
Fix a deadlock in the insertion case.
When inserting a single item, we need to unlock the mutex to avoid a deadlock.
1 parent 73aa47c commit f319f70

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

jsonlistmodel.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,16 @@ void JsonListModel::add(const QJSValue &item)
9797
} else {
9898
extractRoles(item);
9999
int row = addItem(item);
100-
if (row < 0) {
101-
m_lock->unlock();
102-
// do nothing
103-
} else if (row < originalSize) {
100+
101+
if (row >= 0 && row < originalSize) {
104102
QModelIndex index = createIndex(row, 0);
105103
m_lock->unlock();
106104
emit dataChanged(index, index);
107105
return;
108106
}
109107

110108
int newSize = m_keys.count();
109+
m_lock->unlock();
111110

112111
if (newSize > originalSize) {
113112
beginInsertRows(QModelIndex(), originalSize, newSize - 1);

0 commit comments

Comments
 (0)