summary refs log tree commit diff
path: root/src/notifications/ManagerMac.cpp
diff options
context:
space:
mode:
authorLoren Burkholder <computersemiexpert@outlook.com>2021-03-02 19:43:25 -0500
committerNicolas Werner <nicolas.werner@hotmail.de>2021-03-17 19:18:07 +0100
commit716c598f4aa9182b783134b1c3f5da60903c9a8c (patch)
tree253a5616702502e79b137f7f89b23de8d88dc3fc /src/notifications/ManagerMac.cpp
parentmake lint (diff)
downloadnheko-716c598f4aa9182b783134b1c3f5da60903c9a8c.tar.xz
Simplify macOS checks for a null image
Diffstat (limited to 'src/notifications/ManagerMac.cpp')
-rw-r--r--src/notifications/ManagerMac.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/notifications/ManagerMac.cpp b/src/notifications/ManagerMac.cpp

index 7e3ad309..0819272b 100644 --- a/src/notifications/ManagerMac.cpp +++ b/src/notifications/ManagerMac.cpp
@@ -41,7 +41,7 @@ NotificationsManager::postNotification(const mtx::responses::Notification &notif QImage *image = nullptr; if (mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Image) - image = new QImage{cacheImage(notification.event)}; + image = getImgOrNullptr(cacheImage(notification.event)); const auto isEncrypted = std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>( @@ -58,6 +58,17 @@ NotificationsManager::postNotification(const mtx::responses::Notification &notif const QString messageInfo = (isReply ? tr("%1 replied to a message") : tr("%1 sent a message")).arg(sender); objCxxPostNotification( - room_name, messageInfo, formatNotification(notification), (image != nullptr && !image->isNull()) ? image : nullptr); + room_name, messageInfo, formatNotification(notification), image); } } + +QImage * +NotificationsManager::getImgOrNullptr(const QString &path) +{ + auto img = new QImage{path}; + if (img->isNull()) { + delete img; + return nullptr; + } + return img; +}