summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2013-10-04 20:24:32 +0000
committerJohan B. C. Engelen <j.b.c.engelen@alumnus.utwente.nl>2013-10-04 20:24:32 +0000
commiteedaac6439c0c4edb489643335fcfc003607bf08 (patch)
treeb4e7fd9d1051af877ef1f0c821fe4951b2fce554 /src
parentDo not allow NULL _spcurve to be set in PathManipulator. (diff)
downloadinkscape-eedaac6439c0c4edb489643335fcfc003607bf08.tar.gz
inkscape-eedaac6439c0c4edb489643335fcfc003607bf08.zip
LPE: add some const correctness, remove unused function, and fix potential crash bug
(bzr r12656)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/lpeobject.h1
-rw-r--r--src/sp-lpe-item.cpp42
-rw-r--r--src/sp-lpe-item.h2
-rw-r--r--src/sp-path.cpp2
4 files changed, 29 insertions, 18 deletions
diff --git a/src/live_effects/lpeobject.h b/src/live_effects/lpeobject.h
index 534a12897..9700024fe 100644
--- a/src/live_effects/lpeobject.h
+++ b/src/live_effects/lpeobject.h
@@ -39,6 +39,7 @@ public:
/* Note that the returned pointer can be NULL in a valid LivePathEffectObject contained in a valid list of lpeobjects in an lpeitem!
* So one should always check whether the returned value is NULL or not */
Inkscape::LivePathEffect::Effect * get_lpe() { return lpe; };
+ Inkscape::LivePathEffect::Effect const * get_lpe() const { return lpe; };
Inkscape::LivePathEffect::Effect *lpe; // this can be NULL in a valid LivePathEffectObject
diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp
index b3e6182a4..0517201f1 100644
--- a/src/sp-lpe-item.cpp
+++ b/src/sp-lpe-item.cpp
@@ -531,6 +531,26 @@ bool SPLPEItem::hasPathEffect() const
return true;
}
+bool SPLPEItem::hasPathEffectOfType(int const type) const
+{
+ if (path_effect_list->empty()) {
+ return false;
+ }
+
+ for (PathEffectList::const_iterator it = path_effect_list->begin(); it != path_effect_list->end(); ++it)
+ {
+ LivePathEffectObject const *lpeobj = (*it)->lpeobject;
+ if (lpeobj) {
+ Inkscape::LivePathEffect::Effect const* lpe = lpeobj->get_lpe();
+ if (lpe && (lpe->effectType() == type)) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
bool SPLPEItem::hasPathEffectRecursive() const
{
if (parent && SP_IS_LPE_ITEM(parent)) {
@@ -546,27 +566,17 @@ SPLPEItem::getPathEffectOfType(int type)
{
std::list<Inkscape::LivePathEffect::LPEObjectReference *>::iterator i;
for (i = path_effect_list->begin(); i != path_effect_list->end(); ++i) {
- Inkscape::LivePathEffect::Effect* lpe = (*i)->lpeobject->get_lpe();
- if (lpe && (lpe->effectType() == type)) {
- return lpe;
+ LivePathEffectObject *lpeobj = (*i)->lpeobject;
+ if (lpeobj) {
+ Inkscape::LivePathEffect::Effect* lpe = lpeobj->get_lpe();
+ if (lpe && (lpe->effectType() == type)) {
+ return lpe;
+ }
}
}
return NULL;
}
-/* Return false if the item is not a path or already has a shape applied */
-bool sp_lpe_item_can_accept_freehand_shape(SPLPEItem *lpeitem)
-{
- if (!SP_IS_PATH(lpeitem))
- return false;
-
- if (lpeitem->getPathEffectOfType(Inkscape::LivePathEffect::FREEHAND_SHAPE)) {
- return false;
- }
-
- return true;
-}
-
void sp_lpe_item_edit_next_param_oncanvas(SPLPEItem *lpeitem, SPDesktop *dt)
{
Inkscape::LivePathEffect::LPEObjectReference *lperef = sp_lpe_item_get_current_lpereference(lpeitem);
diff --git a/src/sp-lpe-item.h b/src/sp-lpe-item.h
index 81adb938a..00c3e1f3b 100644
--- a/src/sp-lpe-item.h
+++ b/src/sp-lpe-item.h
@@ -71,6 +71,7 @@ public:
virtual void update_patheffect(bool write);
bool hasPathEffect() const;
+ bool hasPathEffectOfType(int const type) const;
bool hasPathEffectRecursive() const;
Inkscape::LivePathEffect::Effect* getPathEffectOfType(int type);
bool hasBrokenPathEffect() const;
@@ -85,7 +86,6 @@ void sp_lpe_item_remove_all_path_effects(SPLPEItem *lpeitem, bool keep_paths);
void sp_lpe_item_remove_current_path_effect(SPLPEItem *lpeitem, bool keep_paths);
void sp_lpe_item_down_current_path_effect(SPLPEItem *lpeitem);
void sp_lpe_item_up_current_path_effect(SPLPEItem *lpeitem);
-bool sp_lpe_item_can_accept_freehand_shape(SPLPEItem *lpeitem);
void sp_lpe_item_edit_next_param_oncanvas(SPLPEItem *lpeitem, SPDesktop *dt);
PathEffectList sp_lpe_item_get_effect_list(SPLPEItem *lpeitem);
PathEffectList const sp_lpe_item_get_effect_list(SPLPEItem const *lpeitem);
diff --git a/src/sp-path.cpp b/src/sp-path.cpp
index af2f02328..5c347e485 100644
--- a/src/sp-path.cpp
+++ b/src/sp-path.cpp
@@ -265,7 +265,7 @@ Geom::Affine SPPath::set_transform(Geom::Affine const &transform) {
// Transform the original-d path if this is a valid LPE this, other else the (ordinary) path
if (_curve_before_lpe && hasPathEffectRecursive()) {
- if (getPathEffectOfType(Inkscape::LivePathEffect::CLONE_ORIGINAL)) {
+ if (this->hasPathEffectOfType(Inkscape::LivePathEffect::CLONE_ORIGINAL)) {
// if path has the CLONE_ORIGINAL LPE applied, don't write the transform to the pathdata, but write it 'unoptimized'
return transform;
} else {