Commit 427ff8e4 authored by Cyrille Berger's avatar Cyrille Berger

Fix infinite recursion when connecting to an artistic text.


svn path=/branches/koffice/2.0/koffice/; revision=960618
parent bcb16568
......@@ -288,24 +288,36 @@ void KoConnectionShape::updatePath(const QSizeF &size)
normalize();
}
void KoConnectionShape::setConnection1(KoShape * shape1, int connectionPointIndex1)
bool KoConnectionShape::setConnection1(KoShape * shape1, int connectionPointIndex1)
{
// refuse to connect to a shape that depends on us (e.g. a artistic text shape)
if (hasDependee(shape1))
return false;
if (d->shape1)
d->shape1->removeDependee(this);
d->shape1 = shape1;
if (d->shape1)
d->shape1->addDependee(this);
d->connectionPointIndex1 = connectionPointIndex1;
return true;
}
void KoConnectionShape::setConnection2(KoShape * shape2, int connectionPointIndex2)
bool KoConnectionShape::setConnection2(KoShape * shape2, int connectionPointIndex2)
{
// refuse to connect to a shape that depends on us (e.g. a artistic text shape)
if (hasDependee(shape2))
return false;
if (d->shape2)
d->shape2->removeDependee(this);
d->shape2 = shape2;
if (d->shape2)
d->shape2->addDependee(this);
d->connectionPointIndex2 = connectionPointIndex2;
return true;
}
KoConnection KoConnectionShape::connection1() const
......
......@@ -60,10 +60,10 @@ public:
virtual bool hitTest(const QPointF &position) const;
/// Sets the first shape the connector is connected to
void setConnection1(KoShape * shape1, int connectionPointIndex);
bool setConnection1(KoShape * shape1, int connectionPointIndex);
/// Sets the second shape the connector is connected to
void setConnection2(KoShape * shape2, int connectionPointIndex);
bool setConnection2(KoShape * shape2, int connectionPointIndex);
/// Returns the connection to the first shape
KoConnection connection1() const;
......
......@@ -1253,6 +1253,11 @@ void KoShape::removeDependee(KoShape * shape)
d->dependees.removeAt(index);
}
bool KoShape::hasDependee(KoShape * shape) const
{
return d->dependees.contains(shape);
}
void KoShape::notifyShapeChanged(KoShape * shape, ChangeType type)
{
Q_UNUSED(shape);
......
......@@ -885,6 +885,9 @@ protected:
*/
void notifyChangedShape(ChangeType type);
/// Returns if the given shape is dependent on this shape
bool hasDependee(KoShape * shape) const;
private:
friend class KoShapeManager;
void addShapeManager(KoShapeManager * manager);
......
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