From 08075752546d552b78fb6673bc105e191eeaf1b3 Mon Sep 17 00:00:00 2001 From: askmeaboutloom Date: Wed, 7 Aug 2024 11:09:03 +0200 Subject: [PATCH] Don't send dataChanged for newly added sessions In the session listing model. This ends up confusing QSortFilterProxy somehow, causing it to potentially run into a crash. --- ChangeLog | 1 + src/libclient/net/sessionlistingmodel.cpp | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index d77f8b6848..6839b54b5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ 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. + * Fix: Don't update sessions that were just added to the session browser, since that can lead to a crash because of what is probably a bug in Qt's filtering and sorting. 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. diff --git a/src/libclient/net/sessionlistingmodel.cpp b/src/libclient/net/sessionlistingmodel.cpp index 97c7a20d34..4be33fe4bd 100644 --- a/src/libclient/net/sessionlistingmodel.cpp +++ b/src/libclient/net/sessionlistingmodel.cpp @@ -2,6 +2,7 @@ #include "libclient/net/sessionlistingmodel.h" #include "libclient/net/loginsessions.h" #include "libclient/parentalcontrols/parentalcontrols.h" +#include "libshared/util/qtcompat.h" #include #include #include @@ -501,10 +502,14 @@ void SessionListingModel::setList( } emit dataChanged(createIndex(i, 0), createIndex(i, 0)); - emit dataChanged( - createIndex(0, 0, quintptr(i + 1)), - createIndex( - sessions.size() - 1, ColumnCount - 1, quintptr(i + 1))); + + compat::sizetype changedSize = qMin(oldSize, sessions.size()); + if(changedSize > 0) { + emit dataChanged( + createIndex(0, 0, quintptr(i + 1)), + createIndex( + changedSize - 1, ColumnCount - 1, quintptr(i + 1))); + } return; } }