Code

Patch from codedread. Prevents rendering of title/desc/metadata elements in text...
[inkscape.git] / src / shape-editor.cpp
index 49d8a2a1442b51297739151851908313f072f7ab..91909d8505fdae651ef80a5a552d3d7c4c972889 100644 (file)
@@ -82,7 +82,7 @@ void ShapeEditor::unset_item() {
     }
 
     if (this->knotholder) {
-        sp_knot_holder_destroy(this->knotholder);
+        delete this->knotholder;
         this->knotholder = NULL;
     }
 }
@@ -96,18 +96,13 @@ bool ShapeEditor::has_knotholder () {
 }
 
 bool ShapeEditor::has_local_change () {
-    if (this->nodepath)
-        return (this->nodepath->local_change != 0);
-    else if (this->knotholder)
-        return (this->knotholder->local_change != 0);
-    else
-        return false;
+    return ((this->nodepath && this->nodepath->local_change) ||
+            (this->knotholder && this->knotholder->local_change != 0));
 }
 
 void ShapeEditor::decrement_local_change () {
-    if (this->nodepath) {
-        if (this->nodepath->local_change > 0)
-            this->nodepath->local_change--;
+    if (this->nodepath && this->nodepath->local_change > 0) {
+        this->nodepath->local_change--;
     } else if (this->knotholder) {
         this->knotholder->local_change = FALSE;
     }
@@ -192,19 +187,15 @@ void ShapeEditor::set_item(SPItem *item) {
     if (item) {
         if (SP_IS_LPE_ITEM(item)) {
             SPLPEItem *lpeitem = SP_LPE_ITEM(item);
-            if ( !sp_lpe_item_get_current_lpe(lpeitem) ||   // if returns NULL, the whole expression evaluates to true and C++ will not call the otherwise crashing 2 functions below
-                 !sp_lpe_item_get_current_lpe(lpeitem)->isVisible() ||
-                 !sp_lpe_item_get_current_lpe(lpeitem)->providesKnotholder() )
+            Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(lpeitem);
+            if (!(lpe && lpe->isVisible() && lpe->providesKnotholder())) {
                 // only create nodepath if the item either doesn't have an LPE
                 // or the LPE is invisible or it doesn't provide a knotholder itself
-            {
-                this->nodepath =
-                    sp_nodepath_new(desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0));
+                this->nodepath = sp_nodepath_new(desktop, item,
+                                                 (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0));
+            } else if (lpe && lpe->isVisible()) {
+                sp_lpe_item_add_temporary_canvasitems(lpeitem, desktop);
             }
-        } else {
-            // only create nodepath if the item either doesn't have an LPE: no fear the item cannot have an LPE
-            this->nodepath =
-                sp_nodepath_new(desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0));
         }
 
         if (this->nodepath) {
@@ -257,7 +248,7 @@ void ShapeEditor::set_item_lpe_path_parameter(SPItem *item, SPObject *lpeobject,
 *  pass a new knotholder to ShapeEditor to manage (and delete)
 */
 void
-ShapeEditor::set_knotholder(SPKnotHolder * knot_holder)
+ShapeEditor::set_knotholder(KnotHolder * knot_holder)
 {
     unset_item();
 
@@ -303,7 +294,7 @@ bool ShapeEditor::is_over_stroke (NR::Point event_p, bool remember) {
 
     //Translate click point into proper coord system
     this->curvepoint_doc = desktop->w2d(event_p);
-    this->curvepoint_doc *= sp_item_dt2i_affine(item);
+    this->curvepoint_doc *= from_2geom(sp_item_dt2i_affine(item));
 
     sp_nodepath_ensure_livarot_path(this->nodepath);
 
@@ -321,9 +312,9 @@ bool ShapeEditor::is_over_stroke (NR::Point event_p, bool remember) {
         (( !SP_OBJECT_STYLE(item)->stroke.isNone() ?
            desktop->current_zoom() *
            SP_OBJECT_STYLE (item)->stroke_width.computed * 0.5 *
-           NR::expansion(sp_item_i2d_affine(item))
+           NR::expansion(from_2geom(sp_item_i2d_affine(item)))
          : 0.0)
-         + prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100)) /NR::expansion(sp_item_i2d_affine(item)); 
+         + prefs_get_int_attribute_limited("options.dragtolerance", "value", 0, 0, 100)) /NR::expansion(from_2geom(sp_item_i2d_affine(item))); 
     bool close = (NR::L2 (delta) < stroke_tolerance);
 
     if (remember && close) {