Skip to content

Commit

Permalink
Don't emit changes in auth list model when not op
Browse files Browse the repository at this point in the history
Because the list is shown as empty while not operator, so any changes
operate on an empty list, which can lead to crashes.
  • Loading branch information
askmeaboutlo0m committed Aug 7, 2024
1 parent 4ff5a30 commit a32134a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Unreleased Version 2.2.2-pre
* Fix: Use more accurate timers for performance profiles if the platform supports it.
* Fix: Don't try to update the roles list before becoming an operator, which could lead to a crash. Thanks Bluestrings for reporting.

2024-08-04 Version 2.2.2-beta.2
* Feature: Allow choosing a different cursor for erase and alpha locked brushes. Thanks Hipofiz and Rylan for suggesting.
Expand Down
26 changes: 19 additions & 7 deletions src/libclient/net/authlistmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,19 @@ void AuthListModel::update(const QJsonArray &auth)
old.trusted != e.trusted;
if(changed) {
old = e;
QModelIndex idx = index(i, 0);
dataChanged(idx, idx);
if(m_isOperator) {
QModelIndex idx = index(i, 0);
dataChanged(idx, idx);
}
}
} else {
beginInsertRows(QModelIndex(), count, count);
if(m_isOperator) {
beginInsertRows(QModelIndex(), count, count);
}
m_list.append(e);
endInsertRows();
if(m_isOperator) {
endInsertRows();
}
}
}

Expand All @@ -117,13 +123,19 @@ void AuthListModel::update(const QJsonArray &auth)
if(authIds.contains(m_list.at(i).authId)) {
++i;
} else {
beginRemoveRows(QModelIndex(), i, i);
if(m_isOperator) {
beginRemoveRows(QModelIndex(), i, i);
}
m_list.removeAt(i);
endRemoveRows();
if(m_isOperator) {
endRemoveRows();
}
}
}

emit updateApplied();
if(m_isOperator) {
emit updateApplied();
}
}

void AuthListModel::clear()
Expand Down

0 comments on commit a32134a

Please sign in to comment.