Code

fix crash on entering invalid lpe name in xml
authorjohanengelen <johanengelen@users.sourceforge.net>
Tue, 23 Sep 2008 21:32:47 +0000 (21:32 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Tue, 23 Sep 2008 21:32:47 +0000 (21:32 +0000)
src/live_effects/lpeobject.cpp
src/sp-lpe-item.cpp

index a73f9ccd6ff1e0c610a3915e2d398922d216402c..ab49de14ff776d35950058b368ccd5a0c062cfae 100644 (file)
@@ -215,12 +215,11 @@ livepatheffect_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscap
         repr = xml_doc->createElement("inkscape:path-effect");
     }
 
-    if ((flags & SP_OBJECT_WRITE_ALL) || lpeobj->effecttype_set)
+    if ((flags & SP_OBJECT_WRITE_ALL) || lpeobj->lpe) {
         repr->setAttribute("effect", Inkscape::LivePathEffect::LPETypeConverter.get_key(lpeobj->effecttype).c_str());
 
-//    lpeobj->lpe->write(repr); something like this.
-
-    lpeobj->lpe->writeParamsToSVG();
+        lpeobj->lpe->writeParamsToSVG();
+    }
 
     if (((SPObjectClass *) livepatheffect_parent_class)->write)
         (* ((SPObjectClass *) livepatheffect_parent_class)->write)(object, xml_doc, repr, flags);
index 56ffd190c00c1a7f8a100b4cd507e70165a5c5d1..89d41be76a5d0d497e5aa4c079b2fd756ba84cdd 100644 (file)
@@ -202,21 +202,20 @@ sp_lpe_item_set(SPObject *object, unsigned int key, gchar const *value)
                     std::string href;
                     while (std::getline(iss, href, ';'))
                     {
-                        Inkscape::LivePathEffect::LPEObjectReference *path_effect_ref;
-                        path_effect_ref = new Inkscape::LivePathEffect::LPEObjectReference(SP_OBJECT(lpeitem));
+                        Inkscape::LivePathEffect::LPEObjectReference *path_effect_ref = new Inkscape::LivePathEffect::LPEObjectReference(SP_OBJECT(lpeitem));
                         path_effect_ref->changedSignal().connect(sigc::bind(sigc::ptr_fun(lpeobject_ref_changed), SP_LPE_ITEM(object)));
                         // Now do the attaching, which emits the changed signal.
                         // Fixme, it should not do this changed signal and updating before all effects are added to the path_effect_list
                         try {
                             path_effect_ref->link(href.c_str());
-                        } catch (Inkscape::BadURIException &e) {
+                        } catch (Inkscape::BadURIException e) {
                             g_warning("BadURIException: %s", e.what());
                             path_effect_ref->unlink();
                             delete path_effect_ref;
                             path_effect_ref = NULL;
                         }
 
-                        if (path_effect_ref) {
+                        if (path_effect_ref && path_effect_ref->lpeobject && path_effect_ref->lpeobject->lpe) {
                             lpeitem->path_effect_list->push_back(path_effect_ref);
                         }
                     }