Commit 5df8969b authored by Tusooa Zhu's avatar Tusooa Zhu

Fix the three broken tests

parent 35f6ed75
......@@ -44,8 +44,8 @@ KoShapeContainer::Private::~Private()
}
KoShapeContainer::Private::Private(const KoShapeContainer::Private &rhs, KoShapeContainer *q)
: shapeInterface(q),
model(0)
: shapeInterface(q)
, model(0)
{
Q_UNUSED(rhs);
}
......@@ -61,17 +61,6 @@ KoShapeContainer::KoShapeContainer(const KoShapeContainer &rhs)
: KoShape(rhs)
, d(new Private(*(rhs.d.data()), this))
{
// HACK ALERT: the shapes are copied inside the model,
// but we still need to connect the to the
// hierarchy here!
if (d->model) {
Q_FOREACH (KoShape *shape, d->model->shapes()) {
if (shape) { // Note: shape can be 0 because not all shapes
// implement cloneShape, e.g. the text shape.
shape->setParent(this);
}
}
}
}
KoShapeContainer::~KoShapeContainer()
......@@ -175,6 +164,22 @@ void KoShapeContainer::setModel(KoShapeContainerModel *model)
d->model = model;
}
void KoShapeContainer::setModelInit(KoShapeContainerModel *model)
{
setModel(model);
// HACK ALERT: the shapes are copied inside the model,
// but we still need to connect the to the
// hierarchy here!
if (d->model) {
Q_FOREACH (KoShape *shape, d->model->shapes()) {
if (shape) { // Note: shape can be 0 because not all shapes
// implement cloneShape, e.g. the text shape.
shape->setParent(this);
}
}
}
}
KoShapeContainer::ShapeInterface *KoShapeContainer::shapeInterface()
{
return &d->shapeInterface;
......
......@@ -203,6 +203,10 @@ protected:
* set the model for this container
*/
void setModel(KoShapeContainerModel *model);
/**
* set the model, and take control of all its children
*/
void setModelInit(KoShapeContainerModel *model);
public:
......
......@@ -102,7 +102,7 @@ KoShapeGroup::KoShapeGroup()
: KoShapeContainer()
, d(new Private)
{
setModel(new ShapeGroupContainerModel(this));
setModelInit(new ShapeGroupContainerModel(this));
}
KoShapeGroup::KoShapeGroup(const KoShapeGroup &rhs)
......@@ -111,7 +111,7 @@ KoShapeGroup::KoShapeGroup(const KoShapeGroup &rhs)
{
ShapeGroupContainerModel *otherModel = dynamic_cast<ShapeGroupContainerModel*>(rhs.model());
KIS_ASSERT_RECOVER_RETURN(otherModel);
setModel(new ShapeGroupContainerModel(*otherModel, this));
setModelInit(new ShapeGroupContainerModel(*otherModel, this));
}
KoShapeGroup::~KoShapeGroup()
......
......@@ -308,7 +308,7 @@ KoSvgTextChunkShape::KoSvgTextChunkShape(const KoSvgTextChunkShape &rhs)
if (rhs.model()) {
SimpleShapeContainerModel *otherModel = dynamic_cast<SimpleShapeContainerModel*>(rhs.model());
KIS_ASSERT_RECOVER_RETURN(otherModel);
setModel(new SimpleShapeContainerModel(*otherModel));
setModelInit(new SimpleShapeContainerModel(*otherModel));
}
// XXX: this will immediately lead to a detach
d->layoutInterface.reset(new KoSvgTextChunkShape::Private::LayoutInterface(this));
......
......@@ -97,6 +97,10 @@ TextShape::TextShape(const TextShape &rhs)
, m_clip(rhs.m_clip)
{
/// TODO: we need to clone the model
KoTextShapeContainerModel *origModel = dynamic_cast<KoTextShapeContainerModel *>(rhs.model());
if (origModel) {
setModel(new KoTextShapeContainerModel());
}
// XXX: ?
//reinterpret_cast<KoShapeContainerPrivate*>(rhs.d_ptr)->model = new KoTextShapeContainerModel();
......
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