summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2011-08-21 10:29:02 +0000
committerJohan Engelen <goejendaagh@zonnet.nl>2011-08-21 10:29:02 +0000
commit9b4b20104eba525bdfff7c40ca1a985cda5d7791 (patch)
treeddc583c4aaaf3e65adf1c35bfc853c17a26904f4 /src
parentupdate cmake file list. (diff)
downloadinkscape-9b4b20104eba525bdfff7c40ca1a985cda5d7791.tar.gz
inkscape-9b4b20104eba525bdfff7c40ca1a985cda5d7791.zip
fix for bad argument crash for guides
Fixed bugs: - https://launchpad.net/bugs/829947 (bzr r10562)
Diffstat (limited to 'src')
-rw-r--r--src/sp-guide.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp
index b55084609..a06d098d0 100644
--- a/src/sp-guide.cpp
+++ b/src/sp-guide.cpp
@@ -231,23 +231,27 @@ static void sp_guide_set(SPObject *object, unsigned int key, const gchar *value)
break;
case SP_ATTR_POSITION:
{
- gchar ** strarray = g_strsplit(value, ",", 2);
- double newx, newy;
- unsigned int success = sp_svg_number_read_d(strarray[0], &newx);
- success += sp_svg_number_read_d(strarray[1], &newy);
- g_strfreev (strarray);
- if (success == 2) {
- guide->point_on_line = Geom::Point(newx, newy);
- } else if (success == 1) {
- // before 0.46 style guideline definition.
- const gchar *attr = object->getRepr()->attribute("orientation");
- if (attr && !strcmp(attr, "horizontal")) {
- guide->point_on_line = Geom::Point(0, newx);
- } else {
- guide->point_on_line = Geom::Point(newx, 0);
+ if (value) {
+ gchar ** strarray = g_strsplit(value, ",", 2);
+ double newx, newy;
+ unsigned int success = sp_svg_number_read_d(strarray[0], &newx);
+ success += sp_svg_number_read_d(strarray[1], &newy);
+ g_strfreev (strarray);
+ if (success == 2) {
+ guide->point_on_line = Geom::Point(newx, newy);
+ } else if (success == 1) {
+ // before 0.46 style guideline definition.
+ const gchar *attr = object->getRepr()->attribute("orientation");
+ if (attr && !strcmp(attr, "horizontal")) {
+ guide->point_on_line = Geom::Point(0, newx);
+ } else {
+ guide->point_on_line = Geom::Point(newx, 0);
+ }
}
+ } else {
+ // default to (0,0) for bad arguments
+ guide->point_on_line = Geom::Point(0,0);
}
-
// update position in non-committing way
// fixme: perhaps we need to add an update method instead, and request_update here
sp_guide_moveto(*guide, guide->point_on_line, false);