Hi,
In 2geom/path.cpp, ll 338-340, the following can be found:
// this approach depends on std::vector's behavior WRT iterator stability
get_curves().erase(first_replaced, last_replaced);
get_curves().insert(first_replaced, first, last);
get_curves() returns a std::vector&, all parameters are iterators.
Both the comment and a failed debug assertion (Expression: vector insert iterator outside range) made me look this case up and I'm quite sure that this is not allowed:
std::vector::erase
Iterator validity
Iterators, pointers and references pointing to position (or first) and beyond are invalidated [.].
http://www.cplusplus.com/reference/vector/vector/erase/
So (at least) first_replaced is invalid in the second line.
Can anyone confirm this? Is there an easy workaround?
Regards,
Markus
2014-03-25 1:51 GMT+01:00 Markus Engel <p637777@...1081...>:
So (at least) first_replaced is invalid in the second line.
Can anyone confirm this? Is there an easy workaround?
Yes, it looks like the code is invalid. An easy workaround is:
first_replaced = get_curves().erase(first_replaced, last_replaced); get_curves().insert(first_replaced, first, last);
Regards, Krzysztof
Hi, thanks a lot! Now there's another problem: 2geom/path.h:420:
do_update(get_curves().begin(), get_curves().end()-1, get_curves().begin(), get_curves().begin());
This is invalid as well. If I understand this correctly, it simply removes everything but the last element in the vector and then duplicates it? How would you fix this? :)
Regards, Markus
-----Ursprüngliche Nachricht----- Von: Krzysztof Kosiński [mailto:tweenk.pl@...400...] Gesendet: Dienstag, 25. März 2014 03:10 An: Markus Engel Cc: inkscape-devel Betreff: Re: [Inkscape-devel] Possible problem in Geom::Path
2014-03-25 1:51 GMT+01:00 Markus Engel <p637777@...1081...>:
So (at least) first_replaced is invalid in the second line.
Can anyone confirm this? Is there an easy workaround?
Yes, it looks like the code is invalid. An easy workaround is:
first_replaced = get_curves().erase(first_replaced, last_replaced); get_curves().insert(first_replaced, first, last);
Regards, Krzysztof
participants (2)
-
Krzysztof Kosiński
-
Markus Engel