Commit a1308094 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Fix crash when loading ORA images

parent 6bf2f807
...@@ -104,7 +104,6 @@ void KisOpenRasterStackLoadVisitor::loadImage() ...@@ -104,7 +104,6 @@ void KisOpenRasterStackLoadVisitor::loadImage()
dbgFile << ppVar(width) << ppVar(height); dbgFile << ppVar(width) << ppVar(height);
d->image = new KisImage(d->undoStore, width, height, KoColorSpaceRegistry::instance()->rgb8(), "OpenRaster Image (name)"); d->image = new KisImage(d->undoStore, width, height, KoColorSpaceRegistry::instance()->rgb8(), "OpenRaster Image (name)");
for (QDomNode node2 = node.firstChild(); !node2.isNull(); node2 = node2.nextSibling()) { for (QDomNode node2 = node.firstChild(); !node2.isNull(); node2 = node2.nextSibling()) {
if (node2.isElement() && node2.nodeName() == "stack") { // it's the root layer ! if (node2.isElement() && node2.nodeName() == "stack") { // it's the root layer !
QDomElement subelem2 = node2.toElement(); QDomElement subelem2 = node2.toElement();
...@@ -193,10 +192,10 @@ void KisOpenRasterStackLoadVisitor::loadPaintLayer(const QDomElement& elem, KisP ...@@ -193,10 +192,10 @@ void KisOpenRasterStackLoadVisitor::loadPaintLayer(const QDomElement& elem, KisP
dbgFile << "Loading was unsuccessful"; dbgFile << "Loading was unsuccessful";
} }
void KisOpenRasterStackLoadVisitor::loadGroupLayer(const QDomElement& elem, KisGroupLayerSP gL) void KisOpenRasterStackLoadVisitor::loadGroupLayer(const QDomElement& elem, KisGroupLayerSP groupLayer)
{ {
dbgFile << "Loading group layer"; dbFile << "Loading group layer" << d->image;
loadLayerInfo(elem, gL); loadLayerInfo(elem, groupLayer);
for (QDomNode node = elem.firstChild(); !node.isNull(); node = node.nextSibling()) { for (QDomNode node = elem.firstChild(); !node.isNull(); node = node.nextSibling()) {
if (node.isElement()) { if (node.isElement()) {
QDomElement subelem = node.toElement(); QDomElement subelem = node.toElement();
...@@ -211,7 +210,7 @@ void KisOpenRasterStackLoadVisitor::loadGroupLayer(const QDomElement& elem, KisG ...@@ -211,7 +210,7 @@ void KisOpenRasterStackLoadVisitor::loadGroupLayer(const QDomElement& elem, KisG
passThrough = false; passThrough = false;
} }
layer->setPassThroughMode(passThrough); layer->setPassThroughMode(passThrough);
d->image->addNode(layer.data(), gL.data(), 0); d->image->addNode(layer, groupLayer.data(), 0);
loadGroupLayer(subelem, layer); loadGroupLayer(subelem, layer);
} else if (node.nodeName() == "layer") { } else if (node.nodeName() == "layer") {
QString filename = subelem.attribute("src"); QString filename = subelem.attribute("src");
...@@ -224,10 +223,9 @@ void KisOpenRasterStackLoadVisitor::loadGroupLayer(const QDomElement& elem, KisG ...@@ -224,10 +223,9 @@ void KisOpenRasterStackLoadVisitor::loadGroupLayer(const QDomElement& elem, KisG
d->image->setResolution(d->xRes, d->yRes); d->image->setResolution(d->xRes, d->yRes);
// now get the device // now get the device
KisPaintDeviceSP device = pngImage->projection(); KisPaintDeviceSP device = pngImage->projection();
delete pngImage.data();
KisPaintLayerSP layer = new KisPaintLayer(gL->image() , "", opacity * 255, device); KisPaintLayerSP layer = new KisPaintLayer(groupLayer->image() , "", opacity * 255, device);
d->image->addNode(layer.data(), gL.data(), 0); d->image->addNode(layer, groupLayer, 0);
loadPaintLayer(subelem, layer); loadPaintLayer(subelem, layer);
dbgFile << "Loading was successful"; dbgFile << "Loading was successful";
} }
...@@ -241,8 +239,8 @@ void KisOpenRasterStackLoadVisitor::loadGroupLayer(const QDomElement& elem, KisG ...@@ -241,8 +239,8 @@ void KisOpenRasterStackLoadVisitor::loadGroupLayer(const QDomElement& elem, KisG
f = KisFilterRegistry::instance()->value(filterTypeSplit[2]); f = KisFilterRegistry::instance()->value(filterTypeSplit[2]);
} }
KisFilterConfigurationSP kfc = f->defaultConfiguration(); KisFilterConfigurationSP kfc = f->defaultConfiguration();
KisAdjustmentLayerSP layer = new KisAdjustmentLayer(gL->image() , "", kfc, KisSelectionSP(0)); KisAdjustmentLayerSP layer = new KisAdjustmentLayer(groupLayer->image() , "", kfc, KisSelectionSP(0));
d->image->addNode(layer.data(), gL.data(), 0); d->image->addNode(layer.data(), groupLayer.data(), 0);
loadAdjustmentLayer(subelem, layer); loadAdjustmentLayer(subelem, layer);
} else { } else {
......
...@@ -36,7 +36,7 @@ public: ...@@ -36,7 +36,7 @@ public:
void loadImage(); void loadImage();
void loadPaintLayer(const QDomElement& elem, KisPaintLayerSP pL); void loadPaintLayer(const QDomElement& elem, KisPaintLayerSP pL);
void loadAdjustmentLayer(const QDomElement& elem, KisAdjustmentLayerSP pL); void loadAdjustmentLayer(const QDomElement& elem, KisAdjustmentLayerSP pL);
void loadGroupLayer(const QDomElement& elem, KisGroupLayerSP gL); void loadGroupLayer(const QDomElement& elem, KisGroupLayerSP groupLayer);
KisImageSP image(); KisImageSP image();
vKisNodeSP activeNodes(); vKisNodeSP activeNodes();
private: private:
......
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