From 6999558b22096849285acee719ebdeb69f15277d Mon Sep 17 00:00:00 2001 From: kiirala Date: Thu, 6 Dec 2007 19:02:55 +0000 Subject: [PATCH] Fixed several crashes when modifying filter effect parameters with XML editor --- src/helper-fns.h | 15 +++++++++++++-- src/sp-fecolormatrix.cpp | 4 ++-- src/sp-fecomponenttransfer.cpp | 2 +- src/sp-feconvolvematrix.cpp | 2 +- src/sp-fedisplacementmap.cpp | 2 +- src/sp-feflood.cpp | 2 +- src/sp-feimage.cpp | 2 +- src/sp-femergenode.cpp | 2 +- src/sp-femorphology.cpp | 2 +- src/sp-fetile.cpp | 2 +- src/sp-feturbulence.cpp | 2 +- 11 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/helper-fns.h b/src/helper-fns.h index b4976bad4..a4ce8e3b5 100644 --- a/src/helper-fns.h +++ b/src/helper-fns.h @@ -15,12 +15,23 @@ #include -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; diff --git a/src/sp-fecolormatrix.cpp b/src/sp-fecolormatrix.cpp index f13e12809..60d312db1 100644 --- a/src/sp-fecolormatrix.cpp +++ b/src/sp-fecolormatrix.cpp @@ -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 } diff --git a/src/sp-fecomponenttransfer.cpp b/src/sp-fecomponenttransfer.cpp index 1ff231a1f..bb51f55be 100644 --- a/src/sp-fecomponenttransfer.cpp +++ b/src/sp-fecomponenttransfer.cpp @@ -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 } diff --git a/src/sp-feconvolvematrix.cpp b/src/sp-feconvolvematrix.cpp index 84a1a8682..a00a009cb 100644 --- a/src/sp-feconvolvematrix.cpp +++ b/src/sp-feconvolvematrix.cpp @@ -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 } diff --git a/src/sp-fedisplacementmap.cpp b/src/sp-fedisplacementmap.cpp index 4a69f32e4..1eb3f3656 100644 --- a/src/sp-fedisplacementmap.cpp +++ b/src/sp-fedisplacementmap.cpp @@ -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 } diff --git a/src/sp-feflood.cpp b/src/sp-feflood.cpp index a9dcb4e71..b3b9ac1d5 100644 --- a/src/sp-feflood.cpp +++ b/src/sp-feflood.cpp @@ -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 } diff --git a/src/sp-feimage.cpp b/src/sp-feimage.cpp index 9456b5966..7387d2a80 100644 --- a/src/sp-feimage.cpp +++ b/src/sp-feimage.cpp @@ -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 } diff --git a/src/sp-femergenode.cpp b/src/sp-femergenode.cpp index 6098fb7b0..b886295a8 100644 --- a/src/sp-femergenode.cpp +++ b/src/sp-femergenode.cpp @@ -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 } diff --git a/src/sp-femorphology.cpp b/src/sp-femorphology.cpp index 22c6de038..77d76f7dc 100644 --- a/src/sp-femorphology.cpp +++ b/src/sp-femorphology.cpp @@ -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 } diff --git a/src/sp-fetile.cpp b/src/sp-fetile.cpp index 472c92139..61cb68bda 100644 --- a/src/sp-fetile.cpp +++ b/src/sp-fetile.cpp @@ -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 } diff --git a/src/sp-feturbulence.cpp b/src/sp-feturbulence.cpp index 7c5091c54..d95a921f1 100644 --- a/src/sp-feturbulence.cpp +++ b/src/sp-feturbulence.cpp @@ -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 } -- 2.30.2