Code

Patch by Alex Leone to fix crash with recursive masks from 190130, I also added him...
authorJosh Andler <scislac@gmail.com>
Sat, 9 Jan 2010 20:05:26 +0000 (12:05 -0800)
committerJosh Andler <scislac@gmail.com>
Sat, 9 Jan 2010 20:05:26 +0000 (12:05 -0800)
AUTHORS
src/sp-mask.h

diff --git a/AUTHORS b/AUTHORS
index 7abce1c56d157a695ae9a9db9a844545d846f9f4..7e042f9f8d2295dcefc6c9827ff3ba673f0fe4f4 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -80,6 +80,7 @@ Adrian Knoth
 Krzysztof Kosiński
 Petr Kovar
 Benoît Lavorata
+Alex Leone
 Julien Leray
 Raph Levien
 Diederik van Lierop
index d5bddd332861f2f18efdbe0e3b4d8013ce1013ea..0b995f0ce85ded208bd1b6bf6da4d1486ad077e9 100644 (file)
@@ -26,6 +26,7 @@ class SPMaskView;
 #include "libnr/nr-forward.h"
 #include "sp-object-group.h"
 #include "uri-references.h"
+#include "xml/node.h"
 
 struct SPMask : public SPObjectGroup {
        unsigned int maskUnits_set : 1;
@@ -50,8 +51,39 @@ public:
                return (SPMask *)URIReference::getObject();
        }
 protected:
+    /**
+     * If the owner element of this reference (the element with <... mask="...">)
+     * is a child of the mask it refers to, return false.
+     * \return false if obj is not a mask or if obj is a parent of this
+     *         reference's owner element.  True otherwise.
+     */
        virtual bool _acceptObject(SPObject *obj) const {
-               return SP_IS_MASK(obj);
+               if (!SP_IS_MASK(obj)) {
+                   return false;
+           }
+           SPObject * const owner = this->getOwner();
+        if (obj->isAncestorOf(owner)) {
+            Inkscape::XML::Node * const owner_repr = owner->repr;
+            Inkscape::XML::Node * const obj_repr = obj->repr;
+            gchar const * owner_name = NULL;
+            gchar const * owner_mask = NULL;
+            gchar const * obj_name = NULL;
+            gchar const * obj_id = NULL;
+            if (owner_repr != NULL) {
+                owner_name = owner_repr->name();
+                owner_mask = owner_repr->attribute("mask");
+            }
+            if (obj_repr != NULL) {
+                obj_name = obj_repr->name();
+                obj_id = obj_repr->attribute("id");
+            }
+            g_warning("Ignoring recursive mask reference "
+                      "<%s mask=\"%s\"> in <%s id=\"%s\">",
+                      owner_name, owner_mask,
+                      obj_name, obj_id);
+            return false;
+        }
+        return true;
        }
 };