From 7e4b6f793d31d3245bd8afbf6f10aa255ac3e7ae Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Thu, 19 Feb 2015 20:20:09 +0100 Subject: added a set to the Selection (bzr r13922.1.6) --- src/xml/repr-util.cpp | 12 ++++++------ src/xml/repr.h | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src/xml') diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp index 12280ea5a..447f2ff40 100644 --- a/src/xml/repr-util.cpp +++ b/src/xml/repr-util.cpp @@ -259,7 +259,7 @@ gchar const *sp_xml_ns_prefix_uri(gchar const *prefix) * -1 first object's position is less than the second * @todo Rewrite this function's description to be understandable */ -int sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::Node const *second) +bool sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::Node const *second) { int p1, p2; if (first->parent() == second->parent()) { @@ -276,9 +276,9 @@ int sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::No g_assert(ancestor != NULL); if (ancestor == first) { - return 1; + return false; } else if (ancestor == second) { - return -1; + return true; } else { Inkscape::XML::Node const *to_first = AncetreFils(first, ancestor); Inkscape::XML::Node const *to_second = AncetreFils(second, ancestor); @@ -288,9 +288,9 @@ int sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::No } } - if (p1 > p2) return 1; - if (p1 < p2) return -1; - return 0; + if (p1 > p2) return false; + if (p1 < p2) return true; + return false; /* effic: Assuming that the parent--child relationship is consistent (i.e. that the parent really does contain first and second among diff --git a/src/xml/repr.h b/src/xml/repr.h index e1d7fdfd6..c96560a98 100644 --- a/src/xml/repr.h +++ b/src/xml/repr.h @@ -118,7 +118,8 @@ unsigned sp_repr_set_svg_double(Inkscape::XML::Node *repr, char const *key, doub unsigned sp_repr_set_point(Inkscape::XML::Node *repr, char const *key, Geom::Point const & val); unsigned sp_repr_get_point(Inkscape::XML::Node *repr, char const *key, Geom::Point *val); -int sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::Node const *second); +//c++-style comparison : returns (bool)(a Date: Fri, 1 May 2015 02:26:56 +0200 Subject: Fixed crash bug due to some overlooked function changed in the recent merge. Also fixed the layer ordering in the widget, which was messed up by the same bug in a way i haven't quite sorted out (so the fact that this patch fixed it is quite a mystery, but i won't complain) (bzr r14079) --- src/xml/repr-util.cpp | 17 +++++++++++------ src/xml/repr.h | 3 ++- 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'src/xml') diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp index 3858f08a7..305f1b292 100644 --- a/src/xml/repr-util.cpp +++ b/src/xml/repr-util.cpp @@ -260,7 +260,7 @@ gchar const *sp_xml_ns_prefix_uri(gchar const *prefix) * -1 first object's position is less than the second * @todo Rewrite this function's description to be understandable */ -bool sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::Node const *second) +int sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::Node const *second) { int p1, p2; if (first->parent() == second->parent()) { @@ -277,9 +277,9 @@ bool sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::N g_assert(ancestor != NULL); if (ancestor == first) { - return false; + return 1; } else if (ancestor == second) { - return true; + return -1; } else { Inkscape::XML::Node const *to_first = AncetreFils(first, ancestor); Inkscape::XML::Node const *to_second = AncetreFils(second, ancestor); @@ -289,9 +289,9 @@ bool sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::N } } - if (p1 > p2) return false; - if (p1 < p2) return true; - return false; + if (p1 > p2) return 1; + if (p1 < p2) return -1; + return 0; /* effic: Assuming that the parent--child relationship is consistent (i.e. that the parent really does contain first and second among @@ -310,6 +310,11 @@ bool sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::N pjrm */ } +bool sp_repr_compare_position_bool(Inkscape::XML::Node const *first, Inkscape::XML::Node const *second){ + return sp_repr_compare_position_bool(first, second)<0; +} + + /** * Find an element node using an unique attribute. * diff --git a/src/xml/repr.h b/src/xml/repr.h index fbe25ec12..17763195a 100644 --- a/src/xml/repr.h +++ b/src/xml/repr.h @@ -121,7 +121,8 @@ unsigned sp_repr_set_point(Inkscape::XML::Node *repr, char const *key, Geom::Poi unsigned sp_repr_get_point(Inkscape::XML::Node *repr, char const *key, Geom::Point *val); //c++-style comparison : returns (bool)(a Date: Sat, 2 May 2015 01:08:34 +0200 Subject: Fix segfault due to an infinite recursion (due to a typo) (bzr r14083) --- src/xml/repr-util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/xml') diff --git a/src/xml/repr-util.cpp b/src/xml/repr-util.cpp index 305f1b292..4cbe930a1 100644 --- a/src/xml/repr-util.cpp +++ b/src/xml/repr-util.cpp @@ -311,7 +311,7 @@ int sp_repr_compare_position(Inkscape::XML::Node const *first, Inkscape::XML::No } bool sp_repr_compare_position_bool(Inkscape::XML::Node const *first, Inkscape::XML::Node const *second){ - return sp_repr_compare_position_bool(first, second)<0; + return sp_repr_compare_position(first, second)<0; } -- cgit v1.2.3