Commit afafb3cb authored by Cyrille Berger's avatar Cyrille Berger

fix memory corruption (I think KoShape::setParent should be the one to make...

fix memory corruption (I think KoShape::setParent should be the one to make the call to KoShapeContainer::addChild/removeChild)

svn path=/trunk/koffice/; revision=619196
parent 2bc55091
......@@ -291,8 +291,9 @@ KisDoc2::KisDoc2(QWidget *parentWidget, QObject *parent, bool singleViewMode)
KisDoc2::~KisDoc2()
{
kDebug() << "There are " << m_d->layerShapes.size() << " shapes" << endl;
foreach( KoShape* shape, m_d->layerShapes ) {
removeShape( shape );
removeShape( shape);
delete shape; // XXX: What happes with stuff on the
// clipboard? And how about undo information?
}
......@@ -1378,6 +1379,7 @@ void KisDoc2::removeShape( KoShape* shape )
kDebug() << ">>>>> KisDoc2::removeShape: " << shape->shapeId() << ", active layer: " << m_d->activeLayerShape() << endl;
KoShapeContainer * container = shape->parent();
kDebug() << "parent is " << container << endl;
if ( container ) {
container->removeChild( shape );
......@@ -1446,6 +1448,7 @@ void KisDoc2::slotLayerAdded( KisLayerSP layer )
// Put the layer in the right place in the hierarchy
shape->setParent( parent );
parent->addChild(shape);
m_d->layerShapes[layer] = shape;
......
......@@ -41,6 +41,7 @@ KisLayerShape::KisLayerShape( KoShapeContainer * parent, KisLayerSP layer)
setShapeId( KIS_LAYER_SHAPE_ID );
setParent( parent );
parent->addChild(this);
}
KisLayerShape::~KisLayerShape()
......@@ -91,4 +92,5 @@ void KisLayerShape::addChild( KoShape * shape )
kDebug() << "Can only add mask shapes as children to layer shapes!\n";
return;
}
KoShapeContainer::addChild(shape);
}
......@@ -32,7 +32,12 @@ KoShapeContainer::KoShapeContainer(KoShapeContainerModel *model)
}
KoShapeContainer::~KoShapeContainer() {
delete m_children;
if(m_children)
{
foreach (KoShape *shape, m_children->iterator())
shape->setParent(0);
delete m_children;
}
}
void KoShapeContainer::addChild(KoShape *shape) {
......
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