[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    koffice/libs/flake
From:       Jan Hambrecht <jaham () gmx ! net>
Date:       2009-04-24 22:53:22
Message-ID: 1240613602.070558.12735.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 958899 by jaham:

fix infinite recursion when accidently connecting to an artistic text
shape that is put on the connection shape we are trying to connect.
both shape were notifying each other of changes, adapting to these 
change and thus causing a new change which the other gets notified of...

please review if that can be backported to branch

CCMAIL:koffice-devel@kde.org



 M  +14 -2     KoConnectionShape.cpp  
 M  +2 -2      KoConnectionShape.h  
 M  +5 -0      KoShape.cpp  
 M  +3 -0      KoShape.h  


--- trunk/koffice/libs/flake/KoConnectionShape.cpp #958898:958899
@@ -286,24 +286,36 @@
     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
--- trunk/koffice/libs/flake/KoConnectionShape.h #958898:958899
@@ -62,10 +62,10 @@
     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;
--- trunk/koffice/libs/flake/KoShape.cpp #958898:958899
@@ -1253,6 +1253,11 @@
         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);
--- trunk/koffice/libs/flake/KoShape.h #958898:958899
@@ -895,6 +895,9 @@
      * @param type the change type
      */
     void notifyChangedShape(ChangeType type);
+    
+    /// Returns if the given shape is dependent on this shape
+    bool hasDependee(KoShape * shape) const;
 
 private:
     friend class KoShapeManager;
_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic