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

Fix the three broken tests

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