Commit f1fe15c2 authored by Halla Rempt's avatar Halla Rempt
Browse files

Check QImageReader errors

parent 9c8a8c8b
......@@ -38,6 +38,7 @@ bool KisPngBrush::load()
QFile f(filename());
if (f.size() == 0) return false;
if (!f.exists()) return false;
f.open(QFile::ReadOnly);
bool res = loadFromDevice(&f);
f.close();
return res;
......@@ -47,6 +48,11 @@ bool KisPngBrush::loadFromDevice(QIODevice *dev)
{
QImageReader reader(dev, "PNG");
if (!reader.canRead()) {
setValid(false);
return false;
}
if (reader.textKeys().contains("brush_spacing")) {
setSpacing(reader.text("brush_spacing").toDouble());
}
......@@ -59,7 +65,14 @@ bool KisPngBrush::loadFromDevice(QIODevice *dev)
setName(info.baseName());
}
setBrushTipImage(reader.read());
QImage image = reader.read();
if (image.isNull()) {
kWarning() << "Could not read brush" << filename() << ". Error:" << reader.errorString();
setValid(false);
return false;
}
setBrushTipImage(image);
setValid(!brushTipImage().isNull());
if (brushTipImage().isGrayscale()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment