Commit 3929649e authored by Jouni Pentikäinen's avatar Jouni Pentikäinen

Fix failure handling when saving reference images

BUG: 396143
parent e0cede28
...@@ -274,16 +274,14 @@ bool KisReferenceImage::saveImage(KoStore *store) const ...@@ -274,16 +274,14 @@ bool KisReferenceImage::saveImage(KoStore *store) const
return false; return false;
} }
KoStoreDevice storeDev(store); bool saved = false;
if (!storeDev.open(QIODevice::WriteOnly)) {
return false;
}
if (!d->image.save(&storeDev, "PNG")) { KoStoreDevice storeDev(store);
return false; if (storeDev.open(QIODevice::WriteOnly)) {
saved = d->image.save(&storeDev, "PNG");
} }
return store->close(); return store->close() && saved;
} }
bool KisReferenceImage::loadImage(KoStore *store) bool KisReferenceImage::loadImage(KoStore *store)
......
...@@ -94,10 +94,15 @@ bool KisKraSaveVisitor::visit(KisExternalLayer * layer) ...@@ -94,10 +94,15 @@ bool KisKraSaveVisitor::visit(KisExternalLayer * layer)
{ {
bool result = false; bool result = false;
if (auto* referencesLayer = dynamic_cast<KisReferenceImagesLayer*>(layer)) { if (auto* referencesLayer = dynamic_cast<KisReferenceImagesLayer*>(layer)) {
result = true;
Q_FOREACH(KoShape *shape, referencesLayer->shapes()) { Q_FOREACH(KoShape *shape, referencesLayer->shapes()) {
auto *reference = dynamic_cast<KisReferenceImage*>(shape); auto *reference = dynamic_cast<KisReferenceImage*>(shape);
KIS_ASSERT_RECOVER_RETURN_VALUE(reference, false); KIS_ASSERT_RECOVER_RETURN_VALUE(reference, false);
reference->saveImage(m_store); bool saved = reference->saveImage(m_store);
if (!saved) {
m_errorMessages << i18n("Failed to save reference image %1.", reference->url());
result = false;
}
} }
} }
else if (KisShapeLayer *shapeLayer = dynamic_cast<KisShapeLayer*>(layer)) { else if (KisShapeLayer *shapeLayer = dynamic_cast<KisShapeLayer*>(layer)) {
......
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