Code

fix stupid crash, make get_item const
authorbuliabyak <buliabyak@users.sourceforge.net>
Sun, 20 Jul 2008 16:36:22 +0000 (16:36 +0000)
committerbuliabyak <buliabyak@users.sourceforge.net>
Sun, 20 Jul 2008 16:36:22 +0000 (16:36 +0000)
src/shape-editor.cpp
src/shape-editor.h

index 77419d1d10393a6cc17a06614f5292a7c267bbcb..27e1dd399fbee31c23725da7a837c7056b9ca53a 100644 (file)
@@ -130,8 +130,8 @@ void ShapeEditor::decrement_local_change (SubType type) {
     }
 }
 
-SPItem *ShapeEditor::get_item (SubType type) {
-    SPItem *item = NULL;
+const SPItem *ShapeEditor::get_item (SubType type) {
+    const SPItem *item = NULL;
     switch (type) {
         case SH_NODEPATH:
             if (this->has_nodepath()) {
@@ -140,7 +140,7 @@ SPItem *ShapeEditor::get_item (SubType type) {
             break;
         case SH_KNOTHOLDER:
             if (this->has_knotholder()) {
-                item = this->nodepath->item;
+                item = this->knotholder->getItem();
             }
             break;
     }
@@ -329,8 +329,8 @@ void ShapeEditor::reset_item (SubType type, bool keep_knotholder)
             break;
         case SH_KNOTHOLDER:
             if (this->knotholder) {
-                SPItem * item = get_item(SH_KNOTHOLDER);
-                set_item(item, SH_KNOTHOLDER, keep_knotholder);
+                const SPItem * item = get_item(SH_KNOTHOLDER);
+                set_item((SPItem *) item, SH_KNOTHOLDER, keep_knotholder);
             }
             break;
     }
@@ -350,7 +350,7 @@ bool ShapeEditor::is_over_stroke (NR::Point event_p, bool remember) {
     if (!this->nodepath)
         return false; // no stroke in knotholder
 
-    SPItem *item = get_item(SH_NODEPATH);
+    const SPItem *item = get_item(SH_NODEPATH);
 
     //Translate click point into proper coord system
     this->curvepoint_doc = desktop->w2d(event_p);
index 9181027614aed152e658d941caf8fc3fe283d3c2..2a6da68c3b6f9f72622a6c6649fd9e4e1db54f51 100644 (file)
@@ -44,7 +44,7 @@ public:
     void reset_item (SubType type, bool keep_knotholder = true);
     void unset_item (SubType type, bool keep_knotholder = false);
 
-    SPItem *get_item (SubType type);
+    const SPItem *get_item (SubType type);
 
     bool has_nodepath ();
     bool has_knotholder ();