Code

Added test script I thought was already added.
[inkscape.git] / src / filters / convolvematrix.cpp
index a5a40811c6d14df094703618d0c06bd65f5463cc..3e1c36f0ad994afd8f6d3cc3edfc88a174a658c4 100644 (file)
@@ -191,8 +191,10 @@ sp_feConvolveMatrix_set(SPObject *object, unsigned int key, gchar const *value)
                 read_num = helperfns_read_number(value);
                 if (read_num == 0) {
                     // This should actually be an error, but given our UI it is more useful to simply set divisor to the default.
-                    for (unsigned int i = 0; i< feConvolveMatrix->kernelMatrix.size(); i++)
-                        read_num += feConvolveMatrix->kernelMatrix[i];
+                    if (feConvolveMatrix->kernelMatrixIsSet) {
+                        for (unsigned int i = 0; i< feConvolveMatrix->kernelMatrix.size(); i++)
+                            read_num += feConvolveMatrix->kernelMatrix[i];
+                    }
                     if (read_num == 0) read_num = 1;
                     if (feConvolveMatrix->divisorIsSet || feConvolveMatrix->divisor!=read_num) {
                         feConvolveMatrix->divisorIsSet = false;
@@ -202,6 +204,7 @@ sp_feConvolveMatrix_set(SPObject *object, unsigned int key, gchar const *value)
                 } else if (!feConvolveMatrix->divisorIsSet || feConvolveMatrix->divisor!=read_num) {
                     feConvolveMatrix->divisorIsSet = true;
                     feConvolveMatrix->divisor = read_num;
+                    object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
                 }
             }
             break;
@@ -294,16 +297,13 @@ sp_feConvolveMatrix_update(SPObject *object, SPCtx *ctx, guint flags)
 static Inkscape::XML::Node *
 sp_feConvolveMatrix_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags)
 {
-    // Inkscape-only object, not copied during an "plain SVG" dump:
-    if (flags & SP_OBJECT_WRITE_EXT) {
-        if (repr) {
-            // is this sane?
-            //repr->mergeFrom(SP_OBJECT_REPR(object), "id");
-        } else {
-            repr = SP_OBJECT_REPR(object)->duplicate(doc);
-        }
+    /* TODO: Don't just clone, but create a new repr node and write all
+     * relevant values into it */
+    if (!repr) {
+        repr = SP_OBJECT_REPR(object)->duplicate(doc);
     }
 
+
     if (((SPObjectClass *) feConvolveMatrix_parent_class)->write) {
         ((SPObjectClass *) feConvolveMatrix_parent_class)->write(object, doc, repr, flags);
     }