From 0d0e88d6e177e5524fc461771a87c228c4c24a3a Mon Sep 17 00:00:00 2001 From: Jakub Dupak Date: Thu, 15 Feb 2024 14:25:41 +0100 Subject: [PATCH] GUI: fix crashes --- src/gui/windows/messages/messagesmodel.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/windows/messages/messagesmodel.cpp b/src/gui/windows/messages/messagesmodel.cpp index 251ed250..67b6b5f8 100644 --- a/src/gui/windows/messages/messagesmodel.cpp +++ b/src/gui/windows/messages/messagesmodel.cpp @@ -105,7 +105,9 @@ void MessagesModel::insert_line( } void MessagesModel::clear_messages() { - beginRemoveRows(QModelIndex(), 0, rowCount() - 1); + auto row_count = rowCount(); + if (row_count == 0) return; + beginRemoveRows(QModelIndex(), 0, row_count - 1); while (!messages.isEmpty()) { delete messages.takeFirst(); }