Code

fix crash bug 195312
authorjohanengelen <johanengelen@users.sourceforge.net>
Tue, 3 Mar 2009 20:30:55 +0000 (20:30 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Tue, 3 Mar 2009 20:30:55 +0000 (20:30 +0000)
src/filters/image.cpp

index 32afe5db66fecf106d3f4797d4fd67bd5e1e384b..eda815d8d881f3d785e6ec72b05757dd54180e13 100644 (file)
@@ -140,7 +140,6 @@ sp_feImage_set(SPObject *object, unsigned int key, gchar const *value)
 {
     SPFeImage *feImage = SP_FEIMAGE(object);
     (void)feImage;
-    Inkscape::URI *SVGElem_uri = NULL;
     switch(key) {
     /*DEAL WITH SETTING ATTRIBUTES HERE*/
         case SP_ATTR_XLINK_HREF:
@@ -150,16 +149,19 @@ sp_feImage_set(SPObject *object, unsigned int key, gchar const *value)
             feImage->href = (value) ? g_strdup (value) : NULL;
             if (!feImage->href) return;
             try{
-                SVGElem_uri = new Inkscape::URI(feImage->href);
+                Inkscape::URI SVGElem_uri(feImage->href);
                 feImage->SVGElemRef = new Inkscape::URIReference(feImage->document);
                 feImage->from_element = true;
-                feImage->SVGElemRef->attach(*SVGElem_uri);
-                feImage->SVGElem = SP_ITEM(feImage->SVGElemRef->getObject());
-
-                delete SVGElem_uri;
-                feImage->_modified_connection = ((SPObject*) feImage->SVGElem)->connectModified(sigc::bind(sigc::ptr_fun(&sp_feImage_elem_modified), object));
-                object->requestModified(SP_OBJECT_MODIFIED_FLAG);
-                break;
+                feImage->SVGElemRef->attach(SVGElem_uri);
+                if (SPObject *elemref = feImage->SVGElemRef->getObject()) {
+                    feImage->SVGElem = SP_ITEM(elemref);
+
+                    feImage->_modified_connection = ((SPObject*) feImage->SVGElem)->connectModified(sigc::bind(sigc::ptr_fun(&sp_feImage_elem_modified), object));
+                    object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+                    break;
+                } else {
+                    g_warning("SVG element URI was not found in the document while loading feImage");
+                }
             }
             catch(const Inkscape::UnsupportedURIException & e)
             {