From 8390b213aa2b3456664d7820b75a9f25458b1cd3 Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Fri, 4 Oct 2013 18:01:05 +0200 Subject: Do not allow NULL _spcurve to be set in PathManipulator. Fixes crasher bug #488035. Fixed bugs: - https://launchpad.net/bugs/488035 (bzr r12655) --- src/ui/tool/path-manipulator.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/ui') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index b775c0637..3d080ad19 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1309,6 +1309,10 @@ void PathManipulator::_getGeometry() } else { _spcurve->unref(); _spcurve = _path->get_curve_for_edit(); + // never allow NULL to sneak in here! + if (_spcurve == NULL) { + _spcurve = new SPCurve(); + } } } -- cgit v1.2.3 From b40810c40eb3631a47ca16968d96294f795baee8 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 4 Oct 2013 22:53:18 +0200 Subject: fix bug (added some comments to jabiertxof's patch) Fixed bugs: - https://launchpad.net/bugs/1235032 (bzr r12658) --- src/ui/tool/path-manipulator.cpp | 5 +++-- src/ui/tool/path-manipulator.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/ui') diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 3d080ad19..36f78af9d 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -203,7 +203,7 @@ void PathManipulator::writeXML() sp_object_ref(_path); _path->deleteObject(true, true); sp_object_unref(_path); - _path = 0; + _path = NULL; } _observer->unblock(); } @@ -1206,7 +1206,8 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) Geom::PathVector pathv = builder.peek() * (_edit_transform * _i2d_transform).inverse(); _spcurve->set_pathvector(pathv); if (alert_LPE) { - if (_path->hasPathEffect()) { + /// \todo note that _path can be an Inkscape::LivePathEffect::Effect* too, kind of confusing, rework member naming? + if (SP_IS_LPE_ITEM(_path) && _path->hasPathEffect()) { PathEffectList effect_list = sp_lpe_item_get_effect_list(_path); LivePathEffect::LPEPowerStroke *lpe_pwr = dynamic_cast( effect_list.front()->lpeobject->get_lpe() ); if (lpe_pwr) { diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index 1444272e8..e01e8617f 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -131,7 +131,7 @@ private: SubpathList _subpaths; MultiPathManipulator &_multi_path_manipulator; - SPPath *_path; + SPPath *_path; ///< can be an SPPath or an Inkscape::LivePathEffect::Effect !!! SPCurve *_spcurve; // in item coordinates SPCanvasItem *_outline; CurveDragPoint *_dragpoint; // an invisible control point hoverng over curve -- cgit v1.2.3 From 9a2c4ca30ed332442428594438848b9de2e589a9 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 4 Oct 2013 23:18:20 +0200 Subject: C++ (bzr r12659) --- src/ui/dialog/livepatheffect-editor.cpp | 14 +++++++------- src/ui/tool/path-manipulator.cpp | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/ui') diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index e96b57170..96f8c9446 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -332,7 +332,7 @@ LivePathEffectEditor::effect_list_reload(SPLPEItem *lpeitem) { effectlist_store->clear(); - PathEffectList effectlist = sp_lpe_item_get_effect_list(lpeitem); + PathEffectList effectlist = lpeitem->getEffectList(); PathEffectList::iterator it; for( it = effectlist.begin() ; it!=effectlist.end(); ++it) { @@ -491,13 +491,13 @@ void LivePathEffectEditor::onUp() Inkscape::Selection *sel = _getSelection(); if ( sel && !sel->isEmpty() ) { SPItem *item = sel->singleItem(); - if ( item && SP_IS_LPE_ITEM(item) ) { - sp_lpe_item_up_current_path_effect(SP_LPE_ITEM(item)); + if ( SPLPEItem *lpeitem = SP_LPE_ITEM(item) ) { + lpeitem->upCurrentPathEffect(); DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Move path effect up") ); - effect_list_reload(SP_LPE_ITEM(item)); + effect_list_reload(lpeitem); } } } @@ -507,13 +507,13 @@ void LivePathEffectEditor::onDown() Inkscape::Selection *sel = _getSelection(); if ( sel && !sel->isEmpty() ) { SPItem *item = sel->singleItem(); - if ( item && SP_IS_LPE_ITEM(item) ) { - sp_lpe_item_down_current_path_effect(SP_LPE_ITEM(item)); + if ( SPLPEItem *lpeitem = SP_LPE_ITEM(item) ) { + lpeitem->downCurrentPathEffect(); DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Move path effect down") ); - effect_list_reload(SP_LPE_ITEM(item)); + effect_list_reload(lpeitem); } } } diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 36f78af9d..d12e2958b 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1208,7 +1208,7 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) if (alert_LPE) { /// \todo note that _path can be an Inkscape::LivePathEffect::Effect* too, kind of confusing, rework member naming? if (SP_IS_LPE_ITEM(_path) && _path->hasPathEffect()) { - PathEffectList effect_list = sp_lpe_item_get_effect_list(_path); + PathEffectList effect_list = _path->getEffectList(); LivePathEffect::LPEPowerStroke *lpe_pwr = dynamic_cast( effect_list.front()->lpeobject->get_lpe() ); if (lpe_pwr) { lpe_pwr->adjustForNewPath(pathv); -- cgit v1.2.3 From 4f857ae84089672e9c7378d327e54889f64c62fb Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Fri, 4 Oct 2013 23:57:28 +0200 Subject: C++ (bzr r12660) --- src/ui/clipboard.cpp | 4 ++-- src/ui/dialog/livepatheffect-editor.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ui') diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index ed28cabbd..da6fed86b 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -938,7 +938,7 @@ void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effectsta { SPLPEItem *lpeitem = SP_LPE_ITEM(item); // for each effect in the stack, check if we need to fork it before adding it to the item - sp_lpe_item_fork_path_effects_if_necessary(lpeitem, 1); + lpeitem->forkPathEffectsIfNecessary(1); std::istringstream iss(effectstack); std::string href; @@ -949,7 +949,7 @@ void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effectsta return; } LivePathEffectObject *lpeobj = LIVEPATHEFFECT(obj); - sp_lpe_item_add_path_effect(lpeitem, lpeobj); + lpeitem->addPathEffect(lpeobj); } } } diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 96f8c9446..30b16cee0 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -280,7 +280,7 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel) set_sensitize_all(true); if ( lpeitem->hasPathEffect() ) { - Inkscape::LivePathEffect::Effect *lpe = sp_lpe_item_get_current_lpe(lpeitem); + Inkscape::LivePathEffect::Effect *lpe = lpeitem->getCurrentLPE(); if (lpe) { showParams(*lpe); lpe_list_locked = true; @@ -475,7 +475,7 @@ LivePathEffectEditor::onRemove() if ( sel && !sel->isEmpty() ) { SPItem *item = sel->singleItem(); if ( item && SP_IS_LPE_ITEM(item) ) { - sp_lpe_item_remove_current_path_effect(SP_LPE_ITEM(item), false); + SP_LPE_ITEM(item)->removeCurrentPathEffect(false); DocumentUndo::done( sp_desktop_document(current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Remove path effect") ); @@ -530,7 +530,7 @@ void LivePathEffectEditor::on_effect_selection_changed() if (lperef && current_lpeitem) { if (lperef->lpeobject->get_lpe()) { lpe_list_locked = true; // prevent reload of the list which would lose selection - sp_lpe_item_set_current_path_effect(current_lpeitem, lperef); + current_lpeitem->setCurrentPathEffect(lperef); showParams(*lperef->lpeobject->get_lpe()); } } -- cgit v1.2.3