Don't create a QImage every time

This commit is contained in:
Loren Burkholder 2021-03-02 19:51:44 -05:00 committed by Nicolas Werner
parent 716c598f4a
commit 95a26edad2
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9

View file

@ -65,10 +65,7 @@ NotificationsManager::postNotification(const mtx::responses::Notification &notif
QImage * QImage *
NotificationsManager::getImgOrNullptr(const QString &path) NotificationsManager::getImgOrNullptr(const QString &path)
{ {
auto img = new QImage{path}; if (QFile::exists(path))
if (img->isNull()) {
delete img;
return nullptr; return nullptr;
} return new QImage{path};
return img;
} }