From 6e2de1cd797575893ebe74a6ad037ab538ff7593 Mon Sep 17 00:00:00 2001 From: Felix Geyer Date: Sun, 31 Jul 2016 14:43:33 +0200 Subject: [PATCH] Display proper error message when reading an icon fails. Refs #512 --- src/gui/EditWidgetIcons.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gui/EditWidgetIcons.cpp b/src/gui/EditWidgetIcons.cpp index c408940e3..d8dc04f65 100644 --- a/src/gui/EditWidgetIcons.cpp +++ b/src/gui/EditWidgetIcons.cpp @@ -19,6 +19,7 @@ #include "ui_EditWidgetIcons.h" #include +#include #include "core/Group.h" #include "core/Metadata.h" @@ -129,7 +130,8 @@ void EditWidgetIcons::addCustomIcon() QString filename = QFileDialog::getOpenFileName( this, tr("Select Image"), "", filter); if (!filename.isEmpty()) { - QImage image(filename); + QImageReader imageReader(filename); + QImage image = imageReader.read(); if (!image.isNull()) { Uuid uuid = Uuid::random(); m_database->metadata()->addCustomIconScaled(uuid, image); @@ -139,7 +141,8 @@ void EditWidgetIcons::addCustomIcon() m_ui->customIconsView->setCurrentIndex(index); } else { - // TODO: show error + MessageBox::critical(this, tr("Error"), + tr("Can't read icon:").append("\n").append(imageReader.errorString())); } } }