From 28d72dc639e8d1423870a02b6f6fec1bf8b9f979 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 2 Jun 2008 20:22:58 +0000 Subject: check if item is LPEItem before casting!!! fixes bug 236788 (bzr r5793) --- src/shape-editor.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/shape-editor.cpp') diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp index 1d60671aa..49d8a2a14 100644 --- a/src/shape-editor.cpp +++ b/src/shape-editor.cpp @@ -190,15 +190,23 @@ void ShapeEditor::set_item(SPItem *item) { this->grab_node = -1; if (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()) { - // 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 + 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() ) + // 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)); + } + } 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) { this->nodepath->shape_editor = this; } -- cgit v1.2.3