Code

Fixed several crashes when modifying filter effect parameters with XML editor
authorkiirala <kiirala@users.sourceforge.net>
Thu, 6 Dec 2007 19:02:55 +0000 (19:02 +0000)
committerkiirala <kiirala@users.sourceforge.net>
Thu, 6 Dec 2007 19:02:55 +0000 (19:02 +0000)
src/helper-fns.h
src/sp-fecolormatrix.cpp
src/sp-fecomponenttransfer.cpp
src/sp-feconvolvematrix.cpp
src/sp-fedisplacementmap.cpp
src/sp-feflood.cpp
src/sp-feimage.cpp
src/sp-femergenode.cpp
src/sp-femorphology.cpp
src/sp-fetile.cpp
src/sp-feturbulence.cpp

index b4976bad44f044cca86ab35561f5a95f43e3ff80..a4ce8e3b5add02b4229fc4c5780140b071f7d000 100644 (file)
 
 #include <sstream>
 
-inline double helperfns_read_number(gchar const *value) {
+// calling helperfns_read_number(string, false), it's not obvious, what
+// that false stands for. helperfns_read_number(string, HELPERFNS_NO_WARNING)
+// can be more clear.
+#define HELPERFNS_NO_WARNING false
+
+/* Setting warning to false disables conversion error warnings from
+ * this function. This can be useful in places, where the input type
+ * is not known beforehand. For example, see sp_feColorMatrix_set in
+ * sp-fecolormatrix.cpp */
+inline double helperfns_read_number(gchar const *value, bool warning = true) {
     if (!value) return 0;
     char *end;
     double ret = g_ascii_strtod(value, &end);
     if (*end) {
-        g_warning("Unable to convert \"%s\" to number", value);
+        if (warning) {
+            g_warning("Unable to convert \"%s\" to number", value);
+        }
         // We could leave this out, too. If strtod can't convert
         // anything, it will return zero.
         ret = 0;
index f13e12809ff9f48657f28e6e8ac0e2f0b8ee3bd2..60d312db1eee97502368e2af03d1d7d286c3ae2e 100644 (file)
@@ -151,7 +151,7 @@ sp_feColorMatrix_set(SPObject *object, unsigned int key, gchar const *str)
         case SP_ATTR_VALUES:
             if (str){
                 feColorMatrix->values = helperfns_read_vector(str, 20);
-                feColorMatrix->value = helperfns_read_number(str);
+                feColorMatrix->value = helperfns_read_number(str, HELPERFNS_NO_WARNING);
                 object->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
             }
             break;
@@ -190,7 +190,7 @@ sp_feColorMatrix_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
     if (flags & SP_OBJECT_WRITE_EXT) {
         if (repr) {
             // is this sane?
-            repr->mergeFrom(SP_OBJECT_REPR(object), "id");
+            //repr->mergeFrom(SP_OBJECT_REPR(object), "id");
         } else {
             repr = SP_OBJECT_REPR(object)->duplicate(NULL); // FIXME
         }
index 1ff231a1ff1e32e8228ba3ae1e6a82a6236c1706..bb51f55bed0f416a1f35f25d642af1700343b22e 100644 (file)
@@ -193,7 +193,7 @@ sp_feComponentTransfer_write(SPObject *object, Inkscape::XML::Node *repr, guint
     if (flags & SP_OBJECT_WRITE_EXT) {
         if (repr) {
             // is this sane?
-            repr->mergeFrom(SP_OBJECT_REPR(object), "id");
+            //repr->mergeFrom(SP_OBJECT_REPR(object), "id");
         } else {
             repr = SP_OBJECT_REPR(object)->duplicate(NULL); // FIXME
         }
index 84a1a8682a7ac217f05aa3c47f66288865d667e4..a00a009cb2329c420a30ede97f1f18d6578ee9f0 100644 (file)
@@ -288,7 +288,7 @@ sp_feConvolveMatrix_write(SPObject *object, Inkscape::XML::Node *repr, guint fla
     if (flags & SP_OBJECT_WRITE_EXT) {
         if (repr) {
             // is this sane?
-            repr->mergeFrom(SP_OBJECT_REPR(object), "id");
+            //repr->mergeFrom(SP_OBJECT_REPR(object), "id");
         } else {
             repr = SP_OBJECT_REPR(object)->duplicate(NULL); // FIXME
         }
index 4a69f32e4049e373bb186c272b98572ab619e86d..1eb3f3656c5520b4847cd9ec74d70756bdf00f88 100644 (file)
@@ -227,7 +227,7 @@ sp_feDisplacementMap_write(SPObject *object, Inkscape::XML::Node *repr, guint fl
     if (flags & SP_OBJECT_WRITE_EXT) {
         if (repr) {
             // is this sane?
-            repr->mergeFrom(SP_OBJECT_REPR(object), "id");
+            //repr->mergeFrom(SP_OBJECT_REPR(object), "id");
         } else {
             repr = SP_OBJECT_REPR(object)->duplicate(NULL); // FIXME
         }
index a9dcb4e71c40d81452b55676646812fec12a7e8f..b3b9ac1d50795ea04c1202e0e95b3c02891ea15b 100644 (file)
@@ -151,7 +151,7 @@ sp_feFlood_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
     if (flags & SP_OBJECT_WRITE_EXT) {
         if (repr) {
             // is this sane?
-            repr->mergeFrom(SP_OBJECT_REPR(object), "id");
+            //repr->mergeFrom(SP_OBJECT_REPR(object), "id");
         } else {
             repr = SP_OBJECT_REPR(object)->duplicate(NULL); // FIXME
         }
index 9456b5966928a5c9fe752b281e7ce7c9b41bdb73..7387d2a80579d2b36766e87f8e2b556908aa21f1 100644 (file)
@@ -186,7 +186,7 @@ sp_feImage_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
     if (flags & SP_OBJECT_WRITE_EXT) {
         if (repr) {
             // is this sane?
-            repr->mergeFrom(SP_OBJECT_REPR(object), "id");
+            //repr->mergeFrom(SP_OBJECT_REPR(object), "id");
         } else {
             repr = SP_OBJECT_REPR(object)->duplicate(NULL); // FIXME
         }
index 6098fb7b011af1924c0872f0db8704acd9c50c5e..b886295a848b30f3644ef3cd15a854fb084970b5 100644 (file)
@@ -151,7 +151,7 @@ sp_feMergeNode_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
     if (flags & SP_OBJECT_WRITE_EXT) {
         if (repr) {
             // is this sane?
-            repr->mergeFrom(SP_OBJECT_REPR(object), "id");
+            //repr->mergeFrom(SP_OBJECT_REPR(object), "id");
         } else {
             repr = SP_OBJECT_REPR(object)->duplicate(NULL); // FIXME
         }
index 22c6de038e48b0a1442060792fd6f941aa9b2d41..77d76f7dccc376f48db4d291c43e1369d1ef7338 100644 (file)
@@ -184,7 +184,7 @@ sp_feMorphology_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
     if (flags & SP_OBJECT_WRITE_EXT) {
         if (repr) {
             // is this sane?
-            repr->mergeFrom(SP_OBJECT_REPR(object), "id");
+            //repr->mergeFrom(SP_OBJECT_REPR(object), "id");
         } else {
             repr = SP_OBJECT_REPR(object)->duplicate(NULL); // FIXME
         }
index 472c921399258bd67fa2009fce44d9b6da8611d1..61cb68bdafb73028a661bbfa04ab9fbf64f27b58 100644 (file)
@@ -151,7 +151,7 @@ sp_feTile_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
     if (flags & SP_OBJECT_WRITE_EXT) {
         if (repr) {
             // is this sane?
-            repr->mergeFrom(SP_OBJECT_REPR(object), "id");
+            //repr->mergeFrom(SP_OBJECT_REPR(object), "id");
         } else {
             repr = SP_OBJECT_REPR(object)->duplicate(NULL); // FIXME
         }
index 7c5091c5412f5ed0ec75d2a96bf999fdd9f2607e..d95a921f1507577e807193beadaa1726a6df266c 100644 (file)
@@ -236,7 +236,7 @@ sp_feTurbulence_write(SPObject *object, Inkscape::XML::Node *repr, guint flags)
     if (flags & SP_OBJECT_WRITE_EXT) {
         if (repr) {
             // is this sane?
-            repr->mergeFrom(SP_OBJECT_REPR(object), "id");
+            //repr->mergeFrom(SP_OBJECT_REPR(object), "id");
         } else {
             repr = SP_OBJECT_REPR(object)->duplicate(NULL); // FIXME
         }