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

List:       koffice-devel
Subject:    koffice
From:       Jan Hambrecht <jaham () gmx ! net>
Date:       2009-04-25 20:55:12
Message-ID: 1240692912.563174.5126.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 959264 by jaham:

fix circular dependencies on a lower lever in KoShape::addDependee
this is a follow-up commit to r958899

please review

CCMAIL:koffice-devel@kde.org



 M  +11 -3     libs/flake/KoShape.cpp  
 M  +11 -3     libs/flake/KoShape.h  
 M  +5 -2      plugins/artistictextshape/ArtisticTextShape.cpp  


--- trunk/koffice/libs/flake/KoShape.cpp #959263:959264
@@ -2,7 +2,7 @@
    Copyright (C) 2006 Casper Boemann Rasmussen <cbr@boemann.dk>
    Copyright (C) 2006-2009 Thomas Zander <zander@kde.org>
    Copyright (C) 2006-2008 Thorsten Zachmann <zachmann@kde.org>
-   Copyright (C) 2007 Jan Hambrecht <jaham@gmx.net>
+   Copyright (C) 2007-2009 Jan Hambrecht <jaham@gmx.net>
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
@@ -1239,11 +1239,19 @@
     return absoluteTransformation(0).inverted().mapRect(rect);
 }
 
-
-void KoShape::addDependee(KoShape * shape)
+bool KoShape::addDependee(KoShape * shape)
 {
+    if (! shape)
+        return false;
+    
+    // refuse to establish a circular dependency
+    if (shape->hasDependee(this))
+        return false;
+    
     if (! d->dependees.contains(shape))
         d->dependees.append(shape);
+    
+    return true;
 }
 
 void KoShape::removeDependee(KoShape * shape)
--- trunk/koffice/libs/flake/KoShape.h #959263:959264
@@ -2,7 +2,7 @@
    Copyright (C) 2006-2008 Thorsten Zachmann <zachmann@kde.org>
    Copyright (C) 2006, 2008 Casper Boemann <cbr@boemann.dk>
    Copyright (C) 2006-2009 Thomas Zander <zander@kde.org>
-   Copyright (C) 2007 Jan Hambrecht <jaham@gmx.net>
+   Copyright (C) 2007-2009 Jan Hambrecht <jaham@gmx.net>
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
@@ -732,8 +732,16 @@
     /// Removes connection point with given index
     void removeConnectionPoint(int index);
 
-    /// Adds a shape which depends on this shape
-    void addDependee(KoShape * shape);
+    /**
+     * Adds a shape which depends on this shape.
+     *
+     * If this shape already depends on the given shape, establishing the
+     * dependency is refused to prevent circular dependencies.
+     *
+     * @param shape the shape which depends on this shape
+     * @return true if dependency could be established, else false
+     */
+    bool addDependee(KoShape * shape);
 
     /// Removes as shape depending on this shape
     void removeDependee(KoShape * shape);
--- trunk/koffice/plugins/artistictextshape/ArtisticTextShape.cpp #959263:959264
@@ -1,5 +1,5 @@
 /* This file is part of the KDE project
- * Copyright (C) 2007-2008 Jan Hambrecht <jaham@gmx.net>
+ * Copyright (C) 2007-2009 Jan Hambrecht <jaham@gmx.net>
  * Copyright (C) 2008 Rob Buis <buis@kde.org>
  *
  * This library is free software; you can redistribute it and/or
@@ -419,10 +419,13 @@
     if( path->outline().isEmpty() )
         return false;
 
+    if( ! path->addDependee( this ) )
+        return false;
+
     update();
 
     m_path = path;
-    m_path->addDependee( this );
+
     // use the paths outline converted to document coordinates as the baseline
     m_baseline = m_path->absoluteTransformation(0).map( m_path->outline() );
 
_______________________________________________
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