diff --git a/src/chat/chat-room.cpp b/src/chat/chat-room.cpp index a861e0843..5a6abe170 100644 --- a/src/chat/chat-room.cpp +++ b/src/chat/chat-room.cpp @@ -91,7 +91,6 @@ void ChatRoomPrivate::release () { msg->cancelFileTransfer(); msg->getPrivate()->setChatRoom(nullptr); } catch(const std::bad_weak_ptr& e) {} - } for (auto &message : transientMessages) { message->cancelFileTransfer(); @@ -336,9 +335,11 @@ shared_ptr ChatRoomPrivate::getTransientMessage (unsigned int stora std::shared_ptr ChatRoomPrivate::getWeakMessage (unsigned int storageId) const { for (auto &message : weakMessages) { - shared_ptr msg(message); - if (msg->getPrivate()->getStorageId() == storageId) - return msg; + try { + shared_ptr msg(message); + if (msg->getPrivate()->getStorageId() == storageId) + return msg; + } catch(const std::bad_weak_ptr& e) {} } return nullptr; }