From d0c07c5aa651509de0a172122353e45594749e4a Mon Sep 17 00:00:00 2001 From: Kitsune Ral <> Date: Wed, 31 Jan 2024 16:53:33 +0100 Subject: [PATCH] Fix a crash when the attached file is no more readable ...any more. --- client/chatroomwidget.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/chatroomwidget.cpp b/client/chatroomwidget.cpp index 8d29dd19..82c0377a 100644 --- a/client/chatroomwidget.cpp +++ b/client/chatroomwidget.cpp @@ -344,8 +344,11 @@ QString ChatRoomWidget::checkAttachment() if (m_fileToAttach->open(QIODevice::ReadOnly)) return {}; + // Form the message in advance while the file name is still there + const auto msg = + tr("%1 is not readable or not a file").arg(m_fileToAttach->fileName()); cancelAttaching(); - return tr("%1 is not readable or not a file").arg(m_fileToAttach->fileName()); + return msg; } void ChatRoomWidget::cancelAttaching()