Skip to content

Commit

Permalink
Fix failing to send attachments due to already open file
Browse files Browse the repository at this point in the history
  • Loading branch information
KitsuneRal authored and Kitsune Ral committed Feb 1, 2024
1 parent d0c07c5 commit 700dd4d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions client/chatroomwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ void ChatRoomWidget::dropFile(const QString& localPath)
QString ChatRoomWidget::checkAttachment()
{
Q_ASSERT(m_fileToAttach != nullptr);
if (m_fileToAttach->open(QIODevice::ReadOnly))
if (m_fileToAttach->isReadable()
|| m_fileToAttach->open(QIODevice::ReadOnly))
return {};

// Form the message in advance while the file name is still there
Expand Down Expand Up @@ -415,10 +416,6 @@ QString ChatRoomWidget::sendFile()
if (const auto error = checkAttachment(); !error.isEmpty())
return error;

if (!m_fileToAttach->open(QIODevice::ReadOnly))
return tr("%1 is not readable or not a file")
.arg(m_fileToAttach->fileName());

QFileInfo fileInfo(*m_fileToAttach);
currentRoom()->postFile(description.isEmpty() ? fileInfo.fileName()
: description,
Expand Down

0 comments on commit 700dd4d

Please sign in to comment.