Merge lp:~mc.../inkscape/SelContainer into lp:~inkscape.dev/inkscape/trunk
- SelContainer
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 14074 |
Proposed branch: | lp:~mc.../inkscape/SelContainer |
Merge into: | lp:~inkscape.dev/inkscape/trunk |
Diff against target: |
8772 lines (+1576/-1810) 114 files modified
AUTHORS (+1/-0) src/conn-avoid-ref.cpp (+3/-2) src/desktop-style.cpp (+60/-61) src/desktop-style.h (+16/-15) src/desktop.cpp (+1/-1) src/desktop.h (+1/-1) src/document.cpp (+17/-17) src/document.h (+4/-4) src/extension/execution-env.cpp (+3/-5) src/extension/implementation/implementation.cpp (+3/-5) src/extension/implementation/script.cpp (+3/-4) src/extension/internal/bitmap/imagemagick.cpp (+7/-11) src/extension/internal/bluredge.cpp (+2/-4) src/extension/internal/cairo-renderer.cpp (+3/-5) src/extension/internal/filter/filter.cpp (+2/-4) src/extension/internal/grid.cpp (+3/-6) src/extension/internal/latex-text-renderer.cpp (+3/-5) src/file.cpp (+2/-5) src/gradient-chemistry.cpp (+7/-5) src/gradient-drag.cpp (+9/-8) src/graphlayout.cpp (+5/-5) src/graphlayout.h (+2/-2) src/helper/png-write.cpp (+6/-6) src/helper/png-write.h (+4/-3) src/live_effects/lpe-knot.cpp (+3/-3) src/main.cpp (+13/-15) src/object-snapper.cpp (+3/-2) src/object-test.h (+2/-1) src/path-chemistry.cpp (+57/-72) src/path-chemistry.h (+1/-1) src/removeoverlap.cpp (+6/-7) src/removeoverlap.h (+1/-1) src/selcue.cpp (+11/-8) src/selection-chemistry.cpp (+415/-518) src/selection-chemistry.h (+5/-4) src/selection-describer.cpp (+17/-17) src/selection.cpp (+83/-89) src/selection.h (+15/-11) src/seltrans.cpp (+27/-28) src/seltrans.h (+1/-1) src/snap.cpp (+7/-7) src/snap.h (+4/-4) src/sp-conn-end.cpp (+3/-2) src/sp-defs.cpp (+3/-5) src/sp-filter.cpp (+3/-5) src/sp-item-group.cpp (+32/-53) src/sp-item-group.h (+6/-4) src/sp-lpe-item.cpp (+15/-15) src/sp-marker.cpp (+3/-3) src/sp-marker.h (+1/-1) src/sp-object.cpp (+3/-3) src/sp-object.h (+3/-2) src/sp-pattern.cpp (+3/-3) src/sp-pattern.h (+1/-1) src/sp-switch.cpp (+11/-13) src/sp-switch.h (+1/-1) src/splivarot.cpp (+44/-57) src/text-chemistry.cpp (+37/-47) src/text-editing.cpp (+3/-4) src/trace/trace.cpp (+4/-4) src/ui/clipboard.cpp (+17/-16) src/ui/dialog/align-and-distribute.cpp (+41/-45) src/ui/dialog/clonetiler.cpp (+7/-9) src/ui/dialog/export.cpp (+15/-13) src/ui/dialog/filter-effects-dialog.cpp (+12/-15) src/ui/dialog/find.cpp (+48/-48) src/ui/dialog/find.h (+5/-5) src/ui/dialog/font-substitution.cpp (+11/-17) src/ui/dialog/font-substitution.h (+3/-2) src/ui/dialog/glyphs.cpp (+7/-5) src/ui/dialog/grid-arrange-tab.cpp (+34/-35) src/ui/dialog/icon-preview.cpp (+3/-5) src/ui/dialog/object-attributes.cpp (+1/-1) src/ui/dialog/objects.cpp (+4/-4) src/ui/dialog/pixelartdialog.cpp (+4/-4) src/ui/dialog/polar-arrange-tab.cpp (+5/-9) src/ui/dialog/print.cpp (+1/-1) src/ui/dialog/svg-fonts-dialog.cpp (+2/-2) src/ui/dialog/swatches.cpp (+3/-3) src/ui/dialog/tags.cpp (+6/-5) src/ui/dialog/text-edit.cpp (+12/-14) src/ui/dialog/transformation.cpp (+24/-20) src/ui/interface.cpp (+7/-10) src/ui/tools/connector-tool.cpp (+3/-5) src/ui/tools/eraser-tool.cpp (+13/-20) src/ui/tools/gradient-tool.cpp (+19/-18) src/ui/tools/lpe-tool.cpp (+4/-4) src/ui/tools/measure-tool.cpp (+3/-3) src/ui/tools/mesh-tool.cpp (+14/-13) src/ui/tools/node-tool.cpp (+4/-6) src/ui/tools/select-tool.cpp (+2/-3) src/ui/tools/spray-tool.cpp (+12/-20) src/ui/tools/text-tool.cpp (+3/-4) src/ui/tools/tool-base.cpp (+2/-4) src/ui/tools/tweak-tool.cpp (+11/-14) src/ui/widget/object-composite-settings.cpp (+2/-1) src/ui/widget/style-subject.cpp (+19/-21) src/ui/widget/style-subject.h (+8/-7) src/unclump.cpp (+32/-35) src/unclump.h (+1/-1) src/vanishing-point.cpp (+15/-11) src/widgets/arc-toolbar.cpp (+12/-21) src/widgets/connector-toolbar.cpp (+6/-10) src/widgets/fill-style.cpp (+16/-16) src/widgets/gradient-toolbar.cpp (+9/-6) src/widgets/mesh-toolbar.cpp (+6/-4) src/widgets/rect-toolbar.cpp (+9/-9) src/widgets/spiral-toolbar.cpp (+6/-10) src/widgets/star-toolbar.cpp (+18/-20) src/widgets/stroke-style.cpp (+15/-15) src/widgets/stroke-style.h (+1/-1) src/widgets/text-toolbar.cpp (+17/-17) src/xml/repr-util.cpp (+6/-6) src/xml/repr.h (+2/-1) |
To merge this branch: | bzr merge lp:~mc.../inkscape/SelContainer |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alex Valavanis | Needs Fixing | ||
Liam P. White (community) | Approve | ||
Review via email: mp+250681@code.launchpad.net |
Commit message
Description of the change
Hi all,
This branch is a proposal to replace a lot of GSLists with std::vectors, more specifically in all the places that deal with the selection.
Basically, selection-
Mc (mc...) wrote : | # |
> I added some fancy new diff comments that should help show where things need
> fixing.
Thanks a lot for your comments !
I actually meant to change the semantics of SPObject::childList : It used to return a GSList, whose *last* element was the first child, and to be reversed in many places.
Now it returns a vector whose *first* element is the first child, so that allows us to actually simplify a lot of things (use push_back instead of insert in all the places that deals with childList)
I'll try to apply your comments as soon as i can.
Krzysztof Kosinski (tweenk) wrote : | # |
Converting Selection to a vector is not the best thing to do. Selection
should be a data structure equivalent to Java's LinkedHashSet, because the
most common operation is lookup (whether something is in the selection) and
we also need to remember the selection's order for purposes such as Boolean
operations.
Regards, Krzysztof
2015-02-24 12:08 GMT+01:00 Mc <email address hidden>:
> > I added some fancy new diff comments that should help show where things
> need
> > fixing.
>
> Thanks a lot for your comments !
>
> I actually meant to change the semantics of SPObject::childList : It used
> to return a GSList, whose *last* element was the first child, and to be
> reversed in many places.
>
> Now it returns a vector whose *first* element is the first child, so that
> allows us to actually simplify a lot of things (use push_back instead of
> insert in all the places that deals with childList)
>
> I'll try to apply your comments as soon as i can.
> --
> https:/
> You are subscribed to branch lp:inkscape.
>
Mc (mc...) wrote : | # |
This is not contradictory: since only the selection object needs to be able to do the lookups, this data structure can be internal to Selection, and does not need to be whatever is sent to anyone who calls itemList() (I don't really favor introducing iteration over boost objects everywhere just for that, stl is enough for stuff out of the selection class (ie: iterate) )
(I actually also added a std::set to make lookups logarithmic, alongside with the vectors change. I agree that it could be made one container, internally to the selection class, but vector+set prevents to do the copying from the boost thing)
> Converting Selection to a vector is not the best thing to do. Selection
> should be a data structure equivalent to Java's LinkedHashSet, because the
> most common operation is lookup (whether something is in the selection) and
> we also need to remember the selection's order for purposes such as Boolean
> operations.
>
> Regards, Krzysztof
Krzysztof Kosinski (tweenk) wrote : | # |
Some more comments.
1. Please follow the coding style.
https:/
2. I don't really understand what you mean by "introducing iteration over boost objects".
3. While simply replacing GSList with vectors is an obvious improvement, I think the correct approach is to make a new data structure, that will encapsulate what we mean by a selection of objects (a list of unique items none of which is a descendant of any other), but which will not be tied to the GUI concept of selection. One could use Boost MultiIndex for this. Then you would return this structure (or references to it) instead of std::vector. The new structure could be a template called SelectionSet, with typedefs SelectionSet<
Liam P. White (liampwhite) wrote : | # |
> I would not be opposed to incorporating the simple GSList -> vector change first and introducing selection sets later.
Then let's do that.
- 13932. By Marc Jeanmougin <email address hidden>
-
corrected the casts (hopefully)
- 13933. By Marc Jeanmougin <email address hidden>
-
more cast cleanup
- 13934. By Marc Jeanmougin <email address hidden>
-
merge
- 13935. By Marc Jeanmougin <email address hidden>
-
merging
- 13936. By Marc Jeanmougin <email address hidden>
-
fix
- 13937. By Marc Jeanmougin <email address hidden>
-
Just reread the entire diff against trunk. Given the diff size, i must have forgotten things, but hopefully, there are only very few changes of semantics:
->childList is now in the intuitive order (childList()[0] is now firstChild)
-> sp_selection_paste_impl is now in the opposite order (change is local to selection- chemistry. cpp, and simplify a few things)
-> selection.setReprList now takes the list in the opposite order. It was always the case (the list was always reversed before handing to it)
-> a few comparison functions now work "the c++ way": the C way was to return -1 if a<b, 0 if a==b and 1 if a>b, now they return (bool)(a<b) - 13938. By Marc Jeanmougin <email address hidden>
-
removed a few "using Inkscape:
:Util:: GSListConstIter ator" - 13939. By Marc Jeanmougin <email address hidden>
-
removed a few useless SP_OBJECT() casts
- 13940. By Marc Jeanmougin <email address hidden>
-
merge with trunk
Liam P. White (liampwhite) wrote : | # |
Approving for merge — may need some small post-merge cleanups but otherwise don't see any issues obstructing merge at this point.
Alex Valavanis (valavanisalex) wrote : | # |
This introduces a build failure if using --enable-dbusapi configuration flag. This is because the src/extension/
Preview Diff
1 | === modified file 'AUTHORS' |
2 | --- AUTHORS 2014-05-12 22:02:09 +0000 |
3 | +++ AUTHORS 2015-04-29 21:03:59 +0000 |
4 | @@ -80,6 +80,7 @@ |
5 | Jean-Olivier Irisson |
6 | Bob Jamison |
7 | Ted Janeczko |
8 | +Marc Jeanmougin |
9 | jEsuSdA |
10 | Lauris Kaplinski |
11 | Lynn Kerby |
12 | |
13 | === modified file 'src/conn-avoid-ref.cpp' |
14 | --- src/conn-avoid-ref.cpp 2014-12-21 21:58:32 +0000 |
15 | +++ src/conn-avoid-ref.cpp 2015-04-29 21:03:59 +0000 |
16 | @@ -252,8 +252,9 @@ |
17 | { |
18 | SPGroup* group = SP_GROUP(item); |
19 | // consider all first-order children |
20 | - for (GSList const* i = sp_item_group_item_list(group); i != NULL; i = i->next) { |
21 | - SPItem* child_item = SP_ITEM(i->data); |
22 | + std::vector<SPItem*> itemlist = sp_item_group_item_list(group); |
23 | + for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i != itemlist.end(); i++) { |
24 | + SPItem* child_item = *i; |
25 | std::vector<Geom::Point> child_points = approxItemWithPoints(child_item, item_transform * child_item->transform); |
26 | poly_points.insert(poly_points.end(), child_points.begin(), child_points.end()); |
27 | } |
28 | |
29 | === modified file 'src/desktop-style.cpp' |
30 | --- src/desktop-style.cpp 2015-02-22 18:04:11 +0000 |
31 | +++ src/desktop-style.cpp 2015-04-29 21:03:59 +0000 |
32 | @@ -194,10 +194,10 @@ |
33 | sp_repr_css_merge(css_write, css); |
34 | sp_css_attr_unset_uris(css_write); |
35 | prefs->mergeStyle("/desktop/style", css_write); |
36 | - |
37 | - for (const GSList *i = desktop->selection->itemList(); i != NULL; i = i->next) { |
38 | + std::vector<SPItem*> const itemlist = desktop->selection->itemList(); |
39 | + for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i!= itemlist.end(); i++) { |
40 | /* last used styles for 3D box faces are stored separately */ |
41 | - SPObject *obj = reinterpret_cast<SPObject *>(i->data); // TODO unsafe until Selection is refactored. |
42 | + SPObject *obj = *i; |
43 | Box3DSide *side = dynamic_cast<Box3DSide *>(obj); |
44 | if (side) { |
45 | const char * descr = box3d_side_axes_string(side); |
46 | @@ -234,8 +234,9 @@ |
47 | sp_repr_css_merge(css_no_text, css); |
48 | css_no_text = sp_css_attr_unset_text(css_no_text); |
49 | |
50 | - for (GSList const *i = desktop->selection->itemList(); i != NULL; i = i->next) { |
51 | - SPItem *item = reinterpret_cast<SPItem *>(i->data); |
52 | + std::vector<SPItem*> const itemlist = desktop->selection->itemList(); |
53 | + for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i!= itemlist.end(); i++) { |
54 | + SPItem *item = *i; |
55 | |
56 | // If not text, don't apply text attributes (can a group have text attributes? Yes! FIXME) |
57 | if (isTextualItem(item)) { |
58 | @@ -438,18 +439,16 @@ |
59 | /** Determine average stroke width, simple method */ |
60 | // see TODO in dialogs/stroke-style.cpp on how to get rid of this eventually |
61 | gdouble |
62 | -stroke_average_width (GSList const *objects) |
63 | +stroke_average_width (const std::vector<SPItem*> &objects) |
64 | { |
65 | - if (g_slist_length ((GSList *) objects) == 0) |
66 | + if (objects.empty()) |
67 | return Geom::infinity(); |
68 | |
69 | gdouble avgwidth = 0.0; |
70 | bool notstroked = true; |
71 | int n_notstroked = 0; |
72 | - |
73 | - for (GSList const *l = objects; l != NULL; l = l->next) { |
74 | - SPObject *obj = reinterpret_cast<SPObject *>(l->data); |
75 | - SPItem *item = dynamic_cast<SPItem *>(obj); |
76 | + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
77 | + SPItem *item = *i; |
78 | if (!item) { |
79 | continue; |
80 | } |
81 | @@ -471,7 +470,7 @@ |
82 | if (notstroked) |
83 | return Geom::infinity(); |
84 | |
85 | - return avgwidth / (g_slist_length ((GSList *) objects) - n_notstroked); |
86 | + return avgwidth / (objects.size() - n_notstroked); |
87 | } |
88 | |
89 | static bool vectorsClose( std::vector<double> const &lhs, std::vector<double> const &rhs ) |
90 | @@ -492,9 +491,9 @@ |
91 | * Write to style_res the average fill or stroke of list of objects, if applicable. |
92 | */ |
93 | int |
94 | -objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill) |
95 | +objects_query_fillstroke (const std::vector<SPItem*> &objects, SPStyle *style_res, bool const isfill) |
96 | { |
97 | - if (g_slist_length(objects) == 0) { |
98 | + if (objects.empty()) { |
99 | /* No objects, set empty */ |
100 | return QUERY_STYLE_NOTHING; |
101 | } |
102 | @@ -514,8 +513,8 @@ |
103 | prev[0] = prev[1] = prev[2] = 0.0; |
104 | bool same_color = true; |
105 | |
106 | - for (GSList const *i = objects; i != NULL; i = i->next) { |
107 | - SPObject *obj = reinterpret_cast<SPObject *>(i->data); |
108 | + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i!= objects.end(); i++) { |
109 | + SPObject *obj = *i; |
110 | if (!obj) { |
111 | continue; |
112 | } |
113 | @@ -674,7 +673,7 @@ |
114 | } |
115 | |
116 | // Not color |
117 | - if (g_slist_length(objects) > 1) { |
118 | + if (objects.size() > 1) { |
119 | return QUERY_STYLE_MULTIPLE_SAME; |
120 | } else { |
121 | return QUERY_STYLE_SINGLE; |
122 | @@ -685,9 +684,9 @@ |
123 | * Write to style_res the average opacity of a list of objects. |
124 | */ |
125 | int |
126 | -objects_query_opacity (GSList *objects, SPStyle *style_res) |
127 | +objects_query_opacity (const std::vector<SPItem*> &objects, SPStyle *style_res) |
128 | { |
129 | - if (g_slist_length(objects) == 0) { |
130 | + if (objects.empty()) { |
131 | /* No objects, set empty */ |
132 | return QUERY_STYLE_NOTHING; |
133 | } |
134 | @@ -698,8 +697,8 @@ |
135 | guint opacity_items = 0; |
136 | |
137 | |
138 | - for (GSList const *i = objects; i != NULL; i = i->next) { |
139 | - SPObject *obj = reinterpret_cast<SPObject *>(i->data); |
140 | + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
141 | + SPObject *obj = *i; |
142 | if (!obj) { |
143 | continue; |
144 | } |
145 | @@ -739,9 +738,9 @@ |
146 | * Write to style_res the average stroke width of a list of objects. |
147 | */ |
148 | int |
149 | -objects_query_strokewidth (GSList *objects, SPStyle *style_res) |
150 | +objects_query_strokewidth (const std::vector<SPItem*> &objects, SPStyle *style_res) |
151 | { |
152 | - if (g_slist_length(objects) == 0) { |
153 | + if (objects.empty()) { |
154 | /* No objects, set empty */ |
155 | return QUERY_STYLE_NOTHING; |
156 | } |
157 | @@ -754,8 +753,8 @@ |
158 | |
159 | int n_stroked = 0; |
160 | |
161 | - for (GSList const *i = objects; i != NULL; i = i->next) { |
162 | - SPObject *obj = reinterpret_cast<SPObject *>(i->data); |
163 | + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
164 | + SPObject *obj = *i; |
165 | if (!obj) { |
166 | continue; |
167 | } |
168 | @@ -815,9 +814,9 @@ |
169 | * Write to style_res the average miter limit of a list of objects. |
170 | */ |
171 | int |
172 | -objects_query_miterlimit (GSList *objects, SPStyle *style_res) |
173 | +objects_query_miterlimit (const std::vector<SPItem*> &objects, SPStyle *style_res) |
174 | { |
175 | - if (g_slist_length(objects) == 0) { |
176 | + if (objects.empty()) { |
177 | /* No objects, set empty */ |
178 | return QUERY_STYLE_NOTHING; |
179 | } |
180 | @@ -828,8 +827,8 @@ |
181 | gdouble prev_ml = -1; |
182 | bool same_ml = true; |
183 | |
184 | - for (GSList const *i = objects; i != NULL; i = i->next) { |
185 | - SPObject *obj = reinterpret_cast<SPObject *>(i->data); |
186 | + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
187 | + SPObject *obj = *i; |
188 | if (!dynamic_cast<SPItem *>(obj)) { |
189 | continue; |
190 | } |
191 | @@ -875,9 +874,9 @@ |
192 | * Write to style_res the stroke cap of a list of objects. |
193 | */ |
194 | int |
195 | -objects_query_strokecap (GSList *objects, SPStyle *style_res) |
196 | +objects_query_strokecap (const std::vector<SPItem*> &objects, SPStyle *style_res) |
197 | { |
198 | - if (g_slist_length(objects) == 0) { |
199 | + if (objects.empty()) { |
200 | /* No objects, set empty */ |
201 | return QUERY_STYLE_NOTHING; |
202 | } |
203 | @@ -887,8 +886,8 @@ |
204 | bool same_cap = true; |
205 | int n_stroked = 0; |
206 | |
207 | - for (GSList const *i = objects; i != NULL; i = i->next) { |
208 | - SPObject *obj = reinterpret_cast<SPObject *>(i->data); |
209 | + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
210 | + SPObject *obj = *i; |
211 | if (!dynamic_cast<SPItem *>(obj)) { |
212 | continue; |
213 | } |
214 | @@ -929,9 +928,9 @@ |
215 | * Write to style_res the stroke join of a list of objects. |
216 | */ |
217 | int |
218 | -objects_query_strokejoin (GSList *objects, SPStyle *style_res) |
219 | +objects_query_strokejoin (const std::vector<SPItem*> &objects, SPStyle *style_res) |
220 | { |
221 | - if (g_slist_length(objects) == 0) { |
222 | + if (objects.empty()) { |
223 | /* No objects, set empty */ |
224 | return QUERY_STYLE_NOTHING; |
225 | } |
226 | @@ -941,8 +940,8 @@ |
227 | bool same_join = true; |
228 | int n_stroked = 0; |
229 | |
230 | - for (GSList const *i = objects; i != NULL; i = i->next) { |
231 | - SPObject *obj = reinterpret_cast<SPObject *>(i->data); |
232 | + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
233 | + SPObject *obj = *i; |
234 | if (!dynamic_cast<SPItem *>(obj)) { |
235 | continue; |
236 | } |
237 | @@ -984,7 +983,7 @@ |
238 | * Write to style_res the average font size and spacing of objects. |
239 | */ |
240 | int |
241 | -objects_query_fontnumbers (GSList *objects, SPStyle *style_res) |
242 | +objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_res) |
243 | { |
244 | bool different = false; |
245 | |
246 | @@ -1004,8 +1003,8 @@ |
247 | int texts = 0; |
248 | int no_size = 0; |
249 | |
250 | - for (GSList const *i = objects; i != NULL; i = i->next) { |
251 | - SPObject *obj = reinterpret_cast<SPObject *>(i->data); |
252 | + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
253 | + SPObject *obj = *i; |
254 | |
255 | if (!isTextualItem(obj)) { |
256 | continue; |
257 | @@ -1116,15 +1115,15 @@ |
258 | * Write to style_res the average font style of objects. |
259 | */ |
260 | int |
261 | -objects_query_fontstyle (GSList *objects, SPStyle *style_res) |
262 | +objects_query_fontstyle (const std::vector<SPItem*> &objects, SPStyle *style_res) |
263 | { |
264 | bool different = false; |
265 | bool set = false; |
266 | |
267 | int texts = 0; |
268 | |
269 | - for (GSList const *i = objects; i != NULL; i = i->next) { |
270 | - SPObject *obj = reinterpret_cast<SPObject *>(i->data); |
271 | + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
272 | + SPObject *obj = *i; |
273 | |
274 | if (!isTextualItem(obj)) { |
275 | continue; |
276 | @@ -1173,7 +1172,7 @@ |
277 | * Write to style_res the baseline numbers. |
278 | */ |
279 | static int |
280 | -objects_query_baselines (GSList *objects, SPStyle *style_res) |
281 | +objects_query_baselines (const std::vector<SPItem*> &objects, SPStyle *style_res) |
282 | { |
283 | bool different = false; |
284 | |
285 | @@ -1192,8 +1191,8 @@ |
286 | |
287 | int texts = 0; |
288 | |
289 | - for (GSList const *i = objects; i != NULL; i = i->next) { |
290 | - SPObject *obj = reinterpret_cast<SPObject *>(i->data); |
291 | + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
292 | + SPObject *obj = *i; |
293 | |
294 | if (!isTextualItem(obj)) { |
295 | continue; |
296 | @@ -1269,7 +1268,7 @@ |
297 | * Write to style_res the average font family of objects. |
298 | */ |
299 | int |
300 | -objects_query_fontfamily (GSList *objects, SPStyle *style_res) |
301 | +objects_query_fontfamily (const std::vector<SPItem*> &objects, SPStyle *style_res) |
302 | { |
303 | bool different = false; |
304 | int texts = 0; |
305 | @@ -1280,8 +1279,8 @@ |
306 | } |
307 | style_res->font_family.set = FALSE; |
308 | |
309 | - for (GSList const *i = objects; i != NULL; i = i->next) { |
310 | - SPObject *obj = reinterpret_cast<SPObject *>(i->data); |
311 | + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
312 | + SPObject *obj = *i; |
313 | |
314 | // std::cout << " " << reinterpret_cast<SPObject*>(i->data)->getId() << std::endl; |
315 | if (!isTextualItem(obj)) { |
316 | @@ -1325,7 +1324,7 @@ |
317 | } |
318 | |
319 | static int |
320 | -objects_query_fontspecification (GSList *objects, SPStyle *style_res) |
321 | +objects_query_fontspecification (const std::vector<SPItem*> &objects, SPStyle *style_res) |
322 | { |
323 | bool different = false; |
324 | int texts = 0; |
325 | @@ -1336,8 +1335,8 @@ |
326 | } |
327 | style_res->font_specification.set = FALSE; |
328 | |
329 | - for (GSList const *i = objects; i != NULL; i = i->next) { |
330 | - SPObject *obj = reinterpret_cast<SPObject *>(i->data); |
331 | + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
332 | + SPObject *obj = *i; |
333 | |
334 | // std::cout << " " << reinterpret_cast<SPObject*>(i->data)->getId() << std::endl; |
335 | if (!isTextualItem(obj)) { |
336 | @@ -1385,7 +1384,7 @@ |
337 | } |
338 | |
339 | static int |
340 | -objects_query_blend (GSList *objects, SPStyle *style_res) |
341 | +objects_query_blend (const std::vector<SPItem*> &objects, SPStyle *style_res) |
342 | { |
343 | const int empty_prev = -2; |
344 | const int complex_filter = 5; |
345 | @@ -1394,8 +1393,8 @@ |
346 | bool same_blend = true; |
347 | guint items = 0; |
348 | |
349 | - for (GSList const *i = objects; i != NULL; i = i->next) { |
350 | - SPObject *obj = reinterpret_cast<SPObject *>(i->data); |
351 | + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
352 | + SPObject *obj = *i; |
353 | if (!obj) { |
354 | continue; |
355 | } |
356 | @@ -1471,9 +1470,9 @@ |
357 | * Write to style_res the average blurring of a list of objects. |
358 | */ |
359 | int |
360 | -objects_query_blur (GSList *objects, SPStyle *style_res) |
361 | +objects_query_blur (const std::vector<SPItem*> &objects, SPStyle *style_res) |
362 | { |
363 | - if (g_slist_length(objects) == 0) { |
364 | + if (objects.empty()) { |
365 | /* No objects, set empty */ |
366 | return QUERY_STYLE_NOTHING; |
367 | } |
368 | @@ -1484,8 +1483,8 @@ |
369 | guint blur_items = 0; |
370 | guint items = 0; |
371 | |
372 | - for (GSList const *i = objects; i != NULL; i = i->next) { |
373 | - SPObject *obj = reinterpret_cast<SPObject *>(i->data); |
374 | + for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); i++) { |
375 | + SPObject *obj = *i; |
376 | if (!obj) { |
377 | continue; |
378 | } |
379 | @@ -1553,7 +1552,7 @@ |
380 | * the result to style, return appropriate flag. |
381 | */ |
382 | int |
383 | -sp_desktop_query_style_from_list (GSList *list, SPStyle *style, int property) |
384 | +sp_desktop_query_style_from_list (const std::vector<SPItem*> &list, SPStyle *style, int property) |
385 | { |
386 | if (property == QUERY_STYLE_PROPERTY_FILL) { |
387 | return objects_query_fillstroke (list, style, true); |
388 | @@ -1606,7 +1605,7 @@ |
389 | |
390 | // otherwise, do querying and averaging over selection |
391 | if (desktop->selection != NULL) { |
392 | - return sp_desktop_query_style_from_list ((GSList *) desktop->selection->itemList(), style, property); |
393 | + return sp_desktop_query_style_from_list (desktop->selection->itemList(), style, property); |
394 | } |
395 | |
396 | return QUERY_STYLE_NOTHING; |
397 | |
398 | === modified file 'src/desktop-style.h' |
399 | --- src/desktop-style.h 2014-10-08 02:22:03 +0000 |
400 | +++ src/desktop-style.h 2015-04-29 21:03:59 +0000 |
401 | @@ -17,6 +17,7 @@ |
402 | class SPCSSAttr; |
403 | class SPDesktop; |
404 | class SPObject; |
405 | +class SPItem; |
406 | class SPStyle; |
407 | typedef struct _GSList GSList; |
408 | namespace Inkscape { |
409 | @@ -64,21 +65,21 @@ |
410 | double sp_desktop_get_font_size_tool (SPDesktop *desktop); |
411 | void sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, Glib::ustring const &tool, bool with_text); |
412 | |
413 | -gdouble stroke_average_width (GSList const *objects); |
414 | - |
415 | -int objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill); |
416 | -int objects_query_fontnumbers (GSList *objects, SPStyle *style_res); |
417 | -int objects_query_fontstyle (GSList *objects, SPStyle *style_res); |
418 | -int objects_query_fontfamily (GSList *objects, SPStyle *style_res); |
419 | -int objects_query_opacity (GSList *objects, SPStyle *style_res); |
420 | -int objects_query_strokewidth (GSList *objects, SPStyle *style_res); |
421 | -int objects_query_miterlimit (GSList *objects, SPStyle *style_res); |
422 | -int objects_query_strokecap (GSList *objects, SPStyle *style_res); |
423 | -int objects_query_strokejoin (GSList *objects, SPStyle *style_res); |
424 | - |
425 | -int objects_query_blur (GSList *objects, SPStyle *style_res); |
426 | - |
427 | -int sp_desktop_query_style_from_list (GSList *list, SPStyle *style, int property); |
428 | +gdouble stroke_average_width (const std::vector<SPItem*> &objects); |
429 | + |
430 | +int objects_query_fillstroke (const std::vector<SPItem*> &objects, SPStyle *style_res, bool const isfill); |
431 | +int objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_res); |
432 | +int objects_query_fontstyle (const std::vector<SPItem*> &objects, SPStyle *style_res); |
433 | +int objects_query_fontfamily (const std::vector<SPItem*> &objects, SPStyle *style_res); |
434 | +int objects_query_opacity (const std::vector<SPItem*> &objects, SPStyle *style_res); |
435 | +int objects_query_strokewidth (const std::vector<SPItem*> &objects, SPStyle *style_res); |
436 | +int objects_query_miterlimit (const std::vector<SPItem*> &objects, SPStyle *style_res); |
437 | +int objects_query_strokecap (const std::vector<SPItem*> &objects, SPStyle *style_res); |
438 | +int objects_query_strokejoin (const std::vector<SPItem*> &objects, SPStyle *style_res); |
439 | + |
440 | +int objects_query_blur (const std::vector<SPItem*> &objects, SPStyle *style_res); |
441 | + |
442 | +int sp_desktop_query_style_from_list (const std::vector<SPItem*> &list, SPStyle *style, int property); |
443 | int sp_desktop_query_style(SPDesktop *desktop, SPStyle *style, int property); |
444 | bool sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query); |
445 | |
446 | |
447 | === modified file 'src/desktop.cpp' |
448 | --- src/desktop.cpp 2015-02-25 01:04:28 +0000 |
449 | +++ src/desktop.cpp 2015-04-29 21:03:59 +0000 |
450 | @@ -716,7 +716,7 @@ |
451 | /** |
452 | * \see SPDocument::getItemFromListAtPointBottom() |
453 | */ |
454 | -SPItem *SPDesktop::getItemFromListAtPointBottom(const GSList *list, Geom::Point const &p) const |
455 | +SPItem *SPDesktop::getItemFromListAtPointBottom(const std::vector<SPItem*> &list, Geom::Point const &p) const |
456 | { |
457 | g_return_val_if_fail (doc() != NULL, NULL); |
458 | return SPDocument::getItemFromListAtPointBottom(dkey, doc()->getRoot(), list, p); |
459 | |
460 | === modified file 'src/desktop.h' |
461 | --- src/desktop.h 2014-12-21 21:58:32 +0000 |
462 | +++ src/desktop.h 2015-04-29 21:03:59 +0000 |
463 | @@ -319,7 +319,7 @@ |
464 | //void push_event_context (GType type, const gchar *config, unsigned int key); |
465 | |
466 | void set_coordinate_status (Geom::Point p); |
467 | - SPItem *getItemFromListAtPointBottom(const GSList *list, Geom::Point const &p) const; |
468 | + SPItem *getItemFromListAtPointBottom(const std::vector<SPItem*> &list, Geom::Point const &p) const; |
469 | SPItem *getItemAtPoint(Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const; |
470 | SPItem *getGroupAtPoint(Geom::Point const &p) const; |
471 | Geom::Point point() const; |
472 | |
473 | === modified file 'src/document.cpp' |
474 | --- src/document.cpp 2015-03-21 11:41:01 +0000 |
475 | +++ src/document.cpp 2015-04-29 21:03:59 +0000 |
476 | @@ -1266,7 +1266,7 @@ |
477 | return area.intersects(box); |
478 | } |
479 | |
480 | -static GSList *find_items_in_area(GSList *s, SPGroup *group, unsigned int dkey, Geom::Rect const &area, |
481 | +static std::vector<SPItem*> &find_items_in_area(std::vector<SPItem*> &s, SPGroup *group, unsigned int dkey, Geom::Rect const &area, |
482 | bool (*test)(Geom::Rect const &, Geom::Rect const &), bool take_insensitive = false) |
483 | { |
484 | g_return_val_if_fail(SP_IS_GROUP(group), s); |
485 | @@ -1279,7 +1279,7 @@ |
486 | SPItem *child = SP_ITEM(o); |
487 | Geom::OptRect box = child->desktopVisualBounds(); |
488 | if ( box && test(area, *box) && (take_insensitive || child->isVisibleAndUnlocked(dkey))) { |
489 | - s = g_slist_append(s, child); |
490 | + s.push_back(child); |
491 | } |
492 | } |
493 | } |
494 | @@ -1306,7 +1306,7 @@ |
495 | return inGroup; |
496 | } |
497 | |
498 | -SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, GSList const *list,Geom::Point const &p, bool take_insensitive) |
499 | +SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, std::vector<SPItem*> const &list,Geom::Point const &p, bool take_insensitive) |
500 | { |
501 | g_return_val_if_fail(group, NULL); |
502 | SPItem *bottomMost = 0; |
503 | @@ -1320,7 +1320,7 @@ |
504 | Inkscape::DrawingItem *arenaitem = item->get_arenaitem(dkey); |
505 | if (arenaitem && arenaitem->pick(p, delta, 1) != NULL |
506 | && (take_insensitive || item->isVisibleAndUnlocked(dkey))) { |
507 | - if (g_slist_find((GSList *) list, item) != NULL) { |
508 | + if (find(list.begin(),list.end(),item)!=list.end() ) { |
509 | bottomMost = item; |
510 | } |
511 | } |
512 | @@ -1422,11 +1422,11 @@ |
513 | * Assumes box is normalized (and g_asserts it!) |
514 | * |
515 | */ |
516 | -GSList *SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) const |
517 | +std::vector<SPItem*> SPDocument::getItemsInBox(unsigned int dkey, Geom::Rect const &box) const |
518 | { |
519 | - g_return_val_if_fail(this->priv != NULL, NULL); |
520 | - |
521 | - return find_items_in_area(NULL, SP_GROUP(this->root), dkey, box, is_within); |
522 | + std::vector<SPItem*> x; |
523 | + g_return_val_if_fail(this->priv != NULL, x); |
524 | + return find_items_in_area(x, SP_GROUP(this->root), dkey, box, is_within); |
525 | } |
526 | |
527 | /* |
528 | @@ -1436,16 +1436,16 @@ |
529 | * |
530 | */ |
531 | |
532 | -GSList *SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const |
533 | +std::vector<SPItem*> SPDocument::getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const |
534 | { |
535 | - g_return_val_if_fail(this->priv != NULL, NULL); |
536 | - |
537 | - return find_items_in_area(NULL, SP_GROUP(this->root), dkey, box, overlaps); |
538 | + std::vector<SPItem*> x; |
539 | + g_return_val_if_fail(this->priv != NULL, x); |
540 | + return find_items_in_area(x, SP_GROUP(this->root), dkey, box, overlaps); |
541 | } |
542 | |
543 | -GSList *SPDocument::getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const |
544 | +std::vector<SPItem*> SPDocument::getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const |
545 | { |
546 | - GSList *items = NULL; |
547 | + std::vector<SPItem*> items; |
548 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
549 | |
550 | // When picking along the path, we don't want small objects close together |
551 | @@ -1454,11 +1454,11 @@ |
552 | gdouble saved_delta = prefs->getDouble("/options/cursortolerance/value", 1.0); |
553 | prefs->setDouble("/options/cursortolerance/value", 0.25); |
554 | |
555 | - for(unsigned int i = 0; i < points.size(); i++) { |
556 | + for(int i = points.size()-1;i>=0; i--) { |
557 | SPItem *item = getItemAtPoint(key, points[i], |
558 | false, NULL); |
559 | - if (item && !g_slist_find(items, item)) |
560 | - items = g_slist_prepend (items, item); |
561 | + if (item && items.end()==find(items.begin(),items.end(), item)) |
562 | + items.push_back(item); |
563 | } |
564 | |
565 | // and now we restore it back |
566 | |
567 | === modified file 'src/document.h' |
568 | --- src/document.h 2015-03-21 11:41:01 +0000 |
569 | +++ src/document.h 2015-04-29 21:03:59 +0000 |
570 | @@ -232,7 +232,7 @@ |
571 | /** |
572 | * Returns the bottommost item from the list which is at the point, or NULL if none. |
573 | */ |
574 | - static SPItem *getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, const GSList *list, Geom::Point const &p, bool take_insensitive = false); |
575 | + static SPItem *getItemFromListAtPointBottom(unsigned int dkey, SPGroup *group, const std::vector<SPItem*> &list, Geom::Point const &p, bool take_insensitive = false); |
576 | |
577 | static SPDocument *createDoc(Inkscape::XML::Document *rdoc, char const *uri, |
578 | char const *base, char const *name, unsigned int keepalive, |
579 | @@ -259,10 +259,10 @@ |
580 | bool addResource(char const *key, SPObject *object); |
581 | bool removeResource(char const *key, SPObject *object); |
582 | const GSList *getResourceList(char const *key) const; |
583 | - GSList *getItemsInBox(unsigned int dkey, Geom::Rect const &box) const; |
584 | - GSList *getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const; |
585 | + std::vector<SPItem*> getItemsInBox(unsigned int dkey, Geom::Rect const &box) const; |
586 | + std::vector<SPItem*> getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const; |
587 | SPItem *getItemAtPoint(unsigned int key, Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const; |
588 | - GSList *getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const; |
589 | + std::vector<SPItem*> getItemsAtPoints(unsigned const key, std::vector<Geom::Point> points) const; |
590 | SPItem *getGroupAtPoint(unsigned int key, Geom::Point const &p) const; |
591 | |
592 | void changeUriAndHrefs(char const *uri); |
593 | |
594 | === modified file 'src/extension/execution-env.cpp' |
595 | --- src/extension/execution-env.cpp 2015-04-27 23:38:31 +0000 |
596 | +++ src/extension/execution-env.cpp 2015-04-29 21:03:59 +0000 |
597 | @@ -60,14 +60,12 @@ |
598 | sp_namedview_document_from_window(desktop); |
599 | |
600 | if (desktop != NULL) { |
601 | - Inkscape::Util::GSListConstIterator<SPItem *> selected = |
602 | - desktop->getSelection()->itemList(); |
603 | - while ( selected != NULL ) { |
604 | + std::vector<SPItem*> selected = desktop->getSelection()->itemList(); |
605 | + for(std::vector<SPItem*>::const_iterator x = selected.begin(); x != selected.end(); x++){ |
606 | Glib::ustring selected_id; |
607 | - selected_id = (*selected)->getId(); |
608 | + selected_id = (*x)->getId(); |
609 | _selected.insert(_selected.end(), selected_id); |
610 | //std::cout << "Selected: " << selected_id << std::endl; |
611 | - ++selected; |
612 | } |
613 | } |
614 | |
615 | |
616 | === modified file 'src/extension/implementation/implementation.cpp' |
617 | --- src/extension/implementation/implementation.cpp 2014-12-21 21:58:32 +0000 |
618 | +++ src/extension/implementation/implementation.cpp 2015-04-29 21:03:59 +0000 |
619 | @@ -47,12 +47,10 @@ |
620 | |
621 | SPDocument * current_document = view->doc(); |
622 | |
623 | - using Inkscape::Util::GSListConstIterator; |
624 | - // FIXME very unsafe cast |
625 | - GSListConstIterator<SPItem *> selected = ((SPDesktop *)view)->getSelection()->itemList(); |
626 | + std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); |
627 | Inkscape::XML::Node const* first_select = NULL; |
628 | - if (selected != NULL) { |
629 | - const SPItem * item = *selected; |
630 | + if (!selected.empty()) { |
631 | + const SPItem * item = selected[0]; |
632 | first_select = item->getRepr(); |
633 | } |
634 | |
635 | |
636 | === modified file 'src/extension/implementation/script.cpp' |
637 | --- src/extension/implementation/script.cpp 2015-04-27 16:01:19 +0000 |
638 | +++ src/extension/implementation/script.cpp 2015-04-29 21:03:59 +0000 |
639 | @@ -689,14 +689,13 @@ |
640 | return; |
641 | } |
642 | |
643 | - Inkscape::Util::GSListConstIterator<SPItem *> selected = |
644 | + std::vector<SPItem*> selected = |
645 | desktop->getSelection()->itemList(); //desktop should not be NULL since doc was checked and desktop is a casted pointer |
646 | - while ( selected != NULL ) { |
647 | + for(std::vector<SPItem*>::const_iterator x = selected.begin(); x != selected.end(); x++){ |
648 | Glib::ustring selected_id; |
649 | selected_id += "--id="; |
650 | - selected_id += (*selected)->getId(); |
651 | + selected_id += (*x)->getId(); |
652 | params.insert(params.begin(), selected_id); |
653 | - ++selected; |
654 | } |
655 | |
656 | file_listener fileout; |
657 | |
658 | === modified file 'src/extension/internal/bitmap/imagemagick.cpp' |
659 | --- src/extension/internal/bitmap/imagemagick.cpp 2015-04-27 23:38:31 +0000 |
660 | +++ src/extension/internal/bitmap/imagemagick.cpp 2015-04-29 21:03:59 +0000 |
661 | @@ -66,8 +66,8 @@ |
662 | _imageItems(NULL) |
663 | { |
664 | SPDesktop *desktop = (SPDesktop*)view; |
665 | - const GSList *selectedItemList = desktop->selection->itemList(); |
666 | - int selectCount = g_slist_length((GSList *)selectedItemList); |
667 | + const std::vector<SPItem*> selectedItemList = desktop->selection->itemList(); |
668 | + int selectCount = selectedItemList.size(); |
669 | |
670 | // Init the data-holders |
671 | _nodes = new Inkscape::XML::Node*[selectCount]; |
672 | @@ -79,9 +79,8 @@ |
673 | _imageItems = new SPItem*[selectCount]; |
674 | |
675 | // Loop through selected items |
676 | - for (; selectedItemList != NULL; selectedItemList = g_slist_next(selectedItemList)) |
677 | - { |
678 | - SPItem *item = SP_ITEM(selectedItemList->data); |
679 | + for (std::vector<SPItem*>::const_iterator i = selectedItemList.begin(); i != selectedItemList.end(); i++) { |
680 | + SPItem *item = *i; |
681 | Inkscape::XML::Node *node = reinterpret_cast<Inkscape::XML::Node *>(item->getRepr()); |
682 | if (!strcmp(node->name(), "image") || !strcmp(node->name(), "svg:image")) |
683 | { |
684 | @@ -237,13 +236,10 @@ |
685 | { |
686 | SPDocument * current_document = view->doc(); |
687 | |
688 | - using Inkscape::Util::GSListConstIterator; |
689 | - |
690 | - // FIXME very unsafe cast |
691 | - GSListConstIterator<SPItem *> selected = ((SPDesktop *)view)->getSelection()->itemList(); |
692 | + std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); |
693 | Inkscape::XML::Node * first_select = NULL; |
694 | - if (selected != NULL) { |
695 | - first_select = (*selected)->getRepr(); |
696 | + if (!selected.empty()) { |
697 | + first_select = (selected.front())->getRepr(); |
698 | } |
699 | |
700 | return module->autogui(current_document, first_select, changeSignal); |
701 | |
702 | === modified file 'src/extension/internal/bluredge.cpp' |
703 | --- src/extension/internal/bluredge.cpp 2014-03-27 01:33:44 +0000 |
704 | +++ src/extension/internal/bluredge.cpp 2015-04-29 21:03:59 +0000 |
705 | @@ -63,13 +63,11 @@ |
706 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
707 | double old_offset = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px"); |
708 | |
709 | - using Inkscape::Util::GSListConstIterator; |
710 | // TODO need to properly refcount the items, at least |
711 | - std::list<SPItem *> items; |
712 | - items.insert<GSListConstIterator<SPItem *> >(items.end(), selection->itemList(), NULL); |
713 | + std::vector<SPItem*> items(selection->itemList()); |
714 | selection->clear(); |
715 | |
716 | - for(std::list<SPItem *>::iterator item = items.begin(); |
717 | + for(std::vector<SPItem*>::iterator item = items.begin(); |
718 | item != items.end(); ++item) { |
719 | SPItem * spitem = *item; |
720 | |
721 | |
722 | === modified file 'src/extension/internal/cairo-renderer.cpp' |
723 | --- src/extension/internal/cairo-renderer.cpp 2015-03-17 17:09:10 +0000 |
724 | +++ src/extension/internal/cairo-renderer.cpp 2015-04-29 21:03:59 +0000 |
725 | @@ -294,14 +294,12 @@ |
726 | CairoRenderer *renderer = ctx->getRenderer(); |
727 | TRACE(("sp_group_render opacity: %f\n", SP_SCALE24_TO_FLOAT(item->style->opacity.value))); |
728 | |
729 | - GSList *l = g_slist_reverse(group->childList(false)); |
730 | - while (l) { |
731 | - SPObject *o = reinterpret_cast<SPObject *>(l->data); |
732 | - SPItem *item = dynamic_cast<SPItem *>(o); |
733 | + std::vector<SPObject*> l(group->childList(false)); |
734 | + for(std::vector<SPObject*>::const_iterator x = l.begin(); x!= l.end(); x++){ |
735 | + SPItem *item = static_cast<SPItem*>(*x); |
736 | if (item) { |
737 | renderer->renderItem(ctx, item); |
738 | } |
739 | - l = g_slist_remove (l, o); |
740 | } |
741 | } |
742 | |
743 | |
744 | === modified file 'src/extension/internal/filter/filter.cpp' |
745 | --- src/extension/internal/filter/filter.cpp 2014-03-27 01:33:44 +0000 |
746 | +++ src/extension/internal/filter/filter.cpp 2015-04-29 21:03:59 +0000 |
747 | @@ -125,15 +125,13 @@ |
748 | //printf("Calling filter effect\n"); |
749 | Inkscape::Selection * selection = ((SPDesktop *)document)->selection; |
750 | |
751 | - using Inkscape::Util::GSListConstIterator; |
752 | // TODO need to properly refcount the items, at least |
753 | - std::list<SPItem *> items; |
754 | - items.insert<GSListConstIterator<SPItem *> >(items.end(), selection->itemList(), NULL); |
755 | + std::vector<SPItem*> items(selection->itemList()); |
756 | |
757 | Inkscape::XML::Document * xmldoc = document->doc()->getReprDoc(); |
758 | Inkscape::XML::Node * defsrepr = document->doc()->getDefs()->getRepr(); |
759 | |
760 | - for(std::list<SPItem *>::iterator item = items.begin(); |
761 | + for(std::vector<SPItem*>::iterator item = items.begin(); |
762 | item != items.end(); ++item) { |
763 | SPItem * spitem = *item; |
764 | Inkscape::XML::Node * node = spitem->getRepr(); |
765 | |
766 | === modified file 'src/extension/internal/grid.cpp' |
767 | --- src/extension/internal/grid.cpp 2015-04-27 23:38:31 +0000 |
768 | +++ src/extension/internal/grid.cpp 2015-04-29 21:03:59 +0000 |
769 | @@ -186,13 +186,10 @@ |
770 | { |
771 | SPDocument * current_document = view->doc(); |
772 | |
773 | - using Inkscape::Util::GSListConstIterator; |
774 | - |
775 | - // FIXME very unsafe cast |
776 | - GSListConstIterator<SPItem *> selected = ((SPDesktop *)view)->getSelection()->itemList(); |
777 | + std::vector<SPItem*> selected = ((SPDesktop *)view)->getSelection()->itemList(); |
778 | Inkscape::XML::Node * first_select = NULL; |
779 | - if (selected != NULL) { |
780 | - first_select = (*selected)->getRepr(); |
781 | + if (!selected.empty()) { |
782 | + first_select = selected[0]->getRepr(); |
783 | } |
784 | |
785 | return module->autogui(current_document, first_select, changeSignal); |
786 | |
787 | === modified file 'src/extension/internal/latex-text-renderer.cpp' |
788 | --- src/extension/internal/latex-text-renderer.cpp 2014-11-10 17:39:33 +0000 |
789 | +++ src/extension/internal/latex-text-renderer.cpp 2015-04-29 21:03:59 +0000 |
790 | @@ -228,14 +228,12 @@ |
791 | |
792 | void LaTeXTextRenderer::sp_group_render(SPGroup *group) |
793 | { |
794 | - GSList *l = g_slist_reverse(group->childList(false)); |
795 | - while (l) { |
796 | - SPObject *o = reinterpret_cast<SPObject *>(l->data); |
797 | - SPItem *item = dynamic_cast<SPItem *>(o); |
798 | + std::vector<SPObject*> l = (group->childList(false)); |
799 | + for(std::vector<SPObject*>::const_iterator x = l.begin(); x != l.end(); x++){ |
800 | + SPItem *item = static_cast<SPItem*>(*x); |
801 | if (item) { |
802 | renderItem(item); |
803 | } |
804 | - l = g_slist_remove (l, o); |
805 | } |
806 | } |
807 | |
808 | |
809 | === modified file 'src/file.cpp' |
810 | --- src/file.cpp 2015-02-23 16:48:29 +0000 |
811 | +++ src/file.cpp 2015-04-29 21:03:59 +0000 |
812 | @@ -1069,7 +1069,7 @@ |
813 | desktop->doc()->importDefs(clipdoc); |
814 | |
815 | // copy objects |
816 | - GSList *pasted_objects = NULL; |
817 | + std::vector<Inkscape::XML::Node*> pasted_objects; |
818 | for (Inkscape::XML::Node *obj = root->firstChild() ; obj ; obj = obj->next()) { |
819 | // Don't copy metadata, defs, named views and internal clipboard contents to the document |
820 | if (!strcmp(obj->name(), "svg:defs")) { |
821 | @@ -1088,9 +1088,8 @@ |
822 | target_parent->appendChild(obj_copy); |
823 | Inkscape::GC::release(obj_copy); |
824 | |
825 | - pasted_objects = g_slist_prepend(pasted_objects, (gpointer) obj_copy); |
826 | + pasted_objects.push_back(obj_copy); |
827 | } |
828 | - |
829 | // Change the selection to the freshly pasted objects |
830 | Inkscape::Selection *selection = desktop->getSelection(); |
831 | selection->setReprList(pasted_objects); |
832 | @@ -1129,8 +1128,6 @@ |
833 | |
834 | sp_selection_move_relative(selection, offset); |
835 | } |
836 | - |
837 | - g_slist_free(pasted_objects); |
838 | } |
839 | |
840 | |
841 | |
842 | === modified file 'src/gradient-chemistry.cpp' |
843 | --- src/gradient-chemistry.cpp 2015-03-01 08:57:53 +0000 |
844 | +++ src/gradient-chemistry.cpp 2015-04-29 21:03:59 +0000 |
845 | @@ -1570,8 +1570,9 @@ |
846 | { |
847 | Inkscape::Selection *selection = desktop->getSelection(); |
848 | |
849 | - for (GSList const* i = selection->itemList(); i != NULL; i = i->next) { |
850 | - sp_item_gradient_invert_vector_color(SP_ITEM(i->data), fill_or_stroke); |
851 | + const std::vector<SPItem*> list=selection->itemList(); |
852 | + for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); i++) { |
853 | + sp_item_gradient_invert_vector_color(*i, fill_or_stroke); |
854 | } |
855 | |
856 | // we did an undoable action |
857 | @@ -1594,9 +1595,10 @@ |
858 | if (drag && drag->selected) { |
859 | drag->selected_reverse_vector(); |
860 | } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients) |
861 | - for (GSList const* i = selection->itemList(); i != NULL; i = i->next) { |
862 | - sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_FILL); |
863 | - sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_STROKE); |
864 | + const std::vector<SPItem*> list=selection->itemList(); |
865 | + for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); i++) { |
866 | + sp_item_gradient_reverse_vector(*i, Inkscape::FOR_FILL); |
867 | + sp_item_gradient_reverse_vector(*i, Inkscape::FOR_STROKE); |
868 | } |
869 | } |
870 | |
871 | |
872 | === modified file 'src/gradient-drag.cpp' |
873 | --- src/gradient-drag.cpp 2015-03-01 08:57:53 +0000 |
874 | +++ src/gradient-drag.cpp 2015-04-29 21:03:59 +0000 |
875 | @@ -2082,9 +2082,9 @@ |
876 | this->draggers = NULL; |
877 | |
878 | g_return_if_fail(this->selection != NULL); |
879 | - |
880 | - for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) { |
881 | - SPItem *item = SP_ITEM(i->data); |
882 | + std::vector<SPItem*> list = this->selection->itemList(); |
883 | + for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); i++) { |
884 | + SPItem *item = *i; |
885 | SPStyle *style = item->style; |
886 | |
887 | if (style && (style->fill.isPaintserver())) { |
888 | @@ -2151,9 +2151,9 @@ |
889 | |
890 | g_return_if_fail(this->selection != NULL); |
891 | |
892 | - for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) { |
893 | - |
894 | - SPItem *item = SP_ITEM(i->data); |
895 | + std::vector<SPItem*> list = this->selection->itemList(); |
896 | + for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); i++) { |
897 | + SPItem *item = *i; |
898 | |
899 | SPStyle *style = item->style; |
900 | |
901 | @@ -2295,8 +2295,9 @@ |
902 | |
903 | g_return_if_fail (this->selection != NULL); |
904 | |
905 | - for (GSList const* i = this->selection->itemList(); i != NULL; i = i->next) { |
906 | - SPItem *item = SP_ITEM(i->data); |
907 | + std::vector<SPItem*> list = this->selection->itemList(); |
908 | + for (std::vector<SPItem*>::const_iterator i = list.begin(); i != list.end(); i++) { |
909 | + SPItem *item = *i; |
910 | Geom::OptRect rect = item->desktopVisualBounds(); |
911 | if (rect) { |
912 | // Remember the edges of the bbox and the center axis |
913 | |
914 | === modified file 'src/graphlayout.cpp' |
915 | --- src/graphlayout.cpp 2014-11-26 01:35:57 +0000 |
916 | +++ src/graphlayout.cpp 2015-04-29 21:03:59 +0000 |
917 | @@ -88,9 +88,9 @@ |
918 | * Scans the items list and places those items that are |
919 | * not connectors in filtered |
920 | */ |
921 | -void filterConnectors(GSList const *const items, list<SPItem *> &filtered) { |
922 | - for(GSList *i=(GSList *)items; i!=NULL; i=i->next) { |
923 | - SPItem *item=SP_ITEM(i->data); |
924 | +void filterConnectors(std::vector<SPItem*> const &items, list<SPItem *> &filtered) { |
925 | + for(std::vector<SPItem*>::const_iterator i = items.begin();i !=items.end(); i++){ |
926 | + SPItem *item = *i; |
927 | if(!isConnector(item)) { |
928 | filtered.push_back(item); |
929 | } |
930 | @@ -101,8 +101,8 @@ |
931 | * connectors between them, and uses graph layout techniques to find |
932 | * a nice layout |
933 | */ |
934 | -void graphlayout(GSList const *const items) { |
935 | - if(!items) { |
936 | +void graphlayout(std::vector<SPItem*> const &items) { |
937 | + if(items.empty()) { |
938 | return; |
939 | } |
940 | |
941 | |
942 | === modified file 'src/graphlayout.h' |
943 | --- src/graphlayout.h 2014-10-08 02:22:03 +0000 |
944 | +++ src/graphlayout.h 2015-04-29 21:03:59 +0000 |
945 | @@ -19,10 +19,10 @@ |
946 | typedef struct _GSList GSList; |
947 | class SPItem; |
948 | |
949 | -void graphlayout(GSList const *const items); |
950 | +void graphlayout(std::vector<SPItem*> const &items); |
951 | |
952 | bool isConnector(SPItem const *const item); |
953 | |
954 | -void filterConnectors(GSList const *const items, std::list<SPItem *> &filtered); |
955 | +void filterConnectors(std::vector<SPItem*> const &items, std::list<SPItem *> &filtered); |
956 | |
957 | #endif // SEEN_GRAPHLAYOUT_H |
958 | |
959 | === modified file 'src/helper/png-write.cpp' |
960 | --- src/helper/png-write.cpp 2014-10-05 16:38:15 +0000 |
961 | +++ src/helper/png-write.cpp 2015-04-29 21:03:59 +0000 |
962 | @@ -361,19 +361,19 @@ |
963 | /** |
964 | * Hide all items that are not listed in list, recursively, skipping groups and defs. |
965 | */ |
966 | -static void hide_other_items_recursively(SPObject *o, GSList *list, unsigned dkey) |
967 | +static void hide_other_items_recursively(SPObject *o, const std::vector<SPItem*> &list, unsigned dkey) |
968 | { |
969 | if ( SP_IS_ITEM(o) |
970 | && !SP_IS_DEFS(o) |
971 | && !SP_IS_ROOT(o) |
972 | && !SP_IS_GROUP(o) |
973 | - && !g_slist_find(list, o) ) |
974 | + && list.end()==find(list.begin(),list.end(),o)) |
975 | { |
976 | SP_ITEM(o)->invoke_hide(dkey); |
977 | } |
978 | |
979 | // recurse |
980 | - if (!g_slist_find(list, o)) { |
981 | + if (list.end()==find(list.begin(),list.end(),o)) { |
982 | for ( SPObject *child = o->firstChild() ; child; child = child->getNext() ) { |
983 | hide_other_items_recursively(child, list, dkey); |
984 | } |
985 | @@ -387,7 +387,7 @@ |
986 | unsigned long bgcolor, |
987 | unsigned int (*status) (float, void *), |
988 | void *data, bool force_overwrite, |
989 | - GSList *items_only) |
990 | + const std::vector<SPItem*> &items_only) |
991 | { |
992 | return sp_export_png_file(doc, filename, Geom::Rect(Geom::Point(x0,y0),Geom::Point(x1,y1)), |
993 | width, height, xdpi, ydpi, bgcolor, status, data, force_overwrite, items_only); |
994 | @@ -399,7 +399,7 @@ |
995 | unsigned long bgcolor, |
996 | unsigned (*status)(float, void *), |
997 | void *data, bool force_overwrite, |
998 | - GSList *items_only) |
999 | + const std::vector<SPItem*> &items_only) |
1000 | { |
1001 | g_return_val_if_fail(doc != NULL, EXPORT_ERROR); |
1002 | g_return_val_if_fail(filename != NULL, EXPORT_ERROR); |
1003 | @@ -457,7 +457,7 @@ |
1004 | |
1005 | // We show all and then hide all items we don't want, instead of showing only requested items, |
1006 | // because that would not work if the shown item references something in defs |
1007 | - if (items_only) { |
1008 | + if (!items_only.empty()) { |
1009 | hide_other_items_recursively(doc->getRoot(), items_only, dkey); |
1010 | } |
1011 | |
1012 | |
1013 | === modified file 'src/helper/png-write.h' |
1014 | --- src/helper/png-write.h 2014-03-27 01:33:44 +0000 |
1015 | +++ src/helper/png-write.h 2015-04-29 21:03:59 +0000 |
1016 | @@ -14,8 +14,9 @@ |
1017 | * Released under GNU GPL, read the file 'COPYING' for more information |
1018 | */ |
1019 | |
1020 | -#include <glib.h> |
1021 | #include <2geom/forward.h> |
1022 | + |
1023 | + |
1024 | class SPDocument; |
1025 | |
1026 | enum ExportResult { |
1027 | @@ -33,12 +34,12 @@ |
1028 | double x0, double y0, double x1, double y1, |
1029 | unsigned long int width, unsigned long int height, double xdpi, double ydpi, |
1030 | unsigned long bgcolor, |
1031 | - unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, GSList *items_only = NULL); |
1032 | + unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const std::vector<SPItem*> &items_only = std::vector<SPItem*>()); |
1033 | |
1034 | ExportResult sp_export_png_file(SPDocument *doc, gchar const *filename, |
1035 | Geom::Rect const &area, |
1036 | unsigned long int width, unsigned long int height, double xdpi, double ydpi, |
1037 | unsigned long bgcolor, |
1038 | - unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, GSList *items_only = NULL); |
1039 | + unsigned int (*status) (float, void *), void *data, bool force_overwrite = false, const std::vector<SPItem*> &items_only = std::vector<SPItem*>()); |
1040 | |
1041 | #endif // SEEN_SP_PNG_WRITE_H |
1042 | |
1043 | === modified file 'src/live_effects/lpe-knot.cpp' |
1044 | --- src/live_effects/lpe-knot.cpp 2015-03-08 16:10:20 +0000 |
1045 | +++ src/live_effects/lpe-knot.cpp 2015-04-29 21:03:59 +0000 |
1046 | @@ -505,9 +505,9 @@ |
1047 | static void |
1048 | collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector<Geom::Path> &paths, std::vector<double> &stroke_widths){ |
1049 | if (SP_IS_GROUP(lpeitem)) { |
1050 | - GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); |
1051 | - for ( GSList const *iter = item_list; iter; iter = iter->next ) { |
1052 | - SPObject *subitem = static_cast<SPObject *>(iter->data); |
1053 | + std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); |
1054 | + for ( std::vector<SPItem*>::const_iterator iter = item_list.begin(); iter != item_list.end(); iter++) { |
1055 | + SPObject *subitem = *iter; |
1056 | if (SP_IS_LPE_ITEM(subitem)) { |
1057 | collectPathsAndWidths(SP_LPE_ITEM(subitem), paths, stroke_widths); |
1058 | } |
1059 | |
1060 | === modified file 'src/main.cpp' |
1061 | --- src/main.cpp 2015-02-26 02:49:35 +0000 |
1062 | +++ src/main.cpp 2015-04-29 21:03:59 +0000 |
1063 | @@ -1156,7 +1156,7 @@ |
1064 | } |
1065 | if (sp_export_svg) { |
1066 | if (sp_export_text_to_path) { |
1067 | - GSList *items = NULL; |
1068 | + std::vector<SPItem*> items; |
1069 | SPRoot *root = doc->getRoot(); |
1070 | doc->ensureUpToDate(); |
1071 | for ( SPObject *iter = root->firstChild(); iter ; iter = iter->getNext()) { |
1072 | @@ -1166,17 +1166,14 @@ |
1073 | } |
1074 | |
1075 | te_update_layout_now_recursive(item); |
1076 | - items = g_slist_append(items, item); |
1077 | + items.push_back(item); |
1078 | } |
1079 | |
1080 | - GSList *selected = NULL; |
1081 | - GSList *to_select = NULL; |
1082 | - |
1083 | - sp_item_list_to_curves(items, &selected, &to_select); |
1084 | - |
1085 | - g_slist_free (items); |
1086 | - g_slist_free (selected); |
1087 | - g_slist_free (to_select); |
1088 | + std::vector<SPItem*> selected; |
1089 | + std::vector<Inkscape::XML::Node*> to_select; |
1090 | + |
1091 | + sp_item_list_to_curves(items, selected, to_select); |
1092 | + |
1093 | } |
1094 | if(sp_export_id) { |
1095 | doc->ensureUpToDate(); |
1096 | @@ -1435,7 +1432,7 @@ |
1097 | g_warning ("--export-use-hints can only be used with --export-id or --export-area-drawing; ignored."); |
1098 | } |
1099 | |
1100 | - GSList *items = NULL; |
1101 | + std::vector<SPItem*> items; |
1102 | |
1103 | Geom::Rect area; |
1104 | if (sp_export_id || sp_export_area_drawing) { |
1105 | @@ -1459,7 +1456,7 @@ |
1106 | return 1; |
1107 | } |
1108 | |
1109 | - items = g_slist_prepend (items, SP_ITEM(o)); |
1110 | + items.push_back(SP_ITEM(o)); |
1111 | |
1112 | if (sp_export_id_only) { |
1113 | g_print("Exporting only object with id=\"%s\"; all other objects hidden\n", sp_export_id); |
1114 | @@ -1644,10 +1641,12 @@ |
1115 | g_print("Background RRGGBBAA: %08x\n", bgcolor); |
1116 | |
1117 | g_print("Area %g:%g:%g:%g exported to %lu x %lu pixels (%g dpi)\n", area[Geom::X][0], area[Geom::Y][0], area[Geom::X][1], area[Geom::Y][1], width, height, dpi); |
1118 | - |
1119 | + |
1120 | + reverse(items.begin(),items.end()); |
1121 | + |
1122 | if ((width >= 1) && (height >= 1) && (width <= PNG_UINT_31_MAX) && (height <= PNG_UINT_31_MAX)) { |
1123 | if( sp_export_png_file(doc, path.c_str(), area, width, height, dpi, |
1124 | - dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : NULL) == 1 ) { |
1125 | + dpi, bgcolor, NULL, NULL, true, sp_export_id_only ? items : std::vector<SPItem*>()) == 1 ) { |
1126 | g_print("Bitmap saved as: %s\n", filename.c_str()); |
1127 | } else { |
1128 | g_warning("Bitmap failed to save to: %s", filename.c_str()); |
1129 | @@ -1657,7 +1656,6 @@ |
1130 | } |
1131 | } |
1132 | |
1133 | - g_slist_free (items); |
1134 | return retcode; |
1135 | } |
1136 | |
1137 | |
1138 | === modified file 'src/object-snapper.cpp' |
1139 | --- src/object-snapper.cpp 2014-11-10 17:39:33 +0000 |
1140 | +++ src/object-snapper.cpp 2015-04-29 21:03:59 +0000 |
1141 | @@ -237,8 +237,9 @@ |
1142 | // current selection (see the comment in SelTrans::centerRequest()) |
1143 | bool old_pref2 = _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_ROTATION_CENTER); |
1144 | if (old_pref2) { |
1145 | - for ( GSList const *itemlist = _snapmanager->getRotationCenterSource(); itemlist != NULL; itemlist = g_slist_next(itemlist) ) { |
1146 | - if ((*i).item == reinterpret_cast<SPItem*>(itemlist->data)) { |
1147 | + std::vector<SPItem*> rotationSource=_snapmanager->getRotationCenterSource(); |
1148 | + for ( std::vector<SPItem*>::const_iterator itemlist = rotationSource.begin(); itemlist != rotationSource.end(); itemlist++) { |
1149 | + if ((*i).item == *itemlist) { |
1150 | // don't snap to this item's rotation center |
1151 | _snapmanager->snapprefs.setTargetSnappable(SNAPTARGET_ROTATION_CENTER, false); |
1152 | break; |
1153 | |
1154 | === modified file 'src/object-test.h' |
1155 | --- src/object-test.h 2015-02-21 16:23:30 +0000 |
1156 | +++ src/object-test.h 2015-04-29 21:03:59 +0000 |
1157 | @@ -204,7 +204,8 @@ |
1158 | assert(n_group != NULL); |
1159 | |
1160 | begin = clock(); |
1161 | - sp_item_group_ungroup(n_group, NULL, false); |
1162 | + std::vector<SPItem*> ch; |
1163 | + sp_item_group_ungroup(n_group, ch, false); |
1164 | end = clock(); |
1165 | |
1166 | std::cout << "Took " << double(end - begin) / double(CLOCKS_PER_SEC) << " seconds to ungroup a <g> with " << num_elements << " elements\n"; |
1167 | |
1168 | === modified file 'src/path-chemistry.cpp' |
1169 | --- src/path-chemistry.cpp 2015-04-28 14:26:17 +0000 |
1170 | +++ src/path-chemistry.cpp 2015-04-29 21:03:59 +0000 |
1171 | @@ -44,13 +44,22 @@ |
1172 | |
1173 | using Inkscape::DocumentUndo; |
1174 | |
1175 | + |
1176 | +inline bool less_than_items(SPItem const *first, SPItem const *second) |
1177 | +{ |
1178 | + return sp_repr_compare_position(first->getRepr(), |
1179 | + second->getRepr())<0; |
1180 | +} |
1181 | + |
1182 | void |
1183 | sp_selected_path_combine(SPDesktop *desktop) |
1184 | { |
1185 | Inkscape::Selection *selection = desktop->getSelection(); |
1186 | SPDocument *doc = desktop->getDocument(); |
1187 | + |
1188 | + std::vector<SPItem*> items(selection->itemList()); |
1189 | |
1190 | - if (g_slist_length((GSList *) selection->itemList()) < 1) { |
1191 | + if (items.size() < 1) { |
1192 | desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to combine.")); |
1193 | return; |
1194 | } |
1195 | @@ -59,28 +68,23 @@ |
1196 | // set "busy" cursor |
1197 | desktop->setWaitingCursor(); |
1198 | |
1199 | - GSList *items = g_slist_copy((GSList *) selection->itemList()); |
1200 | - |
1201 | items = sp_degroup_list (items); // descend into any groups in selection |
1202 | |
1203 | - GSList *to_paths = NULL; |
1204 | - for (GSList *i = items; i != NULL; i = i->next) { |
1205 | - SPItem *item = (SPItem *) i->data; |
1206 | - if (!dynamic_cast<SPPath *>(item) && !dynamic_cast<SPGroup *>(item)) { |
1207 | - to_paths = g_slist_prepend(to_paths, item); |
1208 | + std::vector<SPItem*> to_paths; |
1209 | + for (std::vector<SPItem*>::const_reverse_iterator i = items.rbegin(); i != items.rend(); i++) { |
1210 | + if (!dynamic_cast<SPPath *>(*i) && !dynamic_cast<SPGroup *>(*i)) { |
1211 | + to_paths.push_back(*i); |
1212 | } |
1213 | } |
1214 | - GSList *converted = NULL; |
1215 | - bool did = sp_item_list_to_curves(to_paths, &items, &converted); |
1216 | - g_slist_free(to_paths); |
1217 | - for (GSList *i = converted; i != NULL; i = i->next) |
1218 | - items = g_slist_prepend(items, doc->getObjectByRepr((Inkscape::XML::Node*)(i->data))); |
1219 | + std::vector<Inkscape::XML::Node*> converted; |
1220 | + bool did = sp_item_list_to_curves(to_paths, items, converted); |
1221 | + for (std::vector<Inkscape::XML::Node*>::const_iterator i = converted.begin(); i != converted.end(); i++) |
1222 | + items.push_back((SPItem*)doc->getObjectByRepr(*i)); |
1223 | |
1224 | items = sp_degroup_list (items); // converting to path may have added more groups, descend again |
1225 | |
1226 | - items = g_slist_sort(items, (GCompareFunc) sp_item_repr_compare_position); |
1227 | - items = g_slist_reverse(items); |
1228 | - assert(items); // cannot be NULL because of list length check at top of function |
1229 | + sort(items.begin(),items.end(),less_than_items); |
1230 | + assert(!items.empty()); // cannot be NULL because of list length check at top of function |
1231 | |
1232 | // remember the position, id, transform and style of the topmost path, they will be assigned to the combined one |
1233 | gint position = 0; |
1234 | @@ -97,9 +101,9 @@ |
1235 | selection->clear(); |
1236 | } |
1237 | |
1238 | - for (GSList *i = items; i != NULL; i = i->next) { // going from top to bottom |
1239 | + for (std::vector<SPItem*>::const_reverse_iterator i = items.rbegin(); i != items.rend(); i++){ |
1240 | |
1241 | - SPItem *item = (SPItem *) i->data; |
1242 | + SPItem *item = *i; |
1243 | SPPath *path = dynamic_cast<SPPath *>(item); |
1244 | if (!path) { |
1245 | continue; |
1246 | @@ -136,7 +140,6 @@ |
1247 | } |
1248 | } |
1249 | |
1250 | - g_slist_free(items); |
1251 | |
1252 | if (did) { |
1253 | first->deleteObject(false); |
1254 | @@ -200,11 +203,10 @@ |
1255 | |
1256 | bool did = false; |
1257 | |
1258 | - for (GSList *items = g_slist_copy((GSList *) selection->itemList()); |
1259 | - items != NULL; |
1260 | - items = items->next) { |
1261 | + std::vector<SPItem*> itemlist(selection->itemList()); |
1262 | + for (std::vector<SPItem*>::const_iterator i = itemlist.begin(); i != itemlist.end(); i++){ |
1263 | |
1264 | - SPItem *item = (SPItem *) items->data; |
1265 | + SPItem *item = *i; |
1266 | |
1267 | SPPath *path = dynamic_cast<SPPath *>(item); |
1268 | if (!path) { |
1269 | @@ -241,7 +243,7 @@ |
1270 | |
1271 | curve->unref(); |
1272 | |
1273 | - GSList *reprs = NULL; |
1274 | + std::vector<Inkscape::XML::Node*> reprs; |
1275 | for (GSList *l = list; l != NULL; l = l->next) { |
1276 | curve = (SPCurve *) l->data; |
1277 | |
1278 | @@ -267,14 +269,12 @@ |
1279 | if (l == list) |
1280 | repr->setAttribute("id", id); |
1281 | |
1282 | - reprs = g_slist_prepend (reprs, repr); |
1283 | + reprs.push_back(repr); |
1284 | |
1285 | Inkscape::GC::release(repr); |
1286 | } |
1287 | - |
1288 | selection->setReprList(reprs); |
1289 | |
1290 | - g_slist_free(reprs); |
1291 | g_slist_free(list); |
1292 | g_free(style); |
1293 | g_free(path_effect); |
1294 | @@ -307,18 +307,15 @@ |
1295 | desktop->setWaitingCursor(); |
1296 | } |
1297 | |
1298 | - GSList *selected = g_slist_copy((GSList *) selection->itemList()); |
1299 | - GSList *to_select = NULL; |
1300 | + std::vector<SPItem*> selected(selection->itemList()); |
1301 | + std::vector<Inkscape::XML::Node*> to_select; |
1302 | selection->clear(); |
1303 | - GSList *items = g_slist_copy(selected); |
1304 | - |
1305 | - did = sp_item_list_to_curves(items, &selected, &to_select); |
1306 | - |
1307 | - g_slist_free (items); |
1308 | + std::vector<SPItem*> items(selected); |
1309 | + |
1310 | + did = sp_item_list_to_curves(items, selected, to_select); |
1311 | + |
1312 | selection->setReprList(to_select); |
1313 | selection->addList(selected); |
1314 | - g_slist_free (to_select); |
1315 | - g_slist_free (selected); |
1316 | |
1317 | if (interactive && desktop) { |
1318 | desktop->clearWaitingCursor(); |
1319 | @@ -341,33 +338,24 @@ |
1320 | return; |
1321 | } |
1322 | |
1323 | - GSList *selected = g_slist_copy((GSList *) selection->itemList()); |
1324 | - GSList *to_select = NULL; |
1325 | + std::vector<SPItem*> selected(selection->itemList()); |
1326 | + std::vector<Inkscape::XML::Node*> to_select; |
1327 | selection->clear(); |
1328 | - GSList *items = g_slist_copy(selected); |
1329 | - |
1330 | - sp_item_list_to_curves(items, &selected, &to_select, true); |
1331 | - |
1332 | - g_slist_free(items); |
1333 | - items = 0; |
1334 | + std::vector<SPItem*> items(selected); |
1335 | + |
1336 | + |
1337 | + sp_item_list_to_curves(items, selected, to_select, true); |
1338 | + |
1339 | selection->setReprList(to_select); |
1340 | selection->addList(selected); |
1341 | - g_slist_free(to_select); |
1342 | - to_select = 0; |
1343 | - g_slist_free(selected); |
1344 | - selected = 0; |
1345 | } |
1346 | |
1347 | bool |
1348 | -sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_select, bool skip_all_lpeitems) |
1349 | +sp_item_list_to_curves(const std::vector<SPItem*> &items, std::vector<SPItem*>& selected, std::vector<Inkscape::XML::Node*> &to_select, bool skip_all_lpeitems) |
1350 | { |
1351 | bool did = false; |
1352 | - |
1353 | - for (; |
1354 | - items != NULL; |
1355 | - items = items->next) { |
1356 | - |
1357 | - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(items->data)); |
1358 | + for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++){ |
1359 | + SPItem *item = *i; |
1360 | g_assert(item != NULL); |
1361 | SPDocument *document = item->document; |
1362 | |
1363 | @@ -398,9 +386,9 @@ |
1364 | Inkscape::XML::Node *repr = box3d_convert_to_group(box)->getRepr(); |
1365 | |
1366 | if (repr) { |
1367 | - *to_select = g_slist_prepend (*to_select, repr); |
1368 | + to_select.insert(to_select.begin(),repr); |
1369 | did = true; |
1370 | - *selected = g_slist_remove (*selected, item); |
1371 | + selected.erase(find(selected.begin(),selected.end(),item)); |
1372 | } |
1373 | |
1374 | continue; |
1375 | @@ -408,17 +396,14 @@ |
1376 | |
1377 | if (group) { |
1378 | group->removeAllPathEffects(true); |
1379 | - GSList *item_list = sp_item_group_item_list(group); |
1380 | - |
1381 | - GSList *item_to_select = NULL; |
1382 | - GSList *item_selected = NULL; |
1383 | - |
1384 | - if (sp_item_list_to_curves(item_list, &item_selected, &item_to_select)) |
1385 | + std::vector<SPItem*> item_list = sp_item_group_item_list(group); |
1386 | + |
1387 | + std::vector<Inkscape::XML::Node*> item_to_select; |
1388 | + std::vector<SPItem*> item_selected; |
1389 | + |
1390 | + if (sp_item_list_to_curves(item_list, item_selected, item_to_select)) |
1391 | did = true; |
1392 | |
1393 | - g_slist_free(item_list); |
1394 | - g_slist_free(item_to_select); |
1395 | - g_slist_free(item_selected); |
1396 | |
1397 | continue; |
1398 | } |
1399 | @@ -428,7 +413,7 @@ |
1400 | continue; |
1401 | |
1402 | did = true; |
1403 | - *selected = g_slist_remove (*selected, item); |
1404 | + selected.erase(find(selected.begin(),selected.end(),item)); |
1405 | |
1406 | // remember the position of the item |
1407 | gint pos = item->getRepr()->position(); |
1408 | @@ -470,7 +455,7 @@ |
1409 | |
1410 | /* Buglet: We don't re-add the (new version of the) object to the selection of any other |
1411 | * desktops where it was previously selected. */ |
1412 | - *to_select = g_slist_prepend (*to_select, repr); |
1413 | + to_select.insert(to_select.begin(),repr); |
1414 | Inkscape::GC::release(repr); |
1415 | } |
1416 | |
1417 | @@ -622,9 +607,9 @@ |
1418 | sp_selected_path_reverse(SPDesktop *desktop) |
1419 | { |
1420 | Inkscape::Selection *selection = desktop->getSelection(); |
1421 | - GSList *items = (GSList *) selection->itemList(); |
1422 | + std::vector<SPItem*> items = selection->itemList(); |
1423 | |
1424 | - if (!items) { |
1425 | + if (items.empty()) { |
1426 | desktop->getMessageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>path(s)</b> to reverse.")); |
1427 | return; |
1428 | } |
1429 | @@ -636,9 +621,9 @@ |
1430 | bool did = false; |
1431 | desktop->messageStack()->flash(Inkscape::IMMEDIATE_MESSAGE, _("Reversing paths...")); |
1432 | |
1433 | - for (GSList *i = items; i != NULL; i = i->next) { |
1434 | + for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++){ |
1435 | |
1436 | - SPPath *path = dynamic_cast<SPPath *>(static_cast<SPObject *>(i->data)); |
1437 | + SPPath *path = dynamic_cast<SPPath *>(*i); |
1438 | if (!path) { |
1439 | continue; |
1440 | } |
1441 | |
1442 | === modified file 'src/path-chemistry.h' |
1443 | --- src/path-chemistry.h 2014-10-08 02:22:03 +0000 |
1444 | +++ src/path-chemistry.h 2015-04-29 21:03:59 +0000 |
1445 | @@ -33,7 +33,7 @@ |
1446 | void sp_selected_to_lpeitems(SPDesktop *desktop); |
1447 | Inkscape::XML::Node *sp_selected_item_to_curved_repr(SPItem *item, guint32 text_grouping_policy); |
1448 | void sp_selected_path_reverse (SPDesktop *desktop); |
1449 | -bool sp_item_list_to_curves(const GSList *items, GSList **selected, GSList **to_select, bool skip_all_lpeitems = false); |
1450 | +bool sp_item_list_to_curves(const std::vector<SPItem*> &items, std::vector<SPItem*> &selected, std::vector<Inkscape::XML::Node*> &to_select, bool skip_all_lpeitems = false); |
1451 | |
1452 | #endif // SEEN_PATH_CHEMISTRY_H |
1453 | |
1454 | |
1455 | === modified file 'src/removeoverlap.cpp' |
1456 | --- src/removeoverlap.cpp 2014-03-27 01:33:44 +0000 |
1457 | +++ src/removeoverlap.cpp 2015-04-29 21:03:59 +0000 |
1458 | @@ -38,20 +38,19 @@ |
1459 | * such that rectangular bounding boxes are separated by at least xGap |
1460 | * horizontally and yGap vertically |
1461 | */ |
1462 | -void removeoverlap(GSList const *const items, double const xGap, double const yGap) { |
1463 | - using Inkscape::Util::GSListConstIterator; |
1464 | - std::list<SPItem *> selected; |
1465 | - selected.insert<GSListConstIterator<SPItem *> >(selected.end(), items, NULL); |
1466 | +void removeoverlap(std::vector<SPItem*> const &items, double const xGap, double const yGap) { |
1467 | + std::vector<SPItem*> selected(items); |
1468 | std::vector<Record> records; |
1469 | std::vector<Rectangle *> rs; |
1470 | |
1471 | Geom::Point const gap(xGap, yGap); |
1472 | - for (std::list<SPItem *>::iterator it(selected.begin()); |
1473 | + for (std::vector<SPItem*>::iterator it(selected.begin()); |
1474 | it != selected.end(); |
1475 | ++it) |
1476 | { |
1477 | + SPItem* item = *it; |
1478 | using Geom::X; using Geom::Y; |
1479 | - Geom::OptRect item_box((*it)->desktopVisualBounds()); |
1480 | + Geom::OptRect item_box((item)->desktopVisualBounds()); |
1481 | if (item_box) { |
1482 | Geom::Point min(item_box->min() - .5*gap); |
1483 | Geom::Point max(item_box->max() + .5*gap); |
1484 | @@ -67,7 +66,7 @@ |
1485 | min[Y] = max[Y] = (min[Y] + max[Y])/2; |
1486 | } |
1487 | Rectangle *vspc_rect = new Rectangle(min[X], max[X], min[Y], max[Y]); |
1488 | - records.push_back(Record(*it, item_box->midpoint(), vspc_rect)); |
1489 | + records.push_back(Record(item, item_box->midpoint(), vspc_rect)); |
1490 | rs.push_back(vspc_rect); |
1491 | } |
1492 | } |
1493 | |
1494 | === modified file 'src/removeoverlap.h' |
1495 | --- src/removeoverlap.h 2014-10-08 02:22:03 +0000 |
1496 | +++ src/removeoverlap.h 2015-04-29 21:03:59 +0000 |
1497 | @@ -15,6 +15,6 @@ |
1498 | |
1499 | typedef struct _GSList GSList; |
1500 | |
1501 | -void removeoverlap(GSList const *items, double xGap, double yGap); |
1502 | +void removeoverlap(std::vector<SPItem*> const &items, double xGap, double yGap); |
1503 | |
1504 | #endif // SEEN_REMOVEOVERLAP_H |
1505 | |
1506 | === modified file 'src/selcue.cpp' |
1507 | --- src/selcue.cpp 2014-12-21 21:58:32 +0000 |
1508 | +++ src/selcue.cpp 2015-04-29 21:03:59 +0000 |
1509 | @@ -96,15 +96,16 @@ |
1510 | |
1511 | void Inkscape::SelCue::_updateItemBboxes(gint mode, int prefs_bbox) |
1512 | { |
1513 | - GSList const *items = _selection->itemList(); |
1514 | - if (_item_bboxes.size() != g_slist_length((GSList *) items)) { |
1515 | + const std::vector<SPItem*> items = _selection->itemList(); |
1516 | + if (_item_bboxes.size() != items.size()) { |
1517 | _newItemBboxes(); |
1518 | return; |
1519 | } |
1520 | |
1521 | int bcount = 0; |
1522 | - for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) { |
1523 | - SPItem *item = static_cast<SPItem *>(l->data); |
1524 | + std::vector<SPItem*> ll=_selection->itemList(); |
1525 | + for (std::vector<SPItem*>::const_iterator l = ll.begin(); l != ll.end(); l++) { |
1526 | + SPItem *item = *l; |
1527 | SPCanvasItem* box = _item_bboxes[bcount ++]; |
1528 | |
1529 | if (box) { |
1530 | @@ -145,8 +146,9 @@ |
1531 | |
1532 | int prefs_bbox = prefs->getBool("/tools/bounding_box"); |
1533 | |
1534 | - for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) { |
1535 | - SPItem *item = static_cast<SPItem *>(l->data); |
1536 | + std::vector<SPItem*> ll=_selection->itemList(); |
1537 | + for (std::vector<SPItem*>::const_iterator l = ll.begin(); l != ll.end(); l++) { |
1538 | + SPItem *item = *l; |
1539 | |
1540 | Geom::OptRect const b = (prefs_bbox == 0) ? |
1541 | item->desktopVisualBounds() : item->desktopGeometricBounds(); |
1542 | @@ -199,8 +201,9 @@ |
1543 | } |
1544 | _text_baselines.clear(); |
1545 | |
1546 | - for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) { |
1547 | - SPItem *item = static_cast<SPItem *>(l->data); |
1548 | + std::vector<SPItem*> ll = _selection->itemList(); |
1549 | + for (std::vector<SPItem*>::const_iterator l=ll.begin();l!=ll.end();l++) { |
1550 | + SPItem *item = *l; |
1551 | |
1552 | SPCanvasItem* baseline_point = NULL; |
1553 | if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) { // visualize baseline |
1554 | |
1555 | === modified file 'src/selection-chemistry.cpp' |
1556 | --- src/selection-chemistry.cpp 2015-02-21 16:23:30 +0000 |
1557 | +++ src/selection-chemistry.cpp 2015-04-29 21:03:59 +0000 |
1558 | @@ -279,25 +279,21 @@ |
1559 | |
1560 | Inkscape::Selection *selection = dt->getSelection(); |
1561 | |
1562 | - GSList *items = NULL; |
1563 | - |
1564 | - GSList const *selList = selection->itemList(); |
1565 | - |
1566 | - for( GSList const *i = selList; i; i = i->next ) { |
1567 | - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data)); |
1568 | + std::vector<SPItem*> items ; |
1569 | + |
1570 | + std::vector<SPItem*> const selList = selection->itemList(); |
1571 | + |
1572 | + for( std::vector<SPItem*>::const_reverse_iterator i = selList.rbegin(); i != selList.rend(); i++ ) { |
1573 | + SPItem *item = *i; |
1574 | if( item && |
1575 | !dt->isLayer(item) && |
1576 | (!item->isLocked())) |
1577 | { |
1578 | - items = g_slist_prepend(items, item); |
1579 | + items.push_back(item); |
1580 | } |
1581 | } |
1582 | |
1583 | selection->setList(items); |
1584 | - |
1585 | - if(items) { |
1586 | - g_slist_free(items); |
1587 | - } |
1588 | } |
1589 | |
1590 | } // namespace Inkscape |
1591 | @@ -307,7 +303,7 @@ |
1592 | * Copies repr and its inherited css style elements, along with the accumulated transform 'full_t', |
1593 | * then prepends the copy to 'clip'. |
1594 | */ |
1595 | -static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, GSList **clip, Inkscape::XML::Document* xml_doc) |
1596 | +static void sp_selection_copy_one(Inkscape::XML::Node *repr, Geom::Affine full_t, std::vector<Inkscape::XML::Node*> &clip, Inkscape::XML::Document* xml_doc) |
1597 | { |
1598 | Inkscape::XML::Node *copy = repr->duplicate(xml_doc); |
1599 | |
1600 | @@ -323,41 +319,39 @@ |
1601 | copy->setAttribute("transform", affinestr); |
1602 | g_free(affinestr); |
1603 | |
1604 | - *clip = g_slist_prepend(*clip, copy); |
1605 | + clip.insert(clip.begin(),copy); |
1606 | } |
1607 | |
1608 | -static void sp_selection_copy_impl(GSList const *items, GSList **clip, Inkscape::XML::Document* xml_doc) |
1609 | +static void sp_selection_copy_impl(std::vector<SPItem*> const &items, std::vector<Inkscape::XML::Node*> &clip, Inkscape::XML::Document* xml_doc) |
1610 | { |
1611 | // Sort items: |
1612 | - GSList *sorted_items = g_slist_copy(const_cast<GSList *>(items)); |
1613 | - sorted_items = g_slist_sort(static_cast<GSList *>(sorted_items), (GCompareFunc) sp_object_compare_position); |
1614 | + std::vector<SPItem*> sorted_items(items); |
1615 | + sort(sorted_items.begin(),sorted_items.end(),sp_object_compare_position); |
1616 | |
1617 | // Copy item reprs: |
1618 | - for (GSList *i = sorted_items; i != NULL; i = i->next) { |
1619 | - SPItem *item = dynamic_cast<SPItem *>(SP_OBJECT(i->data)); |
1620 | + for (std::vector<SPItem*>::const_iterator i = sorted_items.begin(); i != sorted_items.end(); i++) { |
1621 | + SPItem *item = *i; |
1622 | if (item) { |
1623 | sp_selection_copy_one(item->getRepr(), item->i2doc_affine(), clip, xml_doc); |
1624 | } else { |
1625 | g_assert_not_reached(); |
1626 | } |
1627 | } |
1628 | - |
1629 | - *clip = g_slist_reverse(*clip); |
1630 | - g_slist_free(static_cast<GSList *>(sorted_items)); |
1631 | + reverse(clip.begin(),clip.end()); |
1632 | } |
1633 | |
1634 | // TODO check if parent parameter should be changed to SPItem, of if the code should handle non-items. |
1635 | -static GSList *sp_selection_paste_impl(SPDocument *doc, SPObject *parent, GSList **clip) |
1636 | +static std::vector<Inkscape::XML::Node*> sp_selection_paste_impl(SPDocument *doc, SPObject *parent, std::vector<Inkscape::XML::Node*> &clip) |
1637 | { |
1638 | Inkscape::XML::Document *xml_doc = doc->getReprDoc(); |
1639 | |
1640 | SPItem *parentItem = dynamic_cast<SPItem *>(parent); |
1641 | g_assert(parentItem != NULL); |
1642 | |
1643 | - GSList *copied = NULL; |
1644 | + std::vector<Inkscape::XML::Node*> copied; |
1645 | // add objects to document |
1646 | - for (GSList *l = *clip; l != NULL; l = l->next) { |
1647 | - Inkscape::XML::Node *repr = static_cast<Inkscape::XML::Node *>(l->data); |
1648 | + for (std::vector<Inkscape::XML::Node*>::const_iterator l = clip.begin(); l != clip.end(); l++) { |
1649 | + Inkscape::XML::Node *repr = *l; |
1650 | Inkscape::XML::Node *copy = repr->duplicate(xml_doc); |
1651 | |
1652 | // premultiply the item transform by the accumulated parent transform in the paste layer |
1653 | @@ -375,19 +369,19 @@ |
1654 | } |
1655 | |
1656 | parent->appendChildRepr(copy); |
1657 | - copied = g_slist_prepend(copied, copy); |
1658 | + copied.push_back(copy); |
1659 | Inkscape::GC::release(copy); |
1660 | } |
1661 | return copied; |
1662 | } |
1663 | |
1664 | -static void sp_selection_delete_impl(GSList const *items, bool propagate = true, bool propagate_descendants = true) |
1665 | +static void sp_selection_delete_impl(std::vector<SPItem*> const &items, bool propagate = true, bool propagate_descendants = true) |
1666 | { |
1667 | - for (GSList const *i = items ; i ; i = i->next ) { |
1668 | - sp_object_ref(static_cast<SPItem *>(i->data), NULL); |
1669 | + for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++) { |
1670 | + sp_object_ref(*i, NULL); |
1671 | } |
1672 | - for (GSList const *i = items; i != NULL; i = i->next) { |
1673 | - SPItem *item = static_cast<SPItem *>(i->data); |
1674 | + for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++) { |
1675 | + SPItem *item = *i; |
1676 | item->deleteObject(propagate, propagate_descendants); |
1677 | sp_object_unref(item, NULL); |
1678 | } |
1679 | @@ -414,11 +408,9 @@ |
1680 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("<b>Nothing</b> was deleted.")); |
1681 | return; |
1682 | } |
1683 | - |
1684 | - GSList *selected = g_slist_copy(const_cast<GSList *>(selection->itemList())); |
1685 | + std::vector<SPItem*> selected(selection->itemList()); |
1686 | selection->clear(); |
1687 | sp_selection_delete_impl(selected); |
1688 | - g_slist_free(selected); |
1689 | desktop->currentLayer()->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); |
1690 | |
1691 | /* a tool may have set up private information in it's selection context |
1692 | @@ -461,16 +453,15 @@ |
1693 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to duplicate.")); |
1694 | return; |
1695 | } |
1696 | - |
1697 | - GSList *reprs = g_slist_copy(const_cast<GSList *>(selection->reprList())); |
1698 | + std::vector<Inkscape::XML::Node*> reprs(selection->reprList()); |
1699 | |
1700 | selection->clear(); |
1701 | |
1702 | // sorting items from different parents sorts each parent's subset without possibly mixing |
1703 | // them, just what we need |
1704 | - reprs = g_slist_sort(reprs, (GCompareFunc) sp_repr_compare_position); |
1705 | + sort(reprs.begin(),reprs.end(),sp_repr_compare_position); |
1706 | |
1707 | - GSList *newsel = NULL; |
1708 | + std::vector<Inkscape::XML::Node*> newsel; |
1709 | |
1710 | std::vector<const gchar *> old_ids; |
1711 | std::vector<const gchar *> new_ids; |
1712 | @@ -478,8 +469,8 @@ |
1713 | bool relink_clones = prefs->getBool("/options/relinkclonesonduplicate/value"); |
1714 | const bool fork_livepatheffects = prefs->getBool("/options/forklpeonduplicate/value", true); |
1715 | |
1716 | - while (reprs) { |
1717 | - Inkscape::XML::Node *old_repr = static_cast<Inkscape::XML::Node *>(reprs->data); |
1718 | + for(std::vector<Inkscape::XML::Node*>::const_reverse_iterator i=reprs.rbegin();i!=reprs.rend();i++){ |
1719 | + Inkscape::XML::Node *old_repr = *i; |
1720 | Inkscape::XML::Node *parent = old_repr->parent(); |
1721 | Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc); |
1722 | |
1723 | @@ -500,8 +491,7 @@ |
1724 | } |
1725 | } |
1726 | |
1727 | - newsel = g_slist_prepend(newsel, copy); |
1728 | - reprs = g_slist_remove(reprs, reprs->data); |
1729 | + newsel.push_back(copy); |
1730 | Inkscape::GC::release(copy); |
1731 | } |
1732 | |
1733 | @@ -547,8 +537,6 @@ |
1734 | } |
1735 | |
1736 | selection->setReprList(newsel); |
1737 | - |
1738 | - g_slist_free(newsel); |
1739 | } |
1740 | |
1741 | void sp_edit_clear_all(Inkscape::Selection *selection) |
1742 | @@ -561,11 +549,10 @@ |
1743 | |
1744 | SPGroup *group = dynamic_cast<SPGroup *>(selection->layers()->currentLayer()); |
1745 | g_return_if_fail(group != NULL); |
1746 | - GSList *items = sp_item_group_item_list(group); |
1747 | + std::vector<SPItem*> items = sp_item_group_item_list(group); |
1748 | |
1749 | - while (items) { |
1750 | - reinterpret_cast<SPObject*>(items->data)->deleteObject(); |
1751 | - items = g_slist_remove(items, items->data); |
1752 | + for(unsigned int i = 0; i < items.size(); i++){ |
1753 | + items[i]->deleteObject(); |
1754 | } |
1755 | |
1756 | DocumentUndo::done(doc, SP_VERB_EDIT_CLEAR_ALL, |
1757 | @@ -582,7 +569,7 @@ |
1758 | * onlysensitive - TRUE includes only non-locked items |
1759 | * ingroups - TRUE to recursively get grouped items children |
1760 | */ |
1761 | -GSList *get_all_items(GSList *list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, GSList const *exclude) |
1762 | +std::vector<SPItem*> &get_all_items(std::vector<SPItem*> &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, std::vector<SPItem*> const &exclude) |
1763 | { |
1764 | for ( SPObject *child = from->firstChild() ; child; child = child->getNext() ) { |
1765 | SPItem *item = dynamic_cast<SPItem *>(child); |
1766 | @@ -590,10 +577,10 @@ |
1767 | !desktop->isLayer(item) && |
1768 | (!onlysensitive || !item->isLocked()) && |
1769 | (!onlyvisible || !desktop->itemIsHidden(item)) && |
1770 | - (!exclude || !g_slist_find(const_cast<GSList *>(exclude), child)) |
1771 | + (exclude.empty() || exclude.end() == std::find(exclude.begin(),exclude.end(),child)) |
1772 | ) |
1773 | { |
1774 | - list = g_slist_prepend(list, item); |
1775 | + list.insert(list.begin(),item); |
1776 | } |
1777 | |
1778 | if (ingroups || (item && desktop->isLayer(item))) { |
1779 | @@ -618,9 +605,9 @@ |
1780 | bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); |
1781 | bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); |
1782 | |
1783 | - GSList *items = NULL; |
1784 | + std::vector<SPItem*> items ; |
1785 | |
1786 | - GSList const *exclude = NULL; |
1787 | + std::vector<SPItem*> exclude; |
1788 | if (invert) { |
1789 | exclude = selection->itemList(); |
1790 | } |
1791 | @@ -634,40 +621,38 @@ |
1792 | (onlyvisible && dt->itemIsHidden(dynamic_cast<SPItem *>(dt->currentLayer()))) ) |
1793 | return; |
1794 | |
1795 | - GSList *all_items = sp_item_group_item_list(dynamic_cast<SPGroup *>(dt->currentLayer())); |
1796 | + std::vector<SPItem*> all_items = sp_item_group_item_list(dynamic_cast<SPGroup *>(dt->currentLayer())); |
1797 | |
1798 | - for (GSList *i = all_items; i; i = i->next) { |
1799 | - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data)); |
1800 | + for (std::vector<SPItem*>::const_reverse_iterator i=all_items.rbegin();i!=all_items.rend();i++) { |
1801 | + SPItem *item = *i; |
1802 | |
1803 | if (item && (!onlysensitive || !item->isLocked())) { |
1804 | if (!onlyvisible || !dt->itemIsHidden(item)) { |
1805 | if (!dt->isLayer(item)) { |
1806 | - if (!invert || !g_slist_find(const_cast<GSList *>(exclude), item)) { |
1807 | - items = g_slist_prepend(items, item); // leave it in the list |
1808 | + if (!invert || exclude.end() == std::find(exclude.begin(),exclude.end(),item)) { |
1809 | + items.push_back(item); // leave it in the list |
1810 | } |
1811 | } |
1812 | } |
1813 | } |
1814 | } |
1815 | |
1816 | - g_slist_free(all_items); |
1817 | break; |
1818 | } |
1819 | case PREFS_SELECTION_LAYER_RECURSIVE: { |
1820 | - items = get_all_items(NULL, dt->currentLayer(), dt, onlyvisible, onlysensitive, FALSE, exclude); |
1821 | + std::vector<SPItem*> x; |
1822 | + items = get_all_items(x, dt->currentLayer(), dt, onlyvisible, onlysensitive, FALSE, exclude); |
1823 | break; |
1824 | } |
1825 | default: { |
1826 | - items = get_all_items(NULL, dt->currentRoot(), dt, onlyvisible, onlysensitive, FALSE, exclude); |
1827 | + std::vector<SPItem*> x; |
1828 | + items = get_all_items(x, dt->currentRoot(), dt, onlyvisible, onlysensitive, FALSE, exclude); |
1829 | break; |
1830 | } |
1831 | } |
1832 | |
1833 | selection->setList(items); |
1834 | |
1835 | - if (items) { |
1836 | - g_slist_free(items); |
1837 | - } |
1838 | } |
1839 | |
1840 | void sp_edit_select_all(SPDesktop *desktop) |
1841 | @@ -690,16 +675,16 @@ |
1842 | sp_edit_select_all_full(desktop, true, true); |
1843 | } |
1844 | |
1845 | -static void sp_selection_group_impl(GSList *p, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) { |
1846 | +static void sp_selection_group_impl(std::vector<Inkscape::XML::Node*> p, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc) { |
1847 | |
1848 | - p = g_slist_sort(p, (GCompareFunc) sp_repr_compare_position); |
1849 | + sort(p.begin(),p.end(),sp_repr_compare_position); |
1850 | |
1851 | // Remember the position and parent of the topmost object. |
1852 | - gint topmost = (static_cast<Inkscape::XML::Node *>(g_slist_last(p)->data))->position(); |
1853 | - Inkscape::XML::Node *topmost_parent = (static_cast<Inkscape::XML::Node *>(g_slist_last(p)->data))->parent(); |
1854 | + gint topmost = p.back()->position(); |
1855 | + Inkscape::XML::Node *topmost_parent = p.back()->parent(); |
1856 | |
1857 | - while (p) { |
1858 | - Inkscape::XML::Node *current = static_cast<Inkscape::XML::Node *>(p->data); |
1859 | + for(std::vector<Inkscape::XML::Node*>::const_iterator i = p.begin(); i != p.end(); i++){ |
1860 | + Inkscape::XML::Node *current = *i; |
1861 | |
1862 | if (current->parent() == topmost_parent) { |
1863 | Inkscape::XML::Node *spnew = current->duplicate(xml_doc); |
1864 | @@ -708,7 +693,7 @@ |
1865 | Inkscape::GC::release(spnew); |
1866 | topmost --; // only reduce count for those items deleted from topmost_parent |
1867 | } else { // move it to topmost_parent first |
1868 | - GSList *temp_clip = NULL; |
1869 | + std::vector<Inkscape::XML::Node*> temp_clip; |
1870 | |
1871 | // At this point, current may already have no item, due to its being a clone whose original is already moved away |
1872 | // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform |
1873 | @@ -724,15 +709,15 @@ |
1874 | // then, if this is clone, looking up its original in that array and pre-multiplying |
1875 | // it by the inverse of that original's transform diff. |
1876 | |
1877 | - sp_selection_copy_one(current, item_t, &temp_clip, xml_doc); |
1878 | + sp_selection_copy_one(current, item_t, temp_clip, xml_doc); |
1879 | sp_repr_unparent(current); |
1880 | |
1881 | // paste into topmost_parent (temporarily) |
1882 | - GSList *copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), &temp_clip); |
1883 | - if (temp_clip) g_slist_free(temp_clip); |
1884 | - if (copied) { // if success, |
1885 | + std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip); |
1886 | + if (!temp_clip.empty())temp_clip.clear() ; |
1887 | + if (!copied.empty()) { // if success, |
1888 | // take pasted object (now in topmost_parent) |
1889 | - Inkscape::XML::Node *in_topmost = static_cast<Inkscape::XML::Node *>(copied->data); |
1890 | + Inkscape::XML::Node *in_topmost = copied.back(); |
1891 | // make a copy |
1892 | Inkscape::XML::Node *spnew = in_topmost->duplicate(xml_doc); |
1893 | // remove pasted |
1894 | @@ -740,10 +725,9 @@ |
1895 | // put its copy into group |
1896 | group->appendChild(spnew); |
1897 | Inkscape::GC::release(spnew); |
1898 | - g_slist_free(copied); |
1899 | + copied.clear(); |
1900 | } |
1901 | } |
1902 | - p = g_slist_remove(p, current); |
1903 | } |
1904 | |
1905 | // Add the new group to the topmost members' parent |
1906 | @@ -764,9 +748,7 @@ |
1907 | return; |
1908 | } |
1909 | |
1910 | - GSList const *l = const_cast<GSList *>(selection->reprList()); |
1911 | - |
1912 | - GSList *p = g_slist_copy(const_cast<GSList *>(l)); |
1913 | + std::vector<Inkscape::XML::Node*> p (selection->reprList()); |
1914 | |
1915 | selection->clear(); |
1916 | |
1917 | @@ -802,11 +784,11 @@ |
1918 | } |
1919 | |
1920 | // first check whether there is anything to ungroup |
1921 | - GSList *old_select = const_cast<GSList *>(selection->itemList()); |
1922 | - GSList *new_select = NULL; |
1923 | + std::vector<SPItem*> old_select = selection->itemList(); |
1924 | + std::vector<SPItem*> new_select; |
1925 | GSList *groups = NULL; |
1926 | - for (GSList *item = old_select; item; item = item->next) { |
1927 | - SPItem *obj = static_cast<SPItem*>(item->data); |
1928 | + for (std::vector<SPItem*>::const_iterator item = old_select.begin(); item!=old_select.end(); item++) { |
1929 | + SPItem *obj = *item; |
1930 | if (dynamic_cast<SPGroup *>(obj)) { |
1931 | groups = g_slist_prepend(groups, obj); |
1932 | } |
1933 | @@ -818,14 +800,14 @@ |
1934 | return; |
1935 | } |
1936 | |
1937 | - GSList *items = g_slist_copy(old_select); |
1938 | + std::vector<SPItem*> items(old_select); |
1939 | selection->clear(); |
1940 | |
1941 | // If any of the clones refer to the groups, unlink them and replace them with successors |
1942 | // in the items list. |
1943 | GSList *clones_to_unlink = NULL; |
1944 | - for (GSList *item = items; item; item = item->next) { |
1945 | - SPUse *use = dynamic_cast<SPUse *>(static_cast<SPItem *>(item->data)); |
1946 | + for (std::vector<SPItem*>::const_iterator item = items.begin(); item != items.end(); item++) { |
1947 | + SPUse *use = dynamic_cast<SPUse *>(*item); |
1948 | |
1949 | SPItem *original = use; |
1950 | while (dynamic_cast<SPUse *>(original)) { |
1951 | @@ -833,7 +815,7 @@ |
1952 | } |
1953 | |
1954 | if (g_slist_find(groups, original) != NULL) { |
1955 | - clones_to_unlink = g_slist_prepend(clones_to_unlink, item->data); |
1956 | + clones_to_unlink = g_slist_prepend(clones_to_unlink, *item); |
1957 | } |
1958 | } |
1959 | |
1960 | @@ -844,57 +826,53 @@ |
1961 | |
1962 | for (GSList *item = clones_to_unlink; item; item = item->next) { |
1963 | SPUse *use = static_cast<SPUse *>(item->data); |
1964 | - GSList *items_node = g_slist_find(items, item->data); |
1965 | - items_node->data = use->unlink(); |
1966 | + std::vector<SPItem*>::iterator items_node = std::find(items.begin(),items.end(), item->data); |
1967 | + *items_node = use->unlink(); |
1968 | } |
1969 | g_slist_free(clones_to_unlink); |
1970 | |
1971 | // do the actual work |
1972 | - for (GSList *item = items; item; item = item->next) { |
1973 | - SPItem *obj = static_cast<SPItem *>(item->data); |
1974 | + for (std::vector<SPItem*>::iterator item = items.begin(); item != items.end(); item++) { |
1975 | + SPItem *obj = *item; |
1976 | |
1977 | // ungroup only the groups marked earlier |
1978 | - if (g_slist_find(groups, item->data) != NULL) { |
1979 | - GSList *children = NULL; |
1980 | - sp_item_group_ungroup(dynamic_cast<SPGroup *>(obj), &children, false); |
1981 | + if (g_slist_find(groups, *item) != NULL) { |
1982 | + std::vector<SPItem*> children; |
1983 | + sp_item_group_ungroup(dynamic_cast<SPGroup *>(obj), children, false); |
1984 | // add the items resulting from ungrouping to the selection |
1985 | - new_select = g_slist_concat(new_select, children); |
1986 | - item->data = NULL; // zero out the original pointer, which is no longer valid |
1987 | + new_select.insert(new_select.end(),children.begin(),children.end()); |
1988 | + *item = NULL; // zero out the original pointer, which is no longer valid |
1989 | } else { |
1990 | // if not a group, keep in the selection |
1991 | - new_select = g_slist_append(new_select, item->data); |
1992 | + new_select.push_back(*item); |
1993 | } |
1994 | } |
1995 | |
1996 | selection->addList(new_select); |
1997 | - g_slist_free(new_select); |
1998 | - g_slist_free(items); |
1999 | |
2000 | DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP, |
2001 | _("Ungroup")); |
2002 | } |
2003 | |
2004 | /** Replace all groups in the list with their member objects, recursively; returns a new list, frees old */ |
2005 | -GSList * |
2006 | -sp_degroup_list(GSList *items) |
2007 | +std::vector<SPItem*> |
2008 | +sp_degroup_list(std::vector<SPItem*> &items) |
2009 | { |
2010 | - GSList *out = NULL; |
2011 | + std::vector<SPItem*> out; |
2012 | bool has_groups = false; |
2013 | - for (GSList *item = items; item; item = item->next) { |
2014 | - SPGroup *group = dynamic_cast<SPGroup *>(static_cast<SPObject *>(item->data)); |
2015 | + for (std::vector<SPItem*>::const_iterator item=items.begin();item!=items.end();item++) { |
2016 | + SPGroup *group = dynamic_cast<SPGroup *>(*item); |
2017 | if (!group) { |
2018 | - out = g_slist_prepend(out, item->data); |
2019 | + out.push_back(*item); |
2020 | } else { |
2021 | has_groups = true; |
2022 | - GSList *members = sp_item_group_item_list(group); |
2023 | - for (GSList *member = members; member; member = member->next) { |
2024 | - out = g_slist_prepend(out, member->data); |
2025 | + std::vector<SPItem*> members = sp_item_group_item_list(group); |
2026 | + for (std::vector<SPItem*>::const_iterator member=members.begin();member!=members.end();member++) { |
2027 | + out.push_back(*member); |
2028 | } |
2029 | - g_slist_free(members); |
2030 | + members.clear(); |
2031 | } |
2032 | } |
2033 | - out = g_slist_reverse(out); |
2034 | - g_slist_free(items); |
2035 | |
2036 | if (has_groups) { // recurse if we unwrapped a group - it may have contained others |
2037 | out = sp_degroup_list(out); |
2038 | @@ -906,18 +884,19 @@ |
2039 | |
2040 | /** If items in the list have a common parent, return it, otherwise return NULL */ |
2041 | static SPGroup * |
2042 | -sp_item_list_common_parent_group(GSList const *items) |
2043 | +sp_item_list_common_parent_group(std::vector<SPItem*> const items) |
2044 | { |
2045 | - if (!items) { |
2046 | + if (items.empty()) { |
2047 | return NULL; |
2048 | } |
2049 | - SPObject *parent = SP_OBJECT(items->data)->parent; |
2050 | + SPObject *parent = items[0]->parent; |
2051 | // Strictly speaking this CAN happen, if user selects <svg> from Inkscape::XML editor |
2052 | if (!dynamic_cast<SPGroup *>(parent)) { |
2053 | return NULL; |
2054 | } |
2055 | - for (items = items->next; items; items = items->next) { |
2056 | - if (SP_OBJECT(items->data)->parent != parent) { |
2057 | + for (std::vector<SPItem*>::const_iterator item=items.begin();item!=items.end();item++) { |
2058 | + if((*item)==items[0])continue; |
2059 | + if ((*item)->parent != parent) { |
2060 | return NULL; |
2061 | } |
2062 | } |
2063 | @@ -927,13 +906,13 @@ |
2064 | |
2065 | /** Finds out the minimum common bbox of the selected items. */ |
2066 | static Geom::OptRect |
2067 | -enclose_items(GSList const *items) |
2068 | +enclose_items(std::vector<SPItem*> const &items) |
2069 | { |
2070 | - g_assert(items != NULL); |
2071 | + g_assert(!items.empty()); |
2072 | |
2073 | Geom::OptRect r; |
2074 | - for (GSList const *i = items; i; i = i->next) { |
2075 | - r.unionWith(static_cast<SPItem *>(i->data)->desktopVisualBounds()); |
2076 | + for (std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();i++) { |
2077 | + r.unionWith((*i)->desktopVisualBounds()); |
2078 | } |
2079 | return r; |
2080 | } |
2081 | @@ -948,11 +927,17 @@ |
2082 | return prev; |
2083 | } |
2084 | |
2085 | +int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second) |
2086 | +{ |
2087 | + return sp_repr_compare_position(((SPItem*)first)->getRepr(), |
2088 | + ((SPItem*)second)->getRepr())<0; |
2089 | +} |
2090 | + |
2091 | void |
2092 | sp_selection_raise(Inkscape::Selection *selection, SPDesktop *desktop) |
2093 | { |
2094 | - GSList const *items = const_cast<GSList *>(selection->itemList()); |
2095 | - if (!items) { |
2096 | + std::vector<SPItem*> items= selection->itemList(); |
2097 | + if (items.empty()) { |
2098 | selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to raise.")); |
2099 | return; |
2100 | } |
2101 | @@ -966,16 +951,16 @@ |
2102 | Inkscape::XML::Node *grepr = const_cast<Inkscape::XML::Node *>(group->getRepr()); |
2103 | |
2104 | /* Construct reverse-ordered list of selected children. */ |
2105 | - GSList *rev = g_slist_copy(const_cast<GSList *>(items)); |
2106 | - rev = g_slist_sort(rev, (GCompareFunc) sp_item_repr_compare_position); |
2107 | + std::vector<SPItem*> rev(items); |
2108 | + sort(rev.begin(),rev.end(),sp_item_repr_compare_position); |
2109 | |
2110 | // Determine the common bbox of the selected items. |
2111 | Geom::OptRect selected = enclose_items(items); |
2112 | |
2113 | // Iterate over all objects in the selection (starting from top). |
2114 | if (selected) { |
2115 | - while (rev) { |
2116 | - SPObject *child = reinterpret_cast<SPObject*>(rev->data); |
2117 | + for (std::vector<SPItem*>::const_iterator item=rev.begin();item!=rev.end();item++) { |
2118 | + SPObject *child = *item; |
2119 | // for each selected object, find the next sibling |
2120 | for (SPObject *newref = child->next; newref; newref = newref->next) { |
2121 | // if the sibling is an item AND overlaps our selection, |
2122 | @@ -984,7 +969,7 @@ |
2123 | Geom::OptRect newref_bbox = newItem->desktopVisualBounds(); |
2124 | if ( newref_bbox && selected->intersects(*newref_bbox) ) { |
2125 | // AND if it's not one of our selected objects, |
2126 | - if (!g_slist_find(const_cast<GSList *>(items), newref)) { |
2127 | + if ( std::find(items.begin(),items.end(),newref)==items.end()) { |
2128 | // move the selected object after that sibling |
2129 | grepr->changeOrder(child->getRepr(), newref->getRepr()); |
2130 | } |
2131 | @@ -992,12 +977,8 @@ |
2132 | } |
2133 | } |
2134 | } |
2135 | - rev = g_slist_remove(rev, child); |
2136 | } |
2137 | - } else { |
2138 | - g_slist_free(rev); |
2139 | } |
2140 | - |
2141 | DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_RAISE, |
2142 | //TRANSLATORS: "Raise" means "to raise an object" in the undo history |
2143 | C_("Undo action", "Raise")); |
2144 | @@ -1012,7 +993,7 @@ |
2145 | return; |
2146 | } |
2147 | |
2148 | - GSList const *items = const_cast<GSList *>(selection->itemList()); |
2149 | + std::vector<SPItem*> items = selection->itemList(); |
2150 | |
2151 | SPGroup const *group = sp_item_list_common_parent_group(items); |
2152 | if (!group) { |
2153 | @@ -1020,24 +1001,22 @@ |
2154 | return; |
2155 | } |
2156 | |
2157 | - GSList *rl = g_slist_copy(const_cast<GSList *>(selection->reprList())); |
2158 | - rl = g_slist_sort(rl, (GCompareFunc) sp_repr_compare_position); |
2159 | + std::vector<Inkscape::XML::Node*> rl(selection->reprList()); |
2160 | + sort(rl.begin(),rl.end(),sp_repr_compare_position); |
2161 | |
2162 | - for (GSList *l = rl; l != NULL; l = l->next) { |
2163 | - Inkscape::XML::Node *repr = static_cast<Inkscape::XML::Node *>(l->data); |
2164 | + for (std::vector<Inkscape::XML::Node*>::const_iterator l=rl.begin(); l!=rl.end();l++) { |
2165 | + Inkscape::XML::Node *repr =(*l); |
2166 | repr->setPosition(-1); |
2167 | } |
2168 | |
2169 | - g_slist_free(rl); |
2170 | - |
2171 | DocumentUndo::done(document, SP_VERB_SELECTION_TO_FRONT, |
2172 | _("Raise to top")); |
2173 | } |
2174 | |
2175 | void sp_selection_lower(Inkscape::Selection *selection, SPDesktop *desktop) |
2176 | { |
2177 | - GSList const *items = const_cast<GSList *>(selection->itemList()); |
2178 | - if (!items) { |
2179 | + std::vector<SPItem*> items = selection->itemList(); |
2180 | + if (items.empty()) { |
2181 | selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to lower.")); |
2182 | return; |
2183 | } |
2184 | @@ -1054,14 +1033,13 @@ |
2185 | Geom::OptRect selected = enclose_items(items); |
2186 | |
2187 | /* Construct direct-ordered list of selected children. */ |
2188 | - GSList *rev = g_slist_copy(const_cast<GSList *>(items)); |
2189 | - rev = g_slist_sort(rev, (GCompareFunc) sp_item_repr_compare_position); |
2190 | - rev = g_slist_reverse(rev); |
2191 | + std::vector<SPItem*> rev(items); |
2192 | + sort(rev.begin(),rev.end(),sp_item_repr_compare_position); |
2193 | |
2194 | // Iterate over all objects in the selection (starting from top). |
2195 | if (selected) { |
2196 | - while (rev) { |
2197 | - SPObject *child = reinterpret_cast<SPObject*>(rev->data); |
2198 | + for (std::vector<SPItem*>::const_reverse_iterator item=rev.rbegin();item!=rev.rend();item++) { |
2199 | + SPObject *child = *item; |
2200 | // for each selected object, find the prev sibling |
2201 | for (SPObject *newref = prev_sibling(child); newref; newref = prev_sibling(newref)) { |
2202 | // if the sibling is an item AND overlaps our selection, |
2203 | @@ -1070,7 +1048,7 @@ |
2204 | Geom::OptRect ref_bbox = newItem->desktopVisualBounds(); |
2205 | if ( ref_bbox && selected->intersects(*ref_bbox) ) { |
2206 | // AND if it's not one of our selected objects, |
2207 | - if (!g_slist_find(const_cast<GSList *>(items), newref)) { |
2208 | + if (items.end()==std::find(items.begin(),items.end(),newref)) { |
2209 | // move the selected object before that sibling |
2210 | SPObject *put_after = prev_sibling(newref); |
2211 | if (put_after) |
2212 | @@ -1082,10 +1060,7 @@ |
2213 | } |
2214 | } |
2215 | } |
2216 | - rev = g_slist_remove(rev, child); |
2217 | } |
2218 | - } else { |
2219 | - g_slist_free(rev); |
2220 | } |
2221 | |
2222 | DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_LOWER, |
2223 | @@ -1102,7 +1077,7 @@ |
2224 | return; |
2225 | } |
2226 | |
2227 | - GSList const *items = const_cast<GSList *>(selection->itemList()); |
2228 | + std::vector<SPItem*> items =selection->itemList(); |
2229 | |
2230 | SPGroup const *group = sp_item_list_common_parent_group(items); |
2231 | if (!group) { |
2232 | @@ -1110,15 +1085,13 @@ |
2233 | return; |
2234 | } |
2235 | |
2236 | - GSList *rl; |
2237 | - rl = g_slist_copy(const_cast<GSList *>(selection->reprList())); |
2238 | - rl = g_slist_sort(rl, (GCompareFunc) sp_repr_compare_position); |
2239 | - rl = g_slist_reverse(rl); |
2240 | + std::vector<Inkscape::XML::Node*> rl(selection->reprList()); |
2241 | + sort(rl.begin(),rl.end(),sp_repr_compare_position); |
2242 | |
2243 | - for (GSList *l = rl; l != NULL; l = l->next) { |
2244 | + for (std::vector<Inkscape::XML::Node*>::const_reverse_iterator l=rl.rbegin();l!=rl.rend();l++) { |
2245 | gint minpos; |
2246 | SPObject *pp, *pc; |
2247 | - Inkscape::XML::Node *repr = static_cast<Inkscape::XML::Node *>(l->data); |
2248 | + Inkscape::XML::Node *repr = (*l); |
2249 | pp = document->getObjectByRepr(repr->parent()); |
2250 | minpos = 0; |
2251 | g_assert(dynamic_cast<SPGroup *>(pp)); |
2252 | @@ -1130,8 +1103,6 @@ |
2253 | repr->setPosition(minpos); |
2254 | } |
2255 | |
2256 | - g_slist_free(rl); |
2257 | - |
2258 | DocumentUndo::done(document, SP_VERB_SELECTION_TO_BACK, |
2259 | _("Lower to bottom")); |
2260 | } |
2261 | @@ -1269,9 +1240,9 @@ |
2262 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to remove live path effects from.")); |
2263 | return; |
2264 | } |
2265 | - |
2266 | - for ( GSList const *itemlist = selection->itemList(); itemlist != NULL; itemlist = g_slist_next(itemlist) ) { |
2267 | - SPItem *item = reinterpret_cast<SPItem*>(itemlist->data); |
2268 | + std::vector<SPItem*> list=selection->itemList(); |
2269 | + for ( std::vector<SPItem*>::const_iterator itemlist=list.begin();itemlist!=list.end();itemlist++) { |
2270 | + SPItem *item = *itemlist; |
2271 | |
2272 | sp_selection_remove_livepatheffect_impl(item); |
2273 | |
2274 | @@ -1325,10 +1296,10 @@ |
2275 | * Ensures that the clones of objects are not modified when moving objects between layers. |
2276 | * Calls the same function as ungroup |
2277 | */ |
2278 | -void sp_selection_change_layer_maintain_clones(GSList const *items,SPObject *where) |
2279 | +void sp_selection_change_layer_maintain_clones(std::vector<SPItem*> const &items,SPObject *where) |
2280 | { |
2281 | - for (const GSList *i = items; i != NULL; i = i->next) { |
2282 | - SPItem *item = dynamic_cast<SPItem *>(SP_OBJECT(i->data)); |
2283 | + for (std::vector<SPItem*>::const_iterator i = items.begin(); i != items.end(); i++) { |
2284 | + SPItem *item = *i; |
2285 | if (item) { |
2286 | SPItem *oldparent = dynamic_cast<SPItem *>(item->parent); |
2287 | SPItem *newparent = dynamic_cast<SPItem *>(where); |
2288 | @@ -1350,26 +1321,24 @@ |
2289 | return; |
2290 | } |
2291 | |
2292 | - GSList const *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); |
2293 | + std::vector<SPItem*> items(selection->itemList()); |
2294 | |
2295 | bool no_more = false; // Set to true, if no more layers above |
2296 | SPObject *next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); |
2297 | if (next) { |
2298 | sp_selection_change_layer_maintain_clones(items,next); |
2299 | - GSList *temp_clip = NULL; |
2300 | - sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc()); |
2301 | + std::vector<Inkscape::XML::Node*> temp_clip; |
2302 | + sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); |
2303 | sp_selection_delete_impl(items, false, false); |
2304 | next=Inkscape::next_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers |
2305 | - GSList *copied; |
2306 | + std::vector<Inkscape::XML::Node*> copied; |
2307 | if (next) { |
2308 | - copied = sp_selection_paste_impl(dt->getDocument(), next, &temp_clip); |
2309 | + copied = sp_selection_paste_impl(dt->getDocument(), next, temp_clip); |
2310 | } else { |
2311 | - copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), &temp_clip); |
2312 | + copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), temp_clip); |
2313 | no_more = true; |
2314 | } |
2315 | - selection->setReprList((GSList const *) copied); |
2316 | - g_slist_free(copied); |
2317 | - if (temp_clip) g_slist_free(temp_clip); |
2318 | + selection->setReprList(copied); |
2319 | if (next) dt->setCurrentLayer(next); |
2320 | if ( !suppressDone ) { |
2321 | DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_NEXT, |
2322 | @@ -1383,7 +1352,6 @@ |
2323 | dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No more layers above.")); |
2324 | } |
2325 | |
2326 | - g_slist_free(const_cast<GSList *>(items)); |
2327 | } |
2328 | |
2329 | void sp_selection_to_prev_layer(SPDesktop *dt, bool suppressDone) |
2330 | @@ -1396,26 +1364,24 @@ |
2331 | return; |
2332 | } |
2333 | |
2334 | - GSList const *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); |
2335 | + const std::vector<SPItem*> items(selection->itemList()); |
2336 | |
2337 | bool no_more = false; // Set to true, if no more layers below |
2338 | SPObject *next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); |
2339 | if (next) { |
2340 | sp_selection_change_layer_maintain_clones(items,next); |
2341 | - GSList *temp_clip = NULL; |
2342 | - sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs |
2343 | + std::vector<Inkscape::XML::Node*> temp_clip; |
2344 | + sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs |
2345 | sp_selection_delete_impl(items, false, false); |
2346 | next=Inkscape::previous_layer(dt->currentRoot(), dt->currentLayer()); // Fixes bug 1482973: crash while moving layers |
2347 | - GSList *copied; |
2348 | + std::vector<Inkscape::XML::Node*> copied; |
2349 | if (next) { |
2350 | - copied = sp_selection_paste_impl(dt->getDocument(), next, &temp_clip); |
2351 | + copied = sp_selection_paste_impl(dt->getDocument(), next, temp_clip); |
2352 | } else { |
2353 | - copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), &temp_clip); |
2354 | + copied = sp_selection_paste_impl(dt->getDocument(), dt->currentLayer(), temp_clip); |
2355 | no_more = true; |
2356 | } |
2357 | - selection->setReprList((GSList const *) copied); |
2358 | - g_slist_free(copied); |
2359 | - if (temp_clip) g_slist_free(temp_clip); |
2360 | + selection->setReprList( copied); |
2361 | if (next) dt->setCurrentLayer(next); |
2362 | if ( !suppressDone ) { |
2363 | DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO_PREV, |
2364 | @@ -1428,8 +1394,6 @@ |
2365 | if (no_more) { |
2366 | dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No more layers below.")); |
2367 | } |
2368 | - |
2369 | - g_slist_free(const_cast<GSList *>(items)); |
2370 | } |
2371 | |
2372 | void sp_selection_to_layer(SPDesktop *dt, SPObject *moveto, bool suppressDone) |
2373 | @@ -1442,25 +1406,22 @@ |
2374 | return; |
2375 | } |
2376 | |
2377 | - GSList const *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); |
2378 | + std::vector<SPItem*> items(selection->itemList()); |
2379 | |
2380 | if (moveto) { |
2381 | sp_selection_change_layer_maintain_clones(items,moveto); |
2382 | - GSList *temp_clip = NULL; |
2383 | - sp_selection_copy_impl(items, &temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs |
2384 | + std::vector<Inkscape::XML::Node*> temp_clip; |
2385 | + sp_selection_copy_impl(items, temp_clip, dt->doc()->getReprDoc()); // we're in the same doc, so no need to copy defs |
2386 | sp_selection_delete_impl(items, false, false); |
2387 | - GSList *copied = sp_selection_paste_impl(dt->getDocument(), moveto, &temp_clip); |
2388 | - selection->setReprList((GSList const *) copied); |
2389 | - g_slist_free(copied); |
2390 | - if (temp_clip) g_slist_free(temp_clip); |
2391 | + std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(dt->getDocument(), moveto, temp_clip); |
2392 | + selection->setReprList(copied); |
2393 | + if (!temp_clip.empty()) temp_clip.clear(); |
2394 | if (moveto) dt->setCurrentLayer(moveto); |
2395 | if ( !suppressDone ) { |
2396 | DocumentUndo::done(dt->getDocument(), SP_VERB_LAYER_MOVE_TO, |
2397 | _("Move selection to layer")); |
2398 | } |
2399 | } |
2400 | - |
2401 | - g_slist_free(const_cast<GSList *>(items)); |
2402 | } |
2403 | |
2404 | static bool |
2405 | @@ -1495,8 +1456,9 @@ |
2406 | selection_contains_both_clone_and_original(Inkscape::Selection *selection) |
2407 | { |
2408 | bool clone_with_original = false; |
2409 | - for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { |
2410 | - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(l->data)); |
2411 | + std::vector<SPItem*> items = selection->itemList(); |
2412 | + for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;l++) { |
2413 | + SPItem *item = *l; |
2414 | if (item) { |
2415 | clone_with_original |= selection_contains_original(item, selection); |
2416 | if (clone_with_original) |
2417 | @@ -1539,9 +1501,9 @@ |
2418 | |
2419 | persp3d_apply_affine_transformation(transf_persp, affine); |
2420 | } |
2421 | - |
2422 | - for (GSList const *l = selection->itemList(); l != NULL; l = l->next) { |
2423 | - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(l->data)); |
2424 | + std::vector<SPItem*> items = selection->itemList(); |
2425 | + for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;l++) { |
2426 | + SPItem *item = *l; |
2427 | |
2428 | if( dynamic_cast<SPRoot *>(item) ) { |
2429 | // An SVG element cannot have a transform. We could change 'x' and 'y' in response |
2430 | @@ -1710,10 +1672,9 @@ |
2431 | |
2432 | Inkscape::Selection *selection = desktop->getSelection(); |
2433 | |
2434 | - GSList const *l = const_cast<GSList *>(selection->reprList()); |
2435 | - while (l != NULL) { |
2436 | - ((Inkscape::XML::Node*)l->data)->setAttribute("transform", NULL, false); |
2437 | - l = l->next; |
2438 | + std::vector<Inkscape::XML::Node*> items = selection->reprList(); |
2439 | + for (std::vector<Inkscape::XML::Node*>::const_iterator l=items.begin();l!=items.end() ;l++) { |
2440 | + (*l)->setAttribute("transform", NULL, false); |
2441 | } |
2442 | |
2443 | DocumentUndo::done(desktop->getDocument(), SP_VERB_OBJECT_FLATTEN, |
2444 | @@ -1811,10 +1772,10 @@ |
2445 | if (selection->isEmpty()) |
2446 | return; |
2447 | |
2448 | - GSList const *l = selection->itemList(); |
2449 | + std::vector<SPItem*> items = selection->itemList(); |
2450 | Geom::Rotate const rot_90(Geom::Point(0, ccw ? 1 : -1)); // pos. or neg. rotation, depending on the value of ccw |
2451 | - for (GSList const *l2 = l ; l2 != NULL ; l2 = l2->next) { |
2452 | - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(l2->data)); |
2453 | + for (std::vector<SPItem*>::const_iterator l=items.begin();l!=items.end() ;l++) { |
2454 | + SPItem *item = *l; |
2455 | if (item) { |
2456 | sp_item_rotate_rel(item, rot_90); |
2457 | } else { |
2458 | @@ -1870,15 +1831,15 @@ |
2459 | bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); |
2460 | bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); |
2461 | bool ingroups = TRUE; |
2462 | - |
2463 | - GSList *all_list = get_all_items(NULL, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, NULL); |
2464 | - GSList *all_matches = NULL; |
2465 | + std::vector<SPItem*> x,y; |
2466 | + std::vector<SPItem*> all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y); |
2467 | + std::vector<SPItem*> all_matches; |
2468 | |
2469 | Inkscape::Selection *selection = desktop->getSelection(); |
2470 | - |
2471 | - for (GSList const* sel_iter = selection->itemList(); sel_iter; sel_iter = sel_iter->next) { |
2472 | - SPItem *sel = dynamic_cast<SPItem *>(static_cast<SPObject *>(sel_iter->data)); |
2473 | - GSList *matches = all_list; |
2474 | + std::vector<SPItem*> items = selection->itemList(); |
2475 | + for (std::vector<SPItem*>::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { |
2476 | + SPItem *sel = *sel_iter; |
2477 | + std::vector<SPItem*> matches = all_list; |
2478 | if (fill && stroke && style) { |
2479 | matches = sp_get_same_style(sel, matches); |
2480 | } |
2481 | @@ -1891,19 +1852,12 @@ |
2482 | else if (style) { |
2483 | matches = sp_get_same_style(sel, matches,SP_STROKE_STYLE_ALL); |
2484 | } |
2485 | - all_matches = g_slist_concat (all_matches, matches); |
2486 | + all_matches.insert(all_matches.end(), matches.begin(),matches.end()); |
2487 | } |
2488 | |
2489 | selection->clear(); |
2490 | selection->setList(all_matches); |
2491 | |
2492 | - if (all_matches) { |
2493 | - g_slist_free(all_matches); |
2494 | - } |
2495 | - if (all_list) { |
2496 | - g_slist_free(all_list); |
2497 | - } |
2498 | - |
2499 | } |
2500 | |
2501 | |
2502 | @@ -1924,14 +1878,15 @@ |
2503 | bool onlyvisible = prefs->getBool("/options/kbselection/onlyvisible", true); |
2504 | bool onlysensitive = prefs->getBool("/options/kbselection/onlysensitive", true); |
2505 | bool ingroups = TRUE; |
2506 | - |
2507 | - GSList *all_list = get_all_items(NULL, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, NULL); |
2508 | - GSList *matches = all_list; |
2509 | + std::vector<SPItem*> x,y; |
2510 | + std::vector<SPItem*> all_list = get_all_items(x, desktop->currentRoot(), desktop, onlyvisible, onlysensitive, ingroups, y); |
2511 | + std::vector<SPItem*> matches = all_list; |
2512 | |
2513 | Inkscape::Selection *selection = desktop->getSelection(); |
2514 | |
2515 | - for (GSList const* sel_iter = selection->itemList(); sel_iter; sel_iter = sel_iter->next) { |
2516 | - SPItem *sel = dynamic_cast<SPItem *>(static_cast<SPObject *>(sel_iter->data)); |
2517 | + std::vector<SPItem*> items=selection->itemList(); |
2518 | + for (std::vector<SPItem*>::const_iterator sel_iter=items.begin();sel_iter!=items.end();sel_iter++) { |
2519 | + SPItem *sel = *sel_iter; |
2520 | if (sel) { |
2521 | matches = sp_get_same_object_type(sel, matches); |
2522 | } else { |
2523 | @@ -1942,12 +1897,6 @@ |
2524 | selection->clear(); |
2525 | selection->setList(matches); |
2526 | |
2527 | - if (matches) { |
2528 | - g_slist_free(matches); |
2529 | - } |
2530 | - if (all_list) { |
2531 | - g_slist_free(all_list); |
2532 | - } |
2533 | } |
2534 | |
2535 | |
2536 | @@ -1956,15 +1905,15 @@ |
2537 | * Find all items in src list that have the same fill or stroke style as sel |
2538 | * Return the list of matching items |
2539 | */ |
2540 | -GSList *sp_get_same_fill_or_stroke_color(SPItem *sel, GSList *src, SPSelectStrokeStyleType type) |
2541 | +std::vector<SPItem*> sp_get_same_fill_or_stroke_color(SPItem *sel, std::vector<SPItem*> &src, SPSelectStrokeStyleType type) |
2542 | { |
2543 | - GSList *matches = NULL; |
2544 | + std::vector<SPItem*> matches ; |
2545 | gboolean match = false; |
2546 | |
2547 | SPIPaint *sel_paint = (type == SP_FILL_COLOR) ? &(sel->style->fill) : &(sel->style->stroke); |
2548 | |
2549 | - for (GSList *i = src; i != NULL; i = i->next) { |
2550 | - SPItem *iter = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data)); |
2551 | + for (std::vector<SPItem*>::const_reverse_iterator i=src.rbegin();i!=src.rend();i++) { |
2552 | + SPItem *iter = *i; |
2553 | if (iter) { |
2554 | SPIPaint *iter_paint = (type == SP_FILL_COLOR) ? &(iter->style->fill) : &(iter->style->stroke); |
2555 | match = false; |
2556 | @@ -2003,7 +1952,7 @@ |
2557 | } |
2558 | |
2559 | if (match) { |
2560 | - matches = g_slist_prepend(matches, iter); |
2561 | + matches.push_back(iter); |
2562 | } |
2563 | } else { |
2564 | g_assert_not_reached(); |
2565 | @@ -2054,17 +2003,16 @@ |
2566 | * Find all items in src list that have the same object type as sel by type |
2567 | * Return the list of matching items |
2568 | */ |
2569 | -GSList *sp_get_same_object_type(SPItem *sel, GSList *src) |
2570 | +std::vector<SPItem*> sp_get_same_object_type(SPItem *sel, std::vector<SPItem*> &src) |
2571 | { |
2572 | - GSList *matches = NULL; |
2573 | + std::vector<SPItem*> matches; |
2574 | |
2575 | - for (GSList *i = src; i != NULL; i = i->next) { |
2576 | - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data)); |
2577 | + for (std::vector<SPItem*>::const_reverse_iterator i=src.rbegin();i!=src.rend();i++) { |
2578 | + SPItem *item = *i; |
2579 | if (item && item_type_match(sel, item) && !item->cloned) { |
2580 | - matches = g_slist_prepend (matches, item); |
2581 | + matches.push_back(item); |
2582 | } |
2583 | } |
2584 | - |
2585 | return matches; |
2586 | } |
2587 | |
2588 | @@ -2074,9 +2022,9 @@ |
2589 | * Find all items in src list that have the same stroke style as sel by type |
2590 | * Return the list of matching items |
2591 | */ |
2592 | -GSList *sp_get_same_style(SPItem *sel, GSList *src, SPSelectStrokeStyleType type) |
2593 | +std::vector<SPItem*> sp_get_same_style(SPItem *sel, std::vector<SPItem*> &src, SPSelectStrokeStyleType type) |
2594 | { |
2595 | - GSList *matches = NULL; |
2596 | + std::vector<SPItem*> matches; |
2597 | bool match = false; |
2598 | |
2599 | SPStyle *sel_style = sel->style; |
2600 | @@ -2092,16 +2040,16 @@ |
2601 | * Stroke width needs to handle transformations, so call this function |
2602 | * to get the transformed stroke width |
2603 | */ |
2604 | - GSList *objects = NULL; |
2605 | + std::vector<SPItem*> objects; |
2606 | SPStyle *sel_style_for_width = NULL; |
2607 | if (type == SP_STROKE_STYLE_WIDTH || type == SP_STROKE_STYLE_ALL || type==SP_STYLE_ALL ) { |
2608 | - objects = g_slist_prepend(objects, sel); |
2609 | + objects.push_back(sel); |
2610 | sel_style_for_width = new SPStyle(SP_ACTIVE_DOCUMENT); |
2611 | objects_query_strokewidth (objects, sel_style_for_width); |
2612 | } |
2613 | bool match_g; |
2614 | - for (GSList *i = src; i != NULL; i = i->next) { |
2615 | - SPItem *iter = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data)); |
2616 | + for (std::vector<SPItem*>::const_iterator i=src.begin();i!=src.end();i++) { |
2617 | + SPItem *iter = *i; |
2618 | if (iter) { |
2619 | match_g=true; |
2620 | SPStyle *iter_style = iter->style; |
2621 | @@ -2110,15 +2058,14 @@ |
2622 | if (type == SP_STROKE_STYLE_WIDTH|| type == SP_STROKE_STYLE_ALL|| type==SP_STYLE_ALL) { |
2623 | match = (sel_style->stroke_width.set == iter_style->stroke_width.set); |
2624 | if (sel_style->stroke_width.set && iter_style->stroke_width.set) { |
2625 | - GSList *objects = NULL; |
2626 | - objects = g_slist_prepend(objects, iter); |
2627 | + std::vector<SPItem*> objects; |
2628 | + objects.insert(objects.begin(),iter); |
2629 | SPStyle tmp_style(SP_ACTIVE_DOCUMENT); |
2630 | objects_query_strokewidth (objects, &tmp_style); |
2631 | |
2632 | if (sel_style_for_width) { |
2633 | match = (sel_style_for_width->stroke_width.computed == tmp_style.stroke_width.computed); |
2634 | } |
2635 | - g_slist_free(objects); |
2636 | } |
2637 | } |
2638 | match_g = match_g && match; |
2639 | @@ -2141,10 +2088,10 @@ |
2640 | } |
2641 | } |
2642 | } |
2643 | - match_g = match_g && match; |
2644 | + match_g = match_g && match; |
2645 | if (match_g) { |
2646 | while (iter->cloned) iter=dynamic_cast<SPItem *>(iter->parent); |
2647 | - matches = g_slist_prepend(matches, iter); |
2648 | + matches.insert(matches.begin(),iter); |
2649 | } |
2650 | } else { |
2651 | g_assert_not_reached(); |
2652 | @@ -2152,8 +2099,6 @@ |
2653 | } |
2654 | |
2655 | if( sel_style_for_width != NULL ) delete sel_style_for_width; |
2656 | - g_slist_free(objects); |
2657 | - |
2658 | return matches; |
2659 | } |
2660 | |
2661 | @@ -2307,17 +2252,9 @@ |
2662 | } |
2663 | } |
2664 | |
2665 | -namespace { |
2666 | - |
2667 | -template <typename D> |
2668 | -SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, |
2669 | - bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive); |
2670 | - |
2671 | -template <typename D> |
2672 | -SPItem *next_item_from_list(SPDesktop *desktop, GSList const *items, SPObject *root, |
2673 | - bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive); |
2674 | - |
2675 | -struct Forward { |
2676 | + |
2677 | + |
2678 | +typedef struct Forward { |
2679 | typedef SPObject *Iterator; |
2680 | |
2681 | static Iterator children(SPObject *o) { return o->firstChild(); } |
2682 | @@ -2326,9 +2263,9 @@ |
2683 | |
2684 | static SPObject *object(Iterator i) { return i; } |
2685 | static Iterator next(Iterator i) { return i->getNext(); } |
2686 | -}; |
2687 | +} Forward; |
2688 | |
2689 | -struct ListReverse { |
2690 | +typedef struct ListReverse { |
2691 | typedef GSList *Iterator; |
2692 | |
2693 | static Iterator children(SPObject *o) { |
2694 | @@ -2359,8 +2296,87 @@ |
2695 | } |
2696 | return list; |
2697 | } |
2698 | -}; |
2699 | - |
2700 | +} ListReverse; |
2701 | + |
2702 | + |
2703 | + |
2704 | +template <typename D> |
2705 | +SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, |
2706 | + bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive) |
2707 | +{ |
2708 | + typename D::Iterator children; |
2709 | + typename D::Iterator iter; |
2710 | + |
2711 | + SPItem *found=NULL; |
2712 | + |
2713 | + if (path) { |
2714 | + SPObject *object=reinterpret_cast<SPObject *>(path->data); |
2715 | + g_assert(object->parent == root); |
2716 | + if (desktop->isLayer(object)) { |
2717 | + found = next_item<D>(desktop, path->next, object, only_in_viewport, inlayer, onlyvisible, onlysensitive); |
2718 | + } |
2719 | + iter = children = D::siblings_after(object); |
2720 | + } else { |
2721 | + iter = children = D::children(root); |
2722 | + } |
2723 | + |
2724 | + while ( iter && !found ) { |
2725 | + SPObject *object=D::object(iter); |
2726 | + if (desktop->isLayer(object)) { |
2727 | + if (PREFS_SELECTION_LAYER != inlayer) { // recurse into sublayers |
2728 | + found = next_item<D>(desktop, NULL, object, only_in_viewport, inlayer, onlyvisible, onlysensitive); |
2729 | + } |
2730 | + } else { |
2731 | + SPItem *item = dynamic_cast<SPItem *>(object); |
2732 | + if ( item && |
2733 | + ( !only_in_viewport || desktop->isWithinViewport(item) ) && |
2734 | + ( !onlyvisible || !desktop->itemIsHidden(item)) && |
2735 | + ( !onlysensitive || !item->isLocked()) && |
2736 | + !desktop->isLayer(item) ) |
2737 | + { |
2738 | + found = item; |
2739 | + } |
2740 | + } |
2741 | + iter = D::next(iter); |
2742 | + } |
2743 | + |
2744 | + D::dispose(children); |
2745 | + |
2746 | + return found; |
2747 | +} |
2748 | + |
2749 | + |
2750 | +template <typename D> |
2751 | +SPItem *next_item_from_list(SPDesktop *desktop, std::vector<SPItem*> const items, |
2752 | + SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive) |
2753 | +{ |
2754 | + SPObject *current=root; |
2755 | + for(std::vector<SPItem*>::const_iterator i = items.begin();i!=items.end();i++) { |
2756 | + SPItem *item = *i; |
2757 | + if ( root->isAncestorOf(item) && |
2758 | + ( !only_in_viewport || desktop->isWithinViewport(item) ) ) |
2759 | + { |
2760 | + current = item; |
2761 | + break; |
2762 | + } |
2763 | + } |
2764 | + |
2765 | + GSList *path=NULL; |
2766 | + while ( current != root ) { |
2767 | + path = g_slist_prepend(path, current); |
2768 | + current = current->parent; |
2769 | + } |
2770 | + |
2771 | + SPItem *next; |
2772 | + // first, try from the current object |
2773 | + next = next_item<D>(desktop, path, root, only_in_viewport, inlayer, onlyvisible, onlysensitive); |
2774 | + g_slist_free(path); |
2775 | + |
2776 | + if (!next) { // if we ran out of objects, start over at the root |
2777 | + next = next_item<D>(desktop, NULL, root, only_in_viewport, inlayer, onlyvisible, onlysensitive); |
2778 | + } |
2779 | + |
2780 | + return next; |
2781 | } |
2782 | |
2783 | void |
2784 | @@ -2487,88 +2503,8 @@ |
2785 | } |
2786 | |
2787 | |
2788 | -namespace { |
2789 | - |
2790 | -template <typename D> |
2791 | -SPItem *next_item_from_list(SPDesktop *desktop, GSList const *items, |
2792 | - SPObject *root, bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive) |
2793 | -{ |
2794 | - SPObject *current=root; |
2795 | - while (items) { |
2796 | - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(items->data)); |
2797 | - if ( root->isAncestorOf(item) && |
2798 | - ( !only_in_viewport || desktop->isWithinViewport(item) ) ) |
2799 | - { |
2800 | - current = item; |
2801 | - break; |
2802 | - } |
2803 | - items = items->next; |
2804 | - } |
2805 | - |
2806 | - GSList *path=NULL; |
2807 | - while ( current != root ) { |
2808 | - path = g_slist_prepend(path, current); |
2809 | - current = current->parent; |
2810 | - } |
2811 | - |
2812 | - SPItem *next; |
2813 | - // first, try from the current object |
2814 | - next = next_item<D>(desktop, path, root, only_in_viewport, inlayer, onlyvisible, onlysensitive); |
2815 | - g_slist_free(path); |
2816 | - |
2817 | - if (!next) { // if we ran out of objects, start over at the root |
2818 | - next = next_item<D>(desktop, NULL, root, only_in_viewport, inlayer, onlyvisible, onlysensitive); |
2819 | - } |
2820 | - |
2821 | - return next; |
2822 | -} |
2823 | - |
2824 | -template <typename D> |
2825 | -SPItem *next_item(SPDesktop *desktop, GSList *path, SPObject *root, |
2826 | - bool only_in_viewport, PrefsSelectionContext inlayer, bool onlyvisible, bool onlysensitive) |
2827 | -{ |
2828 | - typename D::Iterator children; |
2829 | - typename D::Iterator iter; |
2830 | - |
2831 | - SPItem *found=NULL; |
2832 | - |
2833 | - if (path) { |
2834 | - SPObject *object=reinterpret_cast<SPObject *>(path->data); |
2835 | - g_assert(object->parent == root); |
2836 | - if (desktop->isLayer(object)) { |
2837 | - found = next_item<D>(desktop, path->next, object, only_in_viewport, inlayer, onlyvisible, onlysensitive); |
2838 | - } |
2839 | - iter = children = D::siblings_after(object); |
2840 | - } else { |
2841 | - iter = children = D::children(root); |
2842 | - } |
2843 | - |
2844 | - while ( iter && !found ) { |
2845 | - SPObject *object=D::object(iter); |
2846 | - if (desktop->isLayer(object)) { |
2847 | - if (PREFS_SELECTION_LAYER != inlayer) { // recurse into sublayers |
2848 | - found = next_item<D>(desktop, NULL, object, only_in_viewport, inlayer, onlyvisible, onlysensitive); |
2849 | - } |
2850 | - } else { |
2851 | - SPItem *item = dynamic_cast<SPItem *>(object); |
2852 | - if ( item && |
2853 | - ( !only_in_viewport || desktop->isWithinViewport(item) ) && |
2854 | - ( !onlyvisible || !desktop->itemIsHidden(item)) && |
2855 | - ( !onlysensitive || !item->isLocked()) && |
2856 | - !desktop->isLayer(item) ) |
2857 | - { |
2858 | - found = item; |
2859 | - } |
2860 | - } |
2861 | - iter = D::next(iter); |
2862 | - } |
2863 | - |
2864 | - D::dispose(children); |
2865 | - |
2866 | - return found; |
2867 | -} |
2868 | - |
2869 | -} |
2870 | + |
2871 | + |
2872 | |
2873 | /** |
2874 | * If \a item is not entirely visible then adjust visible area to centre on the centre on of |
2875 | @@ -2608,17 +2544,17 @@ |
2876 | return; |
2877 | } |
2878 | |
2879 | - GSList *reprs = g_slist_copy(const_cast<GSList *>(selection->reprList())); |
2880 | + std::vector<Inkscape::XML::Node*> reprs (selection->reprList()); |
2881 | |
2882 | selection->clear(); |
2883 | |
2884 | // sorting items from different parents sorts each parent's subset without possibly mixing them, just what we need |
2885 | - reprs = g_slist_sort(reprs, (GCompareFunc) sp_repr_compare_position); |
2886 | - |
2887 | - GSList *newsel = NULL; |
2888 | - |
2889 | - while (reprs) { |
2890 | - Inkscape::XML::Node *sel_repr = static_cast<Inkscape::XML::Node *>(reprs->data); |
2891 | + sort(reprs.begin(),reprs.end(),sp_repr_compare_position); |
2892 | + |
2893 | + std::vector<Inkscape::XML::Node*> newsel; |
2894 | + |
2895 | + for(std::vector<Inkscape::XML::Node*>::const_reverse_iterator i=reprs.rbegin();i!=reprs.rend();i++){ |
2896 | + Inkscape::XML::Node *sel_repr = *i; |
2897 | Inkscape::XML::Node *parent = sel_repr->parent(); |
2898 | |
2899 | Inkscape::XML::Node *clone = xml_doc->createElement("svg:use"); |
2900 | @@ -2634,8 +2570,7 @@ |
2901 | // add the new clone to the top of the original's parent |
2902 | parent->appendChild(clone); |
2903 | |
2904 | - newsel = g_slist_prepend(newsel, clone); |
2905 | - reprs = g_slist_remove(reprs, sel_repr); |
2906 | + newsel.push_back(clone); |
2907 | Inkscape::GC::release(clone); |
2908 | } |
2909 | |
2910 | @@ -2643,8 +2578,6 @@ |
2911 | C_("Action", "Clone")); |
2912 | |
2913 | selection->setReprList(newsel); |
2914 | - |
2915 | - g_slist_free(newsel); |
2916 | } |
2917 | |
2918 | void |
2919 | @@ -2670,11 +2603,9 @@ |
2920 | |
2921 | // Get a copy of current selection. |
2922 | bool relinked = false; |
2923 | - for (GSList *items = const_cast<GSList *>(selection->itemList()); |
2924 | - items != NULL; |
2925 | - items = items->next) |
2926 | - { |
2927 | - SPItem *item = static_cast<SPItem *>(items->data); |
2928 | + std::vector<SPItem*> items=selection->itemList(); |
2929 | + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ |
2930 | + SPItem *item = *i; |
2931 | |
2932 | if (dynamic_cast<SPUse *>(item)) { |
2933 | item->getRepr()->setAttribute("xlink:href", newref); |
2934 | @@ -2708,13 +2639,11 @@ |
2935 | } |
2936 | |
2937 | // Get a copy of current selection. |
2938 | - GSList *new_select = NULL; |
2939 | + std::vector<SPItem*> new_select; |
2940 | bool unlinked = false; |
2941 | - for (GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); |
2942 | - items != NULL; |
2943 | - items = items->next) |
2944 | - { |
2945 | - SPItem *item = static_cast<SPItem *>(items->data); |
2946 | + std::vector<SPItem*> items=selection->itemList(); |
2947 | + for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ |
2948 | + SPItem *item = *i; |
2949 | |
2950 | if (dynamic_cast<SPText *>(item)) { |
2951 | SPObject *tspan = sp_tref_convert_to_tspan(item); |
2952 | @@ -2730,7 +2659,7 @@ |
2953 | |
2954 | if (!(dynamic_cast<SPUse *>(item) || dynamic_cast<SPTRef *>(item))) { |
2955 | // keep the non-use item in the new selection |
2956 | - new_select = g_slist_prepend(new_select, item); |
2957 | + new_select.push_back(item); |
2958 | continue; |
2959 | } |
2960 | |
2961 | @@ -2740,7 +2669,7 @@ |
2962 | unlink = use->unlink(); |
2963 | // Unable to unlink use (external or invalid href?) |
2964 | if (!unlink) { |
2965 | - new_select = g_slist_prepend(new_select, item); |
2966 | + new_select.push_back(item); |
2967 | continue; |
2968 | } |
2969 | } else /*if (SP_IS_TREF(use))*/ { |
2970 | @@ -2750,13 +2679,12 @@ |
2971 | |
2972 | unlinked = true; |
2973 | // Add ungrouped items to the new selection. |
2974 | - new_select = g_slist_prepend(new_select, unlink); |
2975 | + new_select.push_back(unlink); |
2976 | } |
2977 | |
2978 | - if (new_select) { // set new selection |
2979 | + if (!new_select.empty()) { // set new selection |
2980 | selection->clear(); |
2981 | selection->setList(new_select); |
2982 | - g_slist_free(new_select); |
2983 | } |
2984 | if (!unlinked) { |
2985 | desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("<b>No clones to unlink</b> in the selection.")); |
2986 | @@ -2779,7 +2707,9 @@ |
2987 | gchar const *error = _("Select a <b>clone</b> to go to its original. Select a <b>linked offset</b> to go to its source. Select a <b>text on path</b> to go to the path. Select a <b>flowed text</b> to go to its frame."); |
2988 | |
2989 | // Check if other than two objects are selected |
2990 | - if (g_slist_length(const_cast<GSList *>(selection->itemList())) != 1 || !item) { |
2991 | + |
2992 | + std::vector<SPItem*> items=selection->itemList(); |
2993 | + if (items.size() != 1 || !item) { |
2994 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, error); |
2995 | return; |
2996 | } |
2997 | @@ -2876,14 +2806,15 @@ |
2998 | |
2999 | Inkscape::SVGOStringStream os; |
3000 | SPObject * firstItem = NULL; |
3001 | - for (const GSList * item = selection->itemList(); item != NULL; item = item->next) { |
3002 | - if (SP_IS_SHAPE(item->data) || SP_IS_TEXT(item->data)) { |
3003 | + std::vector<SPItem*> items=selection->itemList(); |
3004 | + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ |
3005 | + if (SP_IS_SHAPE(*i) || SP_IS_TEXT(*i)) { |
3006 | if (firstItem) { |
3007 | os << "|"; |
3008 | } else { |
3009 | - firstItem = SP_ITEM(item->data); |
3010 | + firstItem = SP_ITEM(*i); |
3011 | } |
3012 | - os << '#' << SP_ITEM(item->data)->getId() << ",0"; |
3013 | + os << '#' << SP_ITEM(*i)->getId() << ",0"; |
3014 | } |
3015 | } |
3016 | if (firstItem) { |
3017 | @@ -2960,12 +2891,12 @@ |
3018 | Geom::Point center( *c - corner ); // As defined by rotation center |
3019 | center[Geom::Y] = -center[Geom::Y]; |
3020 | |
3021 | - GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); |
3022 | + std::vector<SPItem*> items(selection->itemList()); |
3023 | |
3024 | //items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); // Why needed? |
3025 | |
3026 | // bottommost object, after sorting |
3027 | - SPObject *parent = SP_OBJECT(items->data)->parent; |
3028 | + SPObject *parent = items[0]->parent; |
3029 | |
3030 | Geom::Affine parent_transform; |
3031 | { |
3032 | @@ -2978,10 +2909,10 @@ |
3033 | } |
3034 | |
3035 | // Create a list of duplicates, to be pasted inside marker element. |
3036 | - GSList *repr_copies = NULL; |
3037 | - for (GSList *i = items; i != NULL; i = i->next) { |
3038 | - Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); |
3039 | - repr_copies = g_slist_prepend(repr_copies, dup); |
3040 | + std::vector<Inkscape::XML::Node*> repr_copies; |
3041 | + for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ |
3042 | + Inkscape::XML::Node *dup = (*i)->getRepr()->duplicate(xml_doc); |
3043 | + repr_copies.push_back(dup); |
3044 | } |
3045 | |
3046 | Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max())); |
3047 | @@ -2989,8 +2920,8 @@ |
3048 | if (apply) { |
3049 | // Delete objects so that their clones don't get alerted; |
3050 | // the objects will be restored inside the marker element. |
3051 | - for (GSList *i = items; i != NULL; i = i->next) { |
3052 | - SPObject *item = reinterpret_cast<SPObject*>(i->data); |
3053 | + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ |
3054 | + SPObject *item = *i; |
3055 | item->deleteObject(false); |
3056 | } |
3057 | } |
3058 | @@ -3009,7 +2940,6 @@ |
3059 | prefs->setInt("/options/clonecompensation/value", saved_compensation); |
3060 | |
3061 | |
3062 | - g_slist_free(items); |
3063 | |
3064 | DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_MARKER, |
3065 | _("Objects to marker")); |
3066 | @@ -3018,8 +2948,9 @@ |
3067 | static void sp_selection_to_guides_recursive(SPItem *item, bool wholegroups) { |
3068 | SPGroup *group = dynamic_cast<SPGroup *>(item); |
3069 | if (group && !dynamic_cast<SPBox3D *>(item) && !wholegroups) { |
3070 | - for (GSList *i = sp_item_group_item_list(group); i != NULL; i = i->next) { |
3071 | - sp_selection_to_guides_recursive(static_cast<SPItem*>(i->data), wholegroups); |
3072 | + std::vector<SPItem*> items=sp_item_group_item_list(group); |
3073 | + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ |
3074 | + sp_selection_to_guides_recursive(*i, wholegroups); |
3075 | } |
3076 | } else { |
3077 | item->convert_to_guides(); |
3078 | @@ -3034,9 +2965,9 @@ |
3079 | SPDocument *doc = desktop->getDocument(); |
3080 | Inkscape::Selection *selection = desktop->getSelection(); |
3081 | // we need to copy the list because it gets reset when objects are deleted |
3082 | - GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); |
3083 | + std::vector<SPItem*> items(selection->itemList()); |
3084 | |
3085 | - if (!items) { |
3086 | + if (items.empty()) { |
3087 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to convert to guides.")); |
3088 | return; |
3089 | } |
3090 | @@ -3049,8 +2980,8 @@ |
3091 | // and its entry in the selection list is invalid (crash). |
3092 | // Therefore: first convert all, then delete all. |
3093 | |
3094 | - for (GSList const *i = items; i != NULL; i = i->next) { |
3095 | - sp_selection_to_guides_recursive(static_cast<SPItem*>(i->data), wholegroups); |
3096 | + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ |
3097 | + sp_selection_to_guides_recursive(*i, wholegroups); |
3098 | } |
3099 | |
3100 | if (deleteitems) { |
3101 | @@ -3058,8 +2989,6 @@ |
3102 | sp_selection_delete_impl(items); |
3103 | } |
3104 | |
3105 | - g_slist_free(items); |
3106 | - |
3107 | DocumentUndo::done(doc, SP_VERB_EDIT_SELECTION_2_GUIDES, _("Objects to guides")); |
3108 | } |
3109 | |
3110 | @@ -3102,18 +3031,18 @@ |
3111 | |
3112 | doc->ensureUpToDate(); |
3113 | |
3114 | - GSList *items = g_slist_copy(const_cast<GSList *>(selection->list())); |
3115 | + std::vector<SPObject*> items(selection->list()); |
3116 | |
3117 | // Keep track of parent, this is where <use> will be inserted. |
3118 | - Inkscape::XML::Node *the_first_repr = reinterpret_cast<SPObject *>( items->data )->getRepr(); |
3119 | + Inkscape::XML::Node *the_first_repr = items[0]->getRepr(); |
3120 | Inkscape::XML::Node *the_parent_repr = the_first_repr->parent(); |
3121 | |
3122 | // Find out if we have a single group |
3123 | bool single_group = false; |
3124 | SPGroup *the_group = NULL; |
3125 | Geom::Affine transform; |
3126 | - if( g_slist_length( items ) == 1 ) { |
3127 | - SPObject *object = reinterpret_cast<SPObject *>( items->data ); |
3128 | + if( items.size() == 1 ) { |
3129 | + SPObject *object = items[0]; |
3130 | the_group = dynamic_cast<SPGroup *>(object); |
3131 | if ( the_group ) { |
3132 | single_group = true; |
3133 | @@ -3124,7 +3053,6 @@ |
3134 | if( transform.isTranslation() ) { |
3135 | |
3136 | // Create new list from group children. |
3137 | - g_slist_free(items); |
3138 | items = object->childList(false); |
3139 | |
3140 | // Hack: Temporarily set clone compensation to unmoved, so that we can move clone-originals |
3141 | @@ -3170,8 +3098,8 @@ |
3142 | } |
3143 | |
3144 | // Move selected items to new <symbol> |
3145 | - for (GSList *i = items; i != NULL; i = i->next) { |
3146 | - Inkscape::XML::Node *repr = SP_OBJECT(i->data)->getRepr(); |
3147 | + for (std::vector<SPObject*>::const_iterator i=items.begin();i!=items.end();i++){ |
3148 | + Inkscape::XML::Node *repr = (*i)->getRepr(); |
3149 | repr->parent()->removeChild(repr); |
3150 | symbol_repr->addChild(repr,NULL); |
3151 | } |
3152 | @@ -3197,7 +3125,6 @@ |
3153 | |
3154 | // Clean up |
3155 | Inkscape::GC::release(symbol_repr); |
3156 | - g_slist_free(items); |
3157 | |
3158 | DocumentUndo::done(doc, SP_VERB_EDIT_SYMBOL, _("Group to symbol")); |
3159 | } |
3160 | @@ -3238,26 +3165,25 @@ |
3161 | desktop->currentLayer()->getRepr()->appendChild(group); |
3162 | |
3163 | // Move all children of symbol to group |
3164 | - GSList* children = symbol->childList(false); |
3165 | + std::vector<SPObject*> children = symbol->childList(false); |
3166 | |
3167 | // Converting a group to a symbol inserts a group for non-translational transform. |
3168 | // In converting a symbol back to a group we strip out the inserted group (or any other |
3169 | // group that only adds a transform to the symbol content). |
3170 | - if( g_slist_length( children ) == 1 ) { |
3171 | - SPObject *object = reinterpret_cast<SPObject *>( children->data ); |
3172 | + if( children.size() == 1 ) { |
3173 | + SPObject *object = children[0]; |
3174 | if ( dynamic_cast<SPGroup *>( object ) ) { |
3175 | if( object->getAttribute("style") == NULL || |
3176 | object->getAttribute("class") == NULL ) { |
3177 | |
3178 | group->setAttribute("transform", object->getAttribute("transform")); |
3179 | - g_slist_free(children); |
3180 | children = object->childList(false); |
3181 | } |
3182 | } |
3183 | } |
3184 | |
3185 | - for (GSList* i = children; i != NULL; i = i->next ) { |
3186 | - Inkscape::XML::Node *repr = SP_OBJECT(i->data)->getRepr(); |
3187 | + for (std::vector<SPObject*>::const_reverse_iterator i=children.rbegin();i!=children.rend();i++){ |
3188 | + Inkscape::XML::Node *repr = (*i)->getRepr(); |
3189 | repr->parent()->removeChild(repr); |
3190 | group->addChild(repr,NULL); |
3191 | } |
3192 | @@ -3283,7 +3209,6 @@ |
3193 | |
3194 | // Clean up |
3195 | Inkscape::GC::release(group); |
3196 | - g_slist_free(children); |
3197 | |
3198 | DocumentUndo::done(doc, SP_VERB_EDIT_UNSYMBOL, _("Group from symbol")); |
3199 | } |
3200 | @@ -3318,12 +3243,12 @@ |
3201 | move_p[Geom::Y] = -move_p[Geom::Y]; |
3202 | Geom::Affine move = Geom::Affine(Geom::Translate(move_p)); |
3203 | |
3204 | - GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); |
3205 | + std::vector<SPItem*> items (selection->itemList()); |
3206 | |
3207 | - items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); |
3208 | + sort(items.begin(),items.end(),sp_object_compare_position); |
3209 | |
3210 | // bottommost object, after sorting |
3211 | - SPObject *parent = SP_OBJECT(items->data)->parent; |
3212 | + SPObject *parent = items[0]->parent; |
3213 | |
3214 | |
3215 | Geom::Affine parent_transform; |
3216 | @@ -3337,23 +3262,21 @@ |
3217 | } |
3218 | |
3219 | // remember the position of the first item |
3220 | - gint pos = SP_OBJECT(items->data)->getRepr()->position(); |
3221 | + gint pos = items[0]->getRepr()->position(); |
3222 | |
3223 | // create a list of duplicates |
3224 | - GSList *repr_copies = NULL; |
3225 | - for (GSList *i = items; i != NULL; i = i->next) { |
3226 | - Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); |
3227 | - repr_copies = g_slist_prepend(repr_copies, dup); |
3228 | + std::vector<Inkscape::XML::Node*> repr_copies; |
3229 | + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ |
3230 | + Inkscape::XML::Node *dup = (*i)->getRepr()->duplicate(xml_doc); |
3231 | + repr_copies.push_back(dup); |
3232 | } |
3233 | - // restore the z-order after prepends |
3234 | - repr_copies = g_slist_reverse(repr_copies); |
3235 | |
3236 | Geom::Rect bbox(desktop->dt2doc(r->min()), desktop->dt2doc(r->max())); |
3237 | |
3238 | if (apply) { |
3239 | // delete objects so that their clones don't get alerted; this object will be restored shortly |
3240 | - for (GSList *i = items; i != NULL; i = i->next) { |
3241 | - SPObject *item = reinterpret_cast<SPObject*>(i->data); |
3242 | + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ |
3243 | + SPObject *item = *i; |
3244 | item->deleteObject(false); |
3245 | } |
3246 | } |
3247 | @@ -3399,7 +3322,6 @@ |
3248 | selection->set(rectangle); |
3249 | } |
3250 | |
3251 | - g_slist_free(items); |
3252 | |
3253 | DocumentUndo::done(doc, SP_VERB_EDIT_TILE, |
3254 | _("Objects to pattern")); |
3255 | @@ -3422,15 +3344,13 @@ |
3256 | return; |
3257 | } |
3258 | |
3259 | - GSList *new_select = NULL; |
3260 | + std::vector<SPItem*> new_select; |
3261 | |
3262 | bool did = false; |
3263 | |
3264 | - for (GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); |
3265 | - items != NULL; |
3266 | - items = items->next) { |
3267 | - |
3268 | - SPItem *item = static_cast<SPItem *>(items->data); |
3269 | + std::vector<SPItem*> items(selection->itemList()); |
3270 | + for (std::vector<SPItem*>::const_reverse_iterator i=items.rbegin();i!=items.rend();i++){ |
3271 | + SPItem *item = *i; |
3272 | |
3273 | SPStyle *style = item->style; |
3274 | |
3275 | @@ -3466,7 +3386,7 @@ |
3276 | Geom::Affine transform( i->transform * pat_transform ); |
3277 | i->doWriteTransform(i->getRepr(), transform); |
3278 | |
3279 | - new_select = g_slist_prepend(new_select, i); |
3280 | + new_select.push_back(i); |
3281 | } else { |
3282 | g_assert_not_reached(); |
3283 | } |
3284 | @@ -3493,18 +3413,14 @@ |
3285 | return; |
3286 | } |
3287 | |
3288 | - GSList const *reprlst = selection->reprList(); |
3289 | + std::vector<Inkscape::XML::Node*> const reprlst = selection->reprList(); |
3290 | bool filename_search = TRUE; |
3291 | bool xdpi_search = TRUE; |
3292 | bool ydpi_search = TRUE; |
3293 | |
3294 | - for (; reprlst != NULL && |
3295 | - filename_search && |
3296 | - xdpi_search && |
3297 | - ydpi_search; |
3298 | - reprlst = reprlst->next) { |
3299 | + for (std::vector<Inkscape::XML::Node*>::const_iterator i=reprlst.begin();filename_search&&xdpi_search&&ydpi_search&&i!=reprlst.end();i++){ |
3300 | gchar const *dpi_string; |
3301 | - Inkscape::XML::Node * repr = static_cast<Inkscape::XML::Node *>(reprlst->data); |
3302 | + Inkscape::XML::Node *repr = *i; |
3303 | |
3304 | if (filename_search) { |
3305 | const gchar* tmp = repr->attribute("inkscape:export-filename"); |
3306 | @@ -3590,10 +3506,10 @@ |
3307 | } |
3308 | |
3309 | // List of the items to show; all others will be hidden |
3310 | - GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); |
3311 | + std::vector<SPItem*> items(selection->itemList()); |
3312 | |
3313 | // Sort items so that the topmost comes last |
3314 | - items = g_slist_sort(items, (GCompareFunc) sp_item_repr_compare_position); |
3315 | + sort(items.begin(),items.end(),sp_item_repr_compare_position); |
3316 | |
3317 | // Generate a random value from the current time (you may create bitmap from the same object(s) |
3318 | // multiple times, and this is done so that they don't clash) |
3319 | @@ -3604,7 +3520,7 @@ |
3320 | // Create the filename. |
3321 | gchar *const basename = g_strdup_printf("%s-%s-%u.png", |
3322 | document->getName(), |
3323 | - SP_OBJECT(items->data)->getRepr()->attribute("id"), |
3324 | + items[0]->getRepr()->attribute("id"), |
3325 | current); |
3326 | // Imagemagick is known not to handle spaces in filenames, so we replace anything but letters, |
3327 | // digits, and a few other chars, with "_" |
3328 | @@ -3624,8 +3540,8 @@ |
3329 | //g_print("%s\n", filepath); |
3330 | |
3331 | // Remember parent and z-order of the topmost one |
3332 | - gint pos = SP_OBJECT(g_slist_last(items)->data)->getRepr()->position(); |
3333 | - SPObject *parent_object = SP_OBJECT(g_slist_last(items)->data)->parent; |
3334 | + gint pos = items.back()->getRepr()->position(); |
3335 | + SPObject *parent_object = items.back()->parent; |
3336 | Inkscape::XML::Node *parent = parent_object->getRepr(); |
3337 | |
3338 | // Calculate resolution |
3339 | @@ -3717,8 +3633,6 @@ |
3340 | true, /*bool force_overwrite,*/ |
3341 | items); |
3342 | |
3343 | - g_slist_free(items); |
3344 | - |
3345 | // Run filter, if any |
3346 | if (run) { |
3347 | g_print("Running external filter: %s\n", run); |
3348 | @@ -3793,22 +3707,20 @@ |
3349 | return; |
3350 | } |
3351 | |
3352 | - GSList const *l = const_cast<GSList *>(selection->reprList()); |
3353 | - |
3354 | - GSList *p = g_slist_copy(const_cast<GSList *>(l)); |
3355 | + std::vector<Inkscape::XML::Node*> p(selection->reprList()); |
3356 | |
3357 | - p = g_slist_sort(p, (GCompareFunc) sp_repr_compare_position); |
3358 | + sort(p.begin(),p.end(),sp_repr_compare_position); |
3359 | |
3360 | selection->clear(); |
3361 | |
3362 | - gint topmost = (static_cast<Inkscape::XML::Node *>(g_slist_last(p)->data))->position(); |
3363 | - Inkscape::XML::Node *topmost_parent = (static_cast<Inkscape::XML::Node *>(g_slist_last(p)->data))->parent(); |
3364 | + int topmost = (p.back())->position(); |
3365 | + Inkscape::XML::Node *topmost_parent = (p.back())->parent(); |
3366 | |
3367 | Inkscape::XML::Node *inner = xml_doc->createElement("svg:g"); |
3368 | inner->setAttribute("inkscape:label", "Clip"); |
3369 | |
3370 | - while (p) { |
3371 | - Inkscape::XML::Node *current = static_cast<Inkscape::XML::Node *>(p->data); |
3372 | + for(std::vector<Inkscape::XML::Node*>::const_iterator i=p.begin();i!=p.end();i++){ |
3373 | + Inkscape::XML::Node *current = *i; |
3374 | |
3375 | if (current->parent() == topmost_parent) { |
3376 | Inkscape::XML::Node *spnew = current->duplicate(xml_doc); |
3377 | @@ -3817,7 +3729,7 @@ |
3378 | Inkscape::GC::release(spnew); |
3379 | topmost --; // only reduce count for those items deleted from topmost_parent |
3380 | } else { // move it to topmost_parent first |
3381 | - GSList *temp_clip = NULL; |
3382 | + std::vector<Inkscape::XML::Node*> temp_clip; |
3383 | |
3384 | // At this point, current may already have no item, due to its being a clone whose original is already moved away |
3385 | // So we copy it artificially calculating the transform from its repr->attr("transform") and the parent transform |
3386 | @@ -3833,15 +3745,14 @@ |
3387 | // then, if this is clone, looking up its original in that array and pre-multiplying |
3388 | // it by the inverse of that original's transform diff. |
3389 | |
3390 | - sp_selection_copy_one(current, item_t, &temp_clip, xml_doc); |
3391 | + sp_selection_copy_one(current, item_t, temp_clip, xml_doc); |
3392 | sp_repr_unparent(current); |
3393 | |
3394 | // paste into topmost_parent (temporarily) |
3395 | - GSList *copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), &temp_clip); |
3396 | - if (temp_clip) g_slist_free(temp_clip); |
3397 | - if (copied) { // if success, |
3398 | + std::vector<Inkscape::XML::Node*> copied = sp_selection_paste_impl(doc, doc->getObjectByRepr(topmost_parent), temp_clip); |
3399 | + if (!copied.empty()) { // if success, |
3400 | // take pasted object (now in topmost_parent) |
3401 | - Inkscape::XML::Node *in_topmost = static_cast<Inkscape::XML::Node *>(copied->data); |
3402 | + Inkscape::XML::Node *in_topmost = copied.back(); |
3403 | // make a copy |
3404 | Inkscape::XML::Node *spnew = in_topmost->duplicate(xml_doc); |
3405 | // remove pasted |
3406 | @@ -3849,10 +3760,8 @@ |
3407 | // put its copy into group |
3408 | inner->appendChild(spnew); |
3409 | Inkscape::GC::release(spnew); |
3410 | - g_slist_free(copied); |
3411 | } |
3412 | } |
3413 | - p = g_slist_remove(p, current); |
3414 | } |
3415 | |
3416 | Inkscape::XML::Node *outer = xml_doc->createElement("svg:g"); |
3417 | @@ -3910,7 +3819,7 @@ |
3418 | if ( apply_to_layer && is_empty) { |
3419 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to create clippath or mask from.")); |
3420 | return; |
3421 | - } else if (!apply_to_layer && ( is_empty || NULL == selection->itemList()->next )) { |
3422 | + } else if (!apply_to_layer && ( is_empty || selection->itemList().size()==1 )) { |
3423 | desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select mask object and <b>object(s)</b> to apply clippath or mask to.")); |
3424 | return; |
3425 | } |
3426 | @@ -3925,9 +3834,9 @@ |
3427 | |
3428 | doc->ensureUpToDate(); |
3429 | |
3430 | - GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); |
3431 | + std::vector<SPItem*> items(selection->itemList()); |
3432 | |
3433 | - items = g_slist_sort(items, (GCompareFunc) sp_object_compare_position); |
3434 | + sort(items.begin(),items.end(),sp_object_compare_position); |
3435 | |
3436 | // See lp bug #542004 |
3437 | selection->clear(); |
3438 | @@ -3936,7 +3845,7 @@ |
3439 | GSList *mask_items = NULL; |
3440 | GSList *apply_to_items = NULL; |
3441 | GSList *items_to_delete = NULL; |
3442 | - GSList *items_to_select = NULL; |
3443 | + std::vector<SPItem*> items_to_select; |
3444 | |
3445 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
3446 | bool topmost = prefs->getBool("/options/maskobject/topmost", true); |
3447 | @@ -3947,38 +3856,38 @@ |
3448 | // all selected items are used for mask, which is applied to a layer |
3449 | apply_to_items = g_slist_prepend(apply_to_items, desktop->currentLayer()); |
3450 | |
3451 | - for (GSList *i = items; i != NULL; i = i->next) { |
3452 | - Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); |
3453 | + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) { |
3454 | + Inkscape::XML::Node *dup = (*i)->getRepr()->duplicate(xml_doc); |
3455 | mask_items = g_slist_prepend(mask_items, dup); |
3456 | |
3457 | - SPObject *item = reinterpret_cast<SPObject*>(i->data); |
3458 | + SPObject *item = *i; |
3459 | if (remove_original) { |
3460 | items_to_delete = g_slist_prepend(items_to_delete, item); |
3461 | } |
3462 | else { |
3463 | - items_to_select = g_slist_prepend(items_to_select, item); |
3464 | + items_to_select.push_back((SPItem*)item); |
3465 | } |
3466 | } |
3467 | } else if (!topmost) { |
3468 | // topmost item is used as a mask, which is applied to other items in a selection |
3469 | - GSList *i = items; |
3470 | - Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); |
3471 | + Inkscape::XML::Node *dup = items[0]->getRepr()->duplicate(xml_doc); |
3472 | mask_items = g_slist_prepend(mask_items, dup); |
3473 | |
3474 | if (remove_original) { |
3475 | - SPObject *item = reinterpret_cast<SPObject*>(i->data); |
3476 | + SPObject *item = items.front(); |
3477 | items_to_delete = g_slist_prepend(items_to_delete, item); |
3478 | } |
3479 | |
3480 | - for (i = i->next; i != NULL; i = i->next) { |
3481 | - apply_to_items = g_slist_prepend(apply_to_items, i->data); |
3482 | - items_to_select = g_slist_prepend(items_to_select, i->data); |
3483 | + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) { |
3484 | + if(i==items.begin())continue; |
3485 | + apply_to_items = g_slist_prepend(apply_to_items, *i); |
3486 | + items_to_select.push_back(*i); |
3487 | } |
3488 | } else { |
3489 | GSList *i = NULL; |
3490 | - for (i = items; NULL != i->next; i = i->next) { |
3491 | - apply_to_items = g_slist_prepend(apply_to_items, i->data); |
3492 | - items_to_select = g_slist_prepend(items_to_select, i->data); |
3493 | + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) { |
3494 | + apply_to_items = g_slist_prepend(apply_to_items, *i); |
3495 | + items_to_select.push_back(*i); |
3496 | } |
3497 | |
3498 | Inkscape::XML::Node *dup = SP_OBJECT(i->data)->getRepr()->duplicate(xml_doc); |
3499 | @@ -3989,9 +3898,7 @@ |
3500 | items_to_delete = g_slist_prepend(items_to_delete, item); |
3501 | } |
3502 | } |
3503 | - |
3504 | - g_slist_free(items); |
3505 | - items = NULL; |
3506 | + items.clear(); |
3507 | |
3508 | if (apply_to_items && grouping == PREFS_MASKOBJECT_GROUPING_ALL) { |
3509 | // group all those objects into one group |
3510 | @@ -4001,24 +3908,21 @@ |
3511 | // make a note we should ungroup this when unsetting mask |
3512 | group->setAttribute("inkscape:groupmode", "maskhelper"); |
3513 | |
3514 | - GSList *reprs_to_group = NULL; |
3515 | + std::vector<Inkscape::XML::Node*> reprs_to_group; |
3516 | |
3517 | for (GSList *i = apply_to_items ; NULL != i ; i = i->next) { |
3518 | - reprs_to_group = g_slist_prepend(reprs_to_group, SP_OBJECT(i->data)->getRepr()); |
3519 | - items_to_select = g_slist_remove(items_to_select, i->data); |
3520 | + reprs_to_group.push_back(static_cast<SPObject*>(i->data)->getRepr()); |
3521 | + items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),static_cast<SPObject*>(i->data))); |
3522 | } |
3523 | - reprs_to_group = g_slist_reverse(reprs_to_group); |
3524 | |
3525 | sp_selection_group_impl(reprs_to_group, group, xml_doc, doc); |
3526 | |
3527 | - reprs_to_group = NULL; |
3528 | - |
3529 | // apply clip/mask only to newly created group |
3530 | g_slist_free(apply_to_items); |
3531 | apply_to_items = NULL; |
3532 | apply_to_items = g_slist_prepend(apply_to_items, doc->getObjectByRepr(group)); |
3533 | |
3534 | - items_to_select = g_slist_prepend(items_to_select, doc->getObjectByRepr(group)); |
3535 | + items_to_select.push_back((SPItem*)(doc->getObjectByRepr(group))); |
3536 | |
3537 | Inkscape::GC::release(group); |
3538 | } |
3539 | @@ -4058,7 +3962,7 @@ |
3540 | |
3541 | Inkscape::XML::Node *spnew = current->duplicate(xml_doc); |
3542 | gint position = current->position(); |
3543 | - items_to_select = g_slist_remove(items_to_select, item); |
3544 | + items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),item)); |
3545 | current->parent()->appendChild(group); |
3546 | sp_repr_unparent(current); |
3547 | group->appendChild(spnew); |
3548 | @@ -4067,7 +3971,7 @@ |
3549 | // Apply clip/mask to group instead |
3550 | apply_mask_to = group; |
3551 | |
3552 | - items_to_select = g_slist_prepend(items_to_select, doc->getObjectByRepr(group)); |
3553 | + items_to_select.push_back((SPItem*)(doc->getObjectByRepr(group))); |
3554 | Inkscape::GC::release(spnew); |
3555 | Inkscape::GC::release(group); |
3556 | } |
3557 | @@ -4082,14 +3986,11 @@ |
3558 | for (GSList *i = items_to_delete; NULL != i; i = i->next) { |
3559 | SPObject *item = reinterpret_cast<SPObject*>(i->data); |
3560 | item->deleteObject(false); |
3561 | - items_to_select = g_slist_remove(items_to_select, item); |
3562 | + items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),item)); |
3563 | } |
3564 | g_slist_free(items_to_delete); |
3565 | |
3566 | - items_to_select = g_slist_reverse(items_to_select); |
3567 | - |
3568 | selection->addList(items_to_select); |
3569 | - g_slist_free(items_to_select); |
3570 | |
3571 | if (apply_clip_path) { |
3572 | DocumentUndo::done(doc, SP_VERB_OBJECT_SET_CLIPPATH, _("Set clipping path")); |
3573 | @@ -4121,20 +4022,19 @@ |
3574 | gchar const *attributeName = apply_clip_path ? "clip-path" : "mask"; |
3575 | std::map<SPObject*,SPItem*> referenced_objects; |
3576 | |
3577 | - GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList())); |
3578 | + std::vector<SPItem*> items(selection->itemList()); |
3579 | selection->clear(); |
3580 | |
3581 | GSList *items_to_ungroup = NULL; |
3582 | - GSList *items_to_select = g_slist_copy(items); |
3583 | - items_to_select = g_slist_reverse(items_to_select); |
3584 | + std::vector<SPItem*> items_to_select(items); |
3585 | |
3586 | |
3587 | // SPObject* refers to a group containing the clipped path or mask itself, |
3588 | // whereas SPItem* refers to the item being clipped or masked |
3589 | - for (GSList const *i = items; NULL != i; i = i->next) { |
3590 | + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++){ |
3591 | if (remove_original) { |
3592 | // remember referenced mask/clippath, so orphaned masks can be moved back to document |
3593 | - SPItem *item = reinterpret_cast<SPItem *>(i->data); |
3594 | + SPItem *item = *i; |
3595 | Inkscape::URIReference *uri_ref = NULL; |
3596 | |
3597 | if (apply_clip_path) { |
3598 | @@ -4149,9 +4049,9 @@ |
3599 | } |
3600 | } |
3601 | |
3602 | - SP_OBJECT(i->data)->getRepr()->setAttribute(attributeName, "none"); |
3603 | + (*i)->getRepr()->setAttribute(attributeName, "none"); |
3604 | |
3605 | - SPGroup *group = dynamic_cast<SPGroup *>(static_cast<SPObject *>(i->data)); |
3606 | + SPGroup *group = dynamic_cast<SPGroup *>(*i); |
3607 | if (ungroup_masked && group) { |
3608 | // if we had previously enclosed masked object in group, |
3609 | // add it to list so we can ungroup it later |
3610 | @@ -4163,7 +4063,6 @@ |
3611 | |
3612 | } |
3613 | } |
3614 | - g_slist_free(items); |
3615 | |
3616 | // restore mask objects into a document |
3617 | for ( std::map<SPObject*,SPItem*>::iterator it = referenced_objects.begin() ; it != referenced_objects.end() ; ++it) { |
3618 | @@ -4171,7 +4070,7 @@ |
3619 | GSList *items_to_move = NULL; |
3620 | for ( SPObject *child = obj->firstChild() ; child; child = child->getNext() ) { |
3621 | // Collect all clipped paths and masks within a single group |
3622 | - Inkscape::XML::Node *copy = SP_OBJECT(child)->getRepr()->duplicate(xml_doc); |
3623 | + Inkscape::XML::Node *copy = child->getRepr()->duplicate(xml_doc); |
3624 | if(copy->attribute("inkscape:original-d") && copy->attribute("inkscape:path-effect")) |
3625 | { |
3626 | copy->setAttribute("d", copy->attribute("inkscape:original-d")); |
3627 | @@ -4197,7 +4096,7 @@ |
3628 | repr->setPosition((pos + 1) > 0 ? (pos + 1) : 0); |
3629 | |
3630 | SPItem *mask_item = static_cast<SPItem *>(desktop->getDocument()->getObjectByRepr(repr)); |
3631 | - items_to_select = g_slist_prepend(items_to_select, mask_item); |
3632 | + items_to_select.push_back(mask_item); |
3633 | |
3634 | // transform mask, so it is moved the same spot where mask was applied |
3635 | Geom::Affine transform(mask_item->transform); |
3636 | @@ -4212,10 +4111,10 @@ |
3637 | for (GSList *i = items_to_ungroup ; NULL != i ; i = i->next) { |
3638 | SPGroup *group = dynamic_cast<SPGroup *>(static_cast<SPObject *>(i->data)); |
3639 | if (group) { |
3640 | - items_to_select = g_slist_remove(items_to_select, group); |
3641 | - GSList *children = NULL; |
3642 | - sp_item_group_ungroup(group, &children, false); |
3643 | - items_to_select = g_slist_concat(children, items_to_select); |
3644 | + items_to_select.erase(find(items_to_select.begin(),items_to_select.end(),group)); |
3645 | + std::vector<SPItem*> children; |
3646 | + sp_item_group_ungroup(group, children, false); |
3647 | + items_to_select.insert(items_to_select.end(),children.rbegin(),children.rend()); |
3648 | } else { |
3649 | g_assert_not_reached(); |
3650 | } |
3651 | @@ -4224,9 +4123,7 @@ |
3652 | g_slist_free(items_to_ungroup); |
3653 | |
3654 | // rebuild selection |
3655 | - items_to_select = g_slist_reverse(items_to_select); |
3656 | selection->addList(items_to_select); |
3657 | - g_slist_free(items_to_select); |
3658 | |
3659 | if (apply_clip_path) { |
3660 | DocumentUndo::done(doc, SP_VERB_OBJECT_UNSET_CLIPPATH, _("Release clipping path")); |
3661 | |
3662 | === modified file 'src/selection-chemistry.h' |
3663 | --- src/selection-chemistry.h 2015-02-20 15:50:51 +0000 |
3664 | +++ src/selection-chemistry.h 2015-04-29 21:03:59 +0000 |
3665 | @@ -143,8 +143,9 @@ |
3666 | |
3667 | void sp_select_same_fill_stroke_style(SPDesktop *desktop, gboolean fill, gboolean strok, gboolean style); |
3668 | void sp_select_same_object_type(SPDesktop *desktop); |
3669 | -GSList *sp_get_same_style(SPItem *sel, GSList *src, SPSelectStrokeStyleType type=SP_STYLE_ALL); |
3670 | -GSList *sp_get_same_object_type(SPItem *sel, GSList *src); |
3671 | + |
3672 | +std::vector<SPItem*> sp_get_same_style(SPItem *sel, std::vector<SPItem*> &src, SPSelectStrokeStyleType type=SP_STYLE_ALL); |
3673 | +std::vector<SPItem*> sp_get_same_object_type(SPItem *sel, std::vector<SPItem*> &src); |
3674 | |
3675 | void scroll_to_show_item(SPDesktop *desktop, SPItem *item); |
3676 | |
3677 | @@ -171,9 +172,9 @@ |
3678 | void unhide_all(SPDesktop *dt); |
3679 | void unhide_all_in_all_layers(SPDesktop *dt); |
3680 | |
3681 | -GSList *get_all_items(GSList *list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, GSList const *exclude); |
3682 | +std::vector<SPItem*> &get_all_items(std::vector<SPItem*> &list, SPObject *from, SPDesktop *desktop, bool onlyvisible, bool onlysensitive, bool ingroups, std::vector<SPItem*> const &exclude); |
3683 | |
3684 | -GSList *sp_degroup_list (GSList *items); |
3685 | +std::vector<SPItem*> sp_degroup_list (std::vector<SPItem*> &items); |
3686 | |
3687 | /* selection cycling */ |
3688 | typedef enum |
3689 | |
3690 | === modified file 'src/selection-describer.cpp' |
3691 | --- src/selection-describer.cpp 2015-03-06 08:51:53 +0000 |
3692 | +++ src/selection-describer.cpp 2015-04-29 21:03:59 +0000 |
3693 | @@ -40,14 +40,14 @@ |
3694 | #include "sp-spiral.h" |
3695 | |
3696 | // Returns a list of terms for the items to be used in the statusbar |
3697 | -char* collect_terms (GSList *items) |
3698 | +char* collect_terms (const std::vector<SPItem*> &items) |
3699 | { |
3700 | GSList *check = NULL; |
3701 | std::stringstream ss; |
3702 | bool first = true; |
3703 | |
3704 | - for (GSList *i = (GSList *)items; i != NULL; i = i->next) { |
3705 | - SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(i->data)); |
3706 | + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
3707 | + SPItem *item = *iter; |
3708 | if (item) { |
3709 | const char *term = item->displayName(); |
3710 | if (term != NULL && g_slist_find (check, term) == NULL) { |
3711 | @@ -61,12 +61,12 @@ |
3712 | } |
3713 | |
3714 | // Returns the number of terms in the list |
3715 | -static int count_terms (GSList *items) |
3716 | +static int count_terms (const std::vector<SPItem*> &items) |
3717 | { |
3718 | GSList *check = NULL; |
3719 | int count=0; |
3720 | - for (GSList *i = (GSList *)items; i != NULL; i = i->next) { |
3721 | - SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(i->data)); |
3722 | + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
3723 | + SPItem *item = *iter; |
3724 | if (item) { |
3725 | const char *term = item->displayName(); |
3726 | if (term != NULL && g_slist_find (check, term) == NULL) { |
3727 | @@ -79,11 +79,11 @@ |
3728 | } |
3729 | |
3730 | // Returns the number of filtered items in the list |
3731 | -static int count_filtered (GSList *items) |
3732 | +static int count_filtered (const std::vector<SPItem*> &items) |
3733 | { |
3734 | int count=0; |
3735 | - for (GSList *i = items; i != NULL; i = i->next) { |
3736 | - SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>((i->data))); |
3737 | + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
3738 | + SPItem *item = *iter; |
3739 | if (item) { |
3740 | count += item->isFiltered(); |
3741 | } |
3742 | @@ -122,12 +122,12 @@ |
3743 | } |
3744 | |
3745 | void SelectionDescriber::_updateMessageFromSelection(Inkscape::Selection *selection) { |
3746 | - GSList const *items = selection->itemList(); |
3747 | + std::vector<SPItem*> const items = selection->itemList(); |
3748 | |
3749 | - if (!items) { // no items |
3750 | + if (items.empty()) { // no items |
3751 | _context.set(Inkscape::NORMAL_MESSAGE, _when_nothing); |
3752 | } else { |
3753 | - SPItem *item = dynamic_cast<SPItem *>(reinterpret_cast<SPObject *>(items->data)); |
3754 | + SPItem *item = items[0]; |
3755 | g_assert(item != NULL); |
3756 | SPObject *layer = selection->layers()->layerForObject(item); |
3757 | SPObject *root = selection->layers()->currentRoot(); |
3758 | @@ -188,7 +188,7 @@ |
3759 | g_free (layer_name); |
3760 | g_free (parent_name); |
3761 | |
3762 | - if (!items->next) { // one item |
3763 | + if (items.size()==1) { // one item |
3764 | char *item_desc = item->detailedDescription(); |
3765 | |
3766 | bool isUse = dynamic_cast<SPUse *>(item) != NULL; |
3767 | @@ -228,9 +228,9 @@ |
3768 | |
3769 | g_free(item_desc); |
3770 | } else { // multiple items |
3771 | - int objcount = g_slist_length((GSList *)items); |
3772 | - char *terms = collect_terms ((GSList *)items); |
3773 | - int n_terms = count_terms((GSList *)items); |
3774 | + int objcount = items.size(); |
3775 | + char *terms = collect_terms (items); |
3776 | + int n_terms = count_terms(items); |
3777 | |
3778 | gchar *objects_str = g_strdup_printf(ngettext( |
3779 | "<b>%1$i</b> objects selected of type %2$s", |
3780 | @@ -241,7 +241,7 @@ |
3781 | |
3782 | // indicate all, some, or none filtered |
3783 | gchar *filt_str = NULL; |
3784 | - int n_filt = count_filtered((GSList *)items); //all filtered |
3785 | + int n_filt = count_filtered(items); //all filtered |
3786 | if (n_filt) { |
3787 | filt_str = g_strdup_printf(ngettext("; <i>%d filtered object</i> ", |
3788 | "; <i>%d filtered objects</i> ", n_filt), n_filt); |
3789 | |
3790 | === modified file 'src/selection.cpp' |
3791 | --- src/selection.cpp 2014-06-27 19:23:06 +0000 |
3792 | +++ src/selection.cpp 2015-04-29 21:03:59 +0000 |
3793 | @@ -42,9 +42,11 @@ |
3794 | namespace Inkscape { |
3795 | |
3796 | Selection::Selection(LayerModel *layers, SPDesktop *desktop) : |
3797 | - _objs(NULL), |
3798 | - _reprs(NULL), |
3799 | - _items(NULL), |
3800 | + _objs(std::list<SPObject*>()), |
3801 | + _objs_vector(std::vector<SPObject*>()), |
3802 | + _objs_set(std::set<SPObject*>()), |
3803 | + _reprs(std::vector<XML::Node*>()), |
3804 | + _items(std::vector<SPItem*>()), |
3805 | _layers(layers), |
3806 | _desktop(desktop), |
3807 | _selection_context(NULL), |
3808 | @@ -121,17 +123,14 @@ |
3809 | } |
3810 | |
3811 | void Selection::_invalidateCachedLists() { |
3812 | - g_slist_free(_items); |
3813 | - _items = NULL; |
3814 | - |
3815 | - g_slist_free(_reprs); |
3816 | - _reprs = NULL; |
3817 | + _items.clear(); |
3818 | + _reprs.clear(); |
3819 | } |
3820 | |
3821 | void Selection::_clear() { |
3822 | _invalidateCachedLists(); |
3823 | - while (_objs) { |
3824 | - SPObject *obj=reinterpret_cast<SPObject *>(_objs->data); |
3825 | + while (!_objs.empty()) { |
3826 | + SPObject *obj=_objs.front(); |
3827 | _remove(obj); |
3828 | } |
3829 | } |
3830 | @@ -148,7 +147,7 @@ |
3831 | |
3832 | g_return_val_if_fail(SP_IS_OBJECT(obj), FALSE); |
3833 | |
3834 | - return ( g_slist_find(_objs, obj) != NULL ); |
3835 | + return ( _objs_set.find(obj)!=_objs_set.end() ); |
3836 | } |
3837 | |
3838 | void Selection::add(SPObject *obj, bool persist_selection_context/* = false */) { |
3839 | @@ -180,7 +179,8 @@ |
3840 | _removeObjectDescendants(obj); |
3841 | _removeObjectAncestors(obj); |
3842 | |
3843 | - _objs = g_slist_prepend(_objs, obj); |
3844 | + _objs.push_front(obj); |
3845 | + _objs_set.insert(obj); |
3846 | |
3847 | add_3D_boxes_recursively(obj); |
3848 | |
3849 | @@ -234,26 +234,27 @@ |
3850 | |
3851 | remove_3D_boxes_recursively(obj); |
3852 | |
3853 | - _objs = g_slist_remove(_objs, obj); |
3854 | + _objs.remove(obj); |
3855 | + _objs_set.erase(obj); |
3856 | } |
3857 | |
3858 | -void Selection::setList(GSList const *list) { |
3859 | +void Selection::setList(std::vector<SPItem*> const &list) { |
3860 | // Clear and add, or just clear with emit. |
3861 | - if (list != NULL) { |
3862 | + if (!list.empty()) { |
3863 | _clear(); |
3864 | addList(list); |
3865 | } else clear(); |
3866 | } |
3867 | |
3868 | -void Selection::addList(GSList const *list) { |
3869 | +void Selection::addList(std::vector<SPItem*> const &list) { |
3870 | |
3871 | - if (list == NULL) |
3872 | + if (list.empty()) |
3873 | return; |
3874 | |
3875 | _invalidateCachedLists(); |
3876 | |
3877 | - for ( GSList const *iter = list ; iter != NULL ; iter = iter->next ) { |
3878 | - SPObject *obj = reinterpret_cast<SPObject *>(iter->data); |
3879 | + for ( std::vector<SPItem*>::const_iterator iter=list.begin();iter!=list.end();iter++ ) { |
3880 | + SPObject *obj = *iter; |
3881 | if (includes(obj)) continue; |
3882 | _add (obj); |
3883 | } |
3884 | @@ -261,11 +262,11 @@ |
3885 | _emitChanged(); |
3886 | } |
3887 | |
3888 | -void Selection::setReprList(GSList const *list) { |
3889 | +void Selection::setReprList(std::vector<XML::Node*> const &list) { |
3890 | _clear(); |
3891 | |
3892 | - for ( GSList const *iter = list ; iter != NULL ; iter = iter->next ) { |
3893 | - SPObject *obj=_objectForXMLNode(reinterpret_cast<Inkscape::XML::Node *>(iter->data)); |
3894 | + for ( std::vector<XML::Node*>::const_reverse_iterator iter=list.rbegin();iter!=list.rend();iter++ ) { |
3895 | + SPObject *obj=_objectForXMLNode(*iter); |
3896 | if (obj) { |
3897 | _add(obj); |
3898 | } |
3899 | @@ -279,35 +280,38 @@ |
3900 | _emitChanged(); |
3901 | } |
3902 | |
3903 | -GSList const *Selection::list() { |
3904 | - return _objs; |
3905 | +std::vector<SPObject*> const &Selection::list() { |
3906 | + if(!_objs_vector.empty()) |
3907 | + return _objs_vector; |
3908 | + |
3909 | + for ( std::list<SPObject*>::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { |
3910 | + _objs_vector.push_back(*iter); |
3911 | + } |
3912 | + return _objs_vector; |
3913 | + |
3914 | } |
3915 | |
3916 | -GSList const *Selection::itemList() { |
3917 | - if (_items) { |
3918 | +std::vector<SPItem*> const &Selection::itemList() { |
3919 | + if (!_items.empty()) { |
3920 | return _items; |
3921 | } |
3922 | |
3923 | - for ( GSList const *iter=_objs ; iter != NULL ; iter = iter->next ) { |
3924 | - SPObject *obj=reinterpret_cast<SPObject *>(iter->data); |
3925 | + for ( std::list<SPObject*>::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { |
3926 | + SPObject *obj=*iter; |
3927 | if (SP_IS_ITEM(obj)) { |
3928 | - _items = g_slist_prepend(_items, SP_ITEM(obj)); |
3929 | + _items.push_back(SP_ITEM(obj)); |
3930 | } |
3931 | } |
3932 | - _items = g_slist_reverse(_items); |
3933 | - |
3934 | return _items; |
3935 | } |
3936 | |
3937 | -GSList const *Selection::reprList() { |
3938 | - if (_reprs) { return _reprs; } |
3939 | - |
3940 | - for ( GSList const *iter=itemList() ; iter != NULL ; iter = iter->next ) { |
3941 | - SPObject *obj=reinterpret_cast<SPObject *>(iter->data); |
3942 | - _reprs = g_slist_prepend(_reprs, obj->getRepr()); |
3943 | +std::vector<XML::Node*> const &Selection::reprList() { |
3944 | + if (!_reprs.empty()) { return _reprs; } |
3945 | + std::vector<SPItem*> list = itemList(); |
3946 | + for ( std::vector<SPItem*>::const_iterator iter=list.begin();iter!=list.end();iter++ ) { |
3947 | + SPObject *obj = *iter; |
3948 | + _reprs.push_back(obj->getRepr()); |
3949 | } |
3950 | - _reprs = g_slist_reverse(_reprs); |
3951 | - |
3952 | return _reprs; |
3953 | } |
3954 | |
3955 | @@ -337,17 +341,17 @@ |
3956 | } |
3957 | |
3958 | SPObject *Selection::single() { |
3959 | - if ( _objs != NULL && _objs->next == NULL ) { |
3960 | - return reinterpret_cast<SPObject *>(_objs->data); |
3961 | + if ( _objs.size() == 1 ) { |
3962 | + return _objs.front(); |
3963 | } else { |
3964 | return NULL; |
3965 | } |
3966 | } |
3967 | |
3968 | SPItem *Selection::singleItem() { |
3969 | - GSList const *items=itemList(); |
3970 | - if ( items != NULL && items->next == NULL ) { |
3971 | - return reinterpret_cast<SPItem *>(items->data); |
3972 | + std::vector<SPItem*> const items=itemList(); |
3973 | + if ( items.size()==1) { |
3974 | + return items[0]; |
3975 | } else { |
3976 | return NULL; |
3977 | } |
3978 | @@ -362,12 +366,12 @@ |
3979 | } |
3980 | |
3981 | SPItem *Selection::_sizeistItem(bool sml, Selection::CompareSize compare) { |
3982 | - GSList const *items = const_cast<Selection *>(this)->itemList(); |
3983 | + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); |
3984 | gdouble max = sml ? 1e18 : 0; |
3985 | SPItem *ist = NULL; |
3986 | |
3987 | - for ( GSList const *i = items; i != NULL ; i = i->next ) { |
3988 | - Geom::OptRect obox = SP_ITEM(i->data)->desktopPreferredBounds(); |
3989 | + for ( std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++ ) { |
3990 | + Geom::OptRect obox = SP_ITEM(*i)->desktopPreferredBounds(); |
3991 | if (!obox || obox.isEmpty()) continue; |
3992 | Geom::Rect bbox = *obox; |
3993 | |
3994 | @@ -376,7 +380,7 @@ |
3995 | size = sml ? size : size * -1; |
3996 | if (size < max) { |
3997 | max = size; |
3998 | - ist = SP_ITEM(i->data); |
3999 | + ist = SP_ITEM(*i); |
4000 | } |
4001 | } |
4002 | return ist; |
4003 | @@ -395,22 +399,22 @@ |
4004 | |
4005 | Geom::OptRect Selection::geometricBounds() const |
4006 | { |
4007 | - GSList const *items = const_cast<Selection *>(this)->itemList(); |
4008 | + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); |
4009 | |
4010 | Geom::OptRect bbox; |
4011 | - for ( GSList const *i = items ; i != NULL ; i = i->next ) { |
4012 | - bbox.unionWith(SP_ITEM(i->data)->desktopGeometricBounds()); |
4013 | + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4014 | + bbox.unionWith(SP_ITEM(*iter)->desktopGeometricBounds()); |
4015 | } |
4016 | return bbox; |
4017 | } |
4018 | |
4019 | Geom::OptRect Selection::visualBounds() const |
4020 | { |
4021 | - GSList const *items = const_cast<Selection *>(this)->itemList(); |
4022 | + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); |
4023 | |
4024 | Geom::OptRect bbox; |
4025 | - for ( GSList const *i = items ; i != NULL ; i = i->next ) { |
4026 | - bbox.unionWith(SP_ITEM(i->data)->desktopVisualBounds()); |
4027 | + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4028 | + bbox.unionWith(SP_ITEM(*iter)->desktopVisualBounds()); |
4029 | } |
4030 | return bbox; |
4031 | } |
4032 | @@ -427,11 +431,11 @@ |
4033 | Geom::OptRect Selection::documentBounds(SPItem::BBoxType type) const |
4034 | { |
4035 | Geom::OptRect bbox; |
4036 | - GSList const *items = const_cast<Selection *>(this)->itemList(); |
4037 | - if (!items) return bbox; |
4038 | + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); |
4039 | + if (items.empty()) return bbox; |
4040 | |
4041 | - for ( GSList const *iter=items ; iter != NULL ; iter = iter->next ) { |
4042 | - SPItem *item = SP_ITEM(iter->data); |
4043 | + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4044 | + SPItem *item = SP_ITEM(*iter); |
4045 | bbox |= item->documentBounds(type); |
4046 | } |
4047 | |
4048 | @@ -441,9 +445,9 @@ |
4049 | // If we have a selection of multiple items, then the center of the first item |
4050 | // will be returned; this is also the case in SelTrans::centerRequest() |
4051 | boost::optional<Geom::Point> Selection::center() const { |
4052 | - GSList *items = (GSList *) const_cast<Selection *>(this)->itemList(); |
4053 | - if (items) { |
4054 | - SPItem *first = reinterpret_cast<SPItem*>(g_slist_last(items)->data); // from the first item in selection |
4055 | + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); |
4056 | + if (!items.empty()) { |
4057 | + SPItem *first = items.back(); // from the first item in selection |
4058 | if (first->isCenterSet()) { // only if set explicitly |
4059 | return first->getCenter(); |
4060 | } |
4061 | @@ -457,13 +461,13 @@ |
4062 | } |
4063 | |
4064 | std::vector<Inkscape::SnapCandidatePoint> Selection::getSnapPoints(SnapPreferences const *snapprefs) const { |
4065 | - GSList const *items = const_cast<Selection *>(this)->itemList(); |
4066 | + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); |
4067 | |
4068 | SnapPreferences snapprefs_dummy = *snapprefs; // create a local copy of the snapping prefs |
4069 | snapprefs_dummy.setTargetSnappable(Inkscape::SNAPTARGET_ROTATION_CENTER, false); // locally disable snapping to the item center |
4070 | std::vector<Inkscape::SnapCandidatePoint> p; |
4071 | - for (GSList const *iter = items; iter != NULL; iter = iter->next) { |
4072 | - SPItem *this_item = SP_ITEM(iter->data); |
4073 | + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4074 | + SPItem *this_item = *iter; |
4075 | this_item->getSnappoints(p, &snapprefs_dummy); |
4076 | |
4077 | //Include the transformation origin for snapping |
4078 | @@ -477,10 +481,8 @@ |
4079 | } |
4080 | |
4081 | void Selection::_removeObjectDescendants(SPObject *obj) { |
4082 | - GSList *iter, *next; |
4083 | - for ( iter = _objs ; iter ; iter = next ) { |
4084 | - next = iter->next; |
4085 | - SPObject *sel_obj=reinterpret_cast<SPObject *>(iter->data); |
4086 | + for ( std::list<SPObject*>::const_iterator iter=_objs.begin();iter!=_objs.end();iter++ ) { |
4087 | + SPObject *sel_obj= *iter; |
4088 | SPObject *parent = sel_obj->parent; |
4089 | while (parent) { |
4090 | if ( parent == obj ) { |
4091 | @@ -511,32 +513,24 @@ |
4092 | return object; |
4093 | } |
4094 | |
4095 | -guint Selection::numberOfLayers() { |
4096 | - GSList const *items = const_cast<Selection *>(this)->itemList(); |
4097 | - GSList *layers = NULL; |
4098 | - for (GSList const *iter = items; iter != NULL; iter = iter->next) { |
4099 | - SPObject *layer = _layers->layerForObject(SP_OBJECT(iter->data)); |
4100 | - if (g_slist_find (layers, layer) == NULL) { |
4101 | - layers = g_slist_prepend (layers, layer); |
4102 | - } |
4103 | +uint Selection::numberOfLayers() { |
4104 | + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); |
4105 | + std::set<SPObject*> layers; |
4106 | + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4107 | + SPObject *layer = _layers->layerForObject(*iter); |
4108 | + layers.insert(layer); |
4109 | } |
4110 | - guint ret = g_slist_length (layers); |
4111 | - g_slist_free (layers); |
4112 | - return ret; |
4113 | + return layers.size(); |
4114 | } |
4115 | |
4116 | guint Selection::numberOfParents() { |
4117 | - GSList const *items = const_cast<Selection *>(this)->itemList(); |
4118 | - GSList *parents = NULL; |
4119 | - for (GSList const *iter = items; iter != NULL; iter = iter->next) { |
4120 | - SPObject *parent = SP_OBJECT(iter->data)->parent; |
4121 | - if (g_slist_find (parents, parent) == NULL) { |
4122 | - parents = g_slist_prepend (parents, parent); |
4123 | - } |
4124 | + std::vector<SPItem*> const items = const_cast<Selection *>(this)->itemList(); |
4125 | + std::set<SPObject*> parents; |
4126 | + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4127 | + SPObject *parent = (*iter)->parent; |
4128 | + parents.insert(parent); |
4129 | } |
4130 | - guint ret = g_slist_length (parents); |
4131 | - g_slist_free (parents); |
4132 | - return ret; |
4133 | + return parents.size(); |
4134 | } |
4135 | |
4136 | } |
4137 | |
4138 | === modified file 'src/selection.h' |
4139 | --- src/selection.h 2015-02-26 02:49:35 +0000 |
4140 | +++ src/selection.h 2015-04-29 21:03:59 +0000 |
4141 | @@ -16,6 +16,7 @@ |
4142 | #include <vector> |
4143 | #include <map> |
4144 | #include <list> |
4145 | +#include <set> |
4146 | #include <stddef.h> |
4147 | #include <sigc++/sigc++.h> |
4148 | |
4149 | @@ -26,11 +27,11 @@ |
4150 | #include "sp-item.h" |
4151 | |
4152 | |
4153 | + |
4154 | class SPDesktop; |
4155 | class SPItem; |
4156 | class SPBox3D; |
4157 | class Persp3D; |
4158 | -typedef struct _GSList GSList; |
4159 | |
4160 | namespace Inkscape { |
4161 | class LayerModel; |
4162 | @@ -39,6 +40,7 @@ |
4163 | } |
4164 | } |
4165 | |
4166 | + |
4167 | namespace Inkscape { |
4168 | |
4169 | /** |
4170 | @@ -154,21 +156,21 @@ |
4171 | * |
4172 | * @param objs the objects to select |
4173 | */ |
4174 | - void setList(GSList const *objs); |
4175 | + void setList(std::vector<SPItem*> const &objs); |
4176 | |
4177 | /** |
4178 | * Adds the specified objects to selection, without deselecting first. |
4179 | * |
4180 | * @param objs the objects to select |
4181 | */ |
4182 | - void addList(GSList const *objs); |
4183 | + void addList(std::vector<SPItem*> const &objs); |
4184 | |
4185 | /** |
4186 | * Clears the selection and selects the specified objects. |
4187 | * |
4188 | * @param repr a list of xml nodes for the items to select |
4189 | */ |
4190 | - void setReprList(GSList const *reprs); |
4191 | + void setReprList(std::vector<XML::Node*> const &reprs); |
4192 | |
4193 | /** Add items from an STL iterator range to the selection. |
4194 | * \param from the begin iterator |
4195 | @@ -192,7 +194,7 @@ |
4196 | /** |
4197 | * Returns true if no items are selected. |
4198 | */ |
4199 | - bool isEmpty() const { return _objs == NULL; } |
4200 | + bool isEmpty() const { return _objs.empty(); } |
4201 | |
4202 | /** |
4203 | * Returns true if the given object is selected. |
4204 | @@ -238,13 +240,13 @@ |
4205 | XML::Node *singleRepr(); |
4206 | |
4207 | /** Returns the list of selected objects. */ |
4208 | - GSList const *list(); |
4209 | + std::vector<SPObject*> const &list(); |
4210 | /** Returns the list of selected SPItems. */ |
4211 | - GSList const *itemList(); |
4212 | + std::vector<SPItem*> const &itemList(); |
4213 | /** Returns a list of the xml nodes of all selected objects. */ |
4214 | /// \todo only returns reprs of SPItems currently; need a separate |
4215 | /// method for that |
4216 | - GSList const *reprList(); |
4217 | + std::vector<XML::Node*> const &reprList(); |
4218 | |
4219 | /** Returns a list of all perspectives which have a 3D box in the current selection. |
4220 | (these may also be nested in groups) */ |
4221 | @@ -360,9 +362,11 @@ |
4222 | /** Releases an active layer object that is being removed. */ |
4223 | void _releaseContext(SPObject *obj); |
4224 | |
4225 | - mutable GSList *_objs; |
4226 | - mutable GSList *_reprs; |
4227 | - mutable GSList *_items; |
4228 | + mutable std::list<SPObject*> _objs; //to more efficiently remove arbitrary elements |
4229 | + mutable std::vector<SPObject*> _objs_vector; // to be returned by list(); |
4230 | + mutable std::set<SPObject*> _objs_set; //to efficiently test if object is selected |
4231 | + mutable std::vector<XML::Node*> _reprs; |
4232 | + mutable std::vector<SPItem*> _items; |
4233 | |
4234 | void add_box_perspective(SPBox3D *box); |
4235 | void add_3D_boxes_recursively(SPObject *obj); |
4236 | |
4237 | === modified file 'src/seltrans.cpp' |
4238 | --- src/seltrans.cpp 2014-12-21 21:58:32 +0000 |
4239 | +++ src/seltrans.cpp 2015-04-29 21:03:59 +0000 |
4240 | @@ -112,7 +112,7 @@ |
4241 | _opposite_for_bboxpoints(Geom::Point(0,0)), |
4242 | _origin_for_specpoints(Geom::Point(0,0)), |
4243 | _origin_for_bboxpoints(Geom::Point(0,0)), |
4244 | - _stamp_cache(NULL), |
4245 | + _stamp_cache(std::vector<SPItem*>()), |
4246 | _message_context(desktop->messageStack()), |
4247 | _bounding_box_prefs_observer(*this) |
4248 | { |
4249 | @@ -239,8 +239,9 @@ |
4250 | _center_is_set = true; |
4251 | |
4252 | // Write the new center position into all selected items |
4253 | - for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) { |
4254 | - SPItem *it = SP_ITEM(l->data); |
4255 | + std::vector<SPItem*> items=_desktop->selection->itemList(); |
4256 | + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4257 | + SPItem *it = SP_ITEM(*iter); |
4258 | it->setCenter(p); |
4259 | // only set the value; updating repr and document_done will be done once, on ungrab |
4260 | } |
4261 | @@ -268,8 +269,9 @@ |
4262 | return; |
4263 | } |
4264 | |
4265 | - for (GSList const *l = selection->itemList(); l; l = l->next) { |
4266 | - SPItem *it = reinterpret_cast<SPItem*>(sp_object_ref(SP_ITEM(l->data), NULL)); |
4267 | + std::vector<SPItem*> items=_desktop->selection->itemList(); |
4268 | + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4269 | + SPItem *it = static_cast<SPItem*>(sp_object_ref(*iter, NULL)); |
4270 | _items.push_back(it); |
4271 | _items_const.push_back(it); |
4272 | _items_affines.push_back(it->i2dt_affine()); |
4273 | @@ -370,7 +372,7 @@ |
4274 | } |
4275 | |
4276 | _updateHandles(); |
4277 | - g_return_if_fail(_stamp_cache == NULL); |
4278 | + g_return_if_fail(_stamp_cache.empty()); |
4279 | } |
4280 | |
4281 | void Inkscape::SelTrans::transform(Geom::Affine const &rel_affine, Geom::Point const &norm) |
4282 | @@ -432,10 +434,8 @@ |
4283 | for (int i = 0; i < 4; i++) |
4284 | sp_canvas_item_hide(_l[i]); |
4285 | } |
4286 | - |
4287 | - if (_stamp_cache) { |
4288 | - g_slist_free(_stamp_cache); |
4289 | - _stamp_cache = NULL; |
4290 | + if(!_stamp_cache.empty()){ |
4291 | + _stamp_cache.clear(); |
4292 | } |
4293 | |
4294 | _message_context.clear(); |
4295 | @@ -491,8 +491,9 @@ |
4296 | |
4297 | if (_center_is_set) { |
4298 | // we were dragging center; update reprs and commit undoable action |
4299 | - for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) { |
4300 | - SPItem *it = SP_ITEM(l->data); |
4301 | + std::vector<SPItem*> items=_desktop->selection->itemList(); |
4302 | + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4303 | + SPItem *it = *iter; |
4304 | it->updateRepr(); |
4305 | } |
4306 | DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_SELECT, |
4307 | @@ -515,26 +516,25 @@ |
4308 | Inkscape::Selection *selection = _desktop->getSelection(); |
4309 | |
4310 | bool fixup = !_grabbed; |
4311 | - if ( fixup && _stamp_cache ) { |
4312 | + if ( fixup && !_stamp_cache.empty() ) { |
4313 | // TODO - give a proper fix. Simple temporary work-around for the grab() issue |
4314 | - g_slist_free(_stamp_cache); |
4315 | - _stamp_cache = NULL; |
4316 | + _stamp_cache.clear(); |
4317 | } |
4318 | |
4319 | /* stamping mode */ |
4320 | if (!_empty) { |
4321 | - GSList *l; |
4322 | - if (_stamp_cache) { |
4323 | + std::vector<SPItem*> l; |
4324 | + if (!_stamp_cache.empty()) { |
4325 | l = _stamp_cache; |
4326 | } else { |
4327 | /* Build cache */ |
4328 | - l = g_slist_copy((GSList *) selection->itemList()); |
4329 | - l = g_slist_sort(l, (GCompareFunc) sp_object_compare_position); |
4330 | + l = selection->itemList(); |
4331 | + sort(l.begin(),l.end(),sp_object_compare_position); |
4332 | _stamp_cache = l; |
4333 | } |
4334 | |
4335 | - while (l) { |
4336 | - SPItem *original_item = SP_ITEM(l->data); |
4337 | + for(std::vector<SPItem*>::const_iterator x=l.begin();x!=l.end();x++) { |
4338 | + SPItem *original_item = *x; |
4339 | Inkscape::XML::Node *original_repr = original_item->getRepr(); |
4340 | |
4341 | // remember the position of the item |
4342 | @@ -568,16 +568,14 @@ |
4343 | } |
4344 | |
4345 | Inkscape::GC::release(copy_repr); |
4346 | - l = l->next; |
4347 | } |
4348 | DocumentUndo::done(_desktop->getDocument(), SP_VERB_CONTEXT_SELECT, |
4349 | _("Stamp")); |
4350 | } |
4351 | |
4352 | - if ( fixup && _stamp_cache ) { |
4353 | + if ( fixup && !_stamp_cache.empty() ) { |
4354 | // TODO - give a proper fix. Simple temporary work-around for the grab() issue |
4355 | - g_slist_free(_stamp_cache); |
4356 | - _stamp_cache = NULL; |
4357 | + _stamp_cache.clear(); |
4358 | } |
4359 | } |
4360 | |
4361 | @@ -712,8 +710,9 @@ |
4362 | case HANDLE_CENTER: |
4363 | if (state & GDK_SHIFT_MASK) { |
4364 | // Unset the center position for all selected items |
4365 | - for (GSList const *l = _desktop->selection->itemList(); l; l = l->next) { |
4366 | - SPItem *it = SP_ITEM(l->data); |
4367 | + std::vector<SPItem*> items=_desktop->selection->itemList(); |
4368 | + for ( std::vector<SPItem*>::const_iterator iter=items.begin();iter!=items.end();iter++ ) { |
4369 | + SPItem *it = *iter; |
4370 | it->unsetCenter(); |
4371 | it->updateRepr(); |
4372 | _center_is_set = false; // center has changed |
4373 | @@ -1283,7 +1282,7 @@ |
4374 | // items will share a single center. While dragging that single center, it should never snap to the |
4375 | // centers of any of the selected objects. Therefore we will have to pass the list of selected items |
4376 | // to the snapper, to avoid self-snapping of the rotation center |
4377 | - GSList *items = (GSList *) const_cast<Selection *>(_selection)->itemList(); |
4378 | + std::vector<SPItem*> items = const_cast<Selection *>(_selection)->itemList(); |
4379 | SnapManager &m = _desktop->namedview->snap_manager; |
4380 | m.setup(_desktop); |
4381 | m.setRotationCenterSource(items); |
4382 | |
4383 | === modified file 'src/seltrans.h' |
4384 | --- src/seltrans.h 2014-10-08 02:22:03 +0000 |
4385 | +++ src/seltrans.h 2015-04-29 21:03:59 +0000 |
4386 | @@ -187,7 +187,7 @@ |
4387 | SPCtrlLine *_l[4]; |
4388 | unsigned int _sel_changed_id; |
4389 | unsigned int _sel_modified_id; |
4390 | - GSList *_stamp_cache; |
4391 | + std::vector<SPItem*> _stamp_cache; |
4392 | |
4393 | Geom::Point _origin; ///< position of origin for transforms |
4394 | Geom::Point _point; ///< original position of the knot being used for the current transform |
4395 | |
4396 | === modified file 'src/snap.cpp' |
4397 | --- src/snap.cpp 2015-02-25 23:08:51 +0000 |
4398 | +++ src/snap.cpp 2015-04-29 21:03:59 +0000 |
4399 | @@ -43,7 +43,7 @@ |
4400 | object(this, 0), |
4401 | snapprefs(), |
4402 | _named_view(v), |
4403 | - _rotation_center_source_items(NULL), |
4404 | + _rotation_center_source_items(std::vector<SPItem*>()), |
4405 | _guide_to_ignore(NULL), |
4406 | _desktop(NULL), |
4407 | _snapindicator(true), |
4408 | @@ -1013,7 +1013,7 @@ |
4409 | _snapindicator = snapindicator; |
4410 | _unselected_nodes = unselected_nodes; |
4411 | _guide_to_ignore = guide_to_ignore; |
4412 | - _rotation_center_source_items = NULL; |
4413 | + _rotation_center_source_items.clear(); |
4414 | } |
4415 | |
4416 | void SnapManager::setup(SPDesktop const *desktop, |
4417 | @@ -1031,7 +1031,7 @@ |
4418 | _snapindicator = snapindicator; |
4419 | _unselected_nodes = unselected_nodes; |
4420 | _guide_to_ignore = guide_to_ignore; |
4421 | - _rotation_center_source_items = NULL; |
4422 | + _rotation_center_source_items.clear(); |
4423 | } |
4424 | |
4425 | /// Setup, taking the list of items to ignore from the desktop's selection. |
4426 | @@ -1049,13 +1049,13 @@ |
4427 | _snapindicator = snapindicator; |
4428 | _unselected_nodes = unselected_nodes; |
4429 | _guide_to_ignore = guide_to_ignore; |
4430 | - _rotation_center_source_items = NULL; |
4431 | + _rotation_center_source_items.clear(); |
4432 | _items_to_ignore.clear(); |
4433 | |
4434 | Inkscape::Selection *sel = _desktop->selection; |
4435 | - GSList const *items = sel->itemList(); |
4436 | - for (GSList *i = const_cast<GSList*>(items); i; i = i->next) { |
4437 | - _items_to_ignore.push_back(static_cast<SPItem const *>(i->data)); |
4438 | + std::vector<SPItem*> const items = sel->itemList(); |
4439 | + for (std::vector<SPItem*>::const_iterator i=items.begin();i!=items.end();i++) { |
4440 | + _items_to_ignore.push_back(*i); |
4441 | } |
4442 | } |
4443 | |
4444 | |
4445 | === modified file 'src/snap.h' |
4446 | --- src/snap.h 2014-10-08 02:22:03 +0000 |
4447 | +++ src/snap.h 2015-04-29 21:03:59 +0000 |
4448 | @@ -136,7 +136,7 @@ |
4449 | std::vector<Inkscape::SnapCandidatePoint> *unselected_nodes = NULL, |
4450 | SPGuide *guide_to_ignore = NULL); |
4451 | |
4452 | - void unSetup() {_rotation_center_source_items = NULL; |
4453 | + void unSetup() {_rotation_center_source_items.clear(); |
4454 | _guide_to_ignore = NULL; |
4455 | _desktop = NULL; |
4456 | _unselected_nodes = NULL;} |
4457 | @@ -145,8 +145,8 @@ |
4458 | // of this rotation center; this reference is used to make sure that we do not snap a rotation |
4459 | // center to itself |
4460 | // NOTE: Must be called after calling setup(), not before! |
4461 | - void setRotationCenterSource(GSList *items) {_rotation_center_source_items = items;} |
4462 | - GSList const *getRotationCenterSource() {return _rotation_center_source_items;} |
4463 | + void setRotationCenterSource(const std::vector<SPItem*> &items) {_rotation_center_source_items = items;} |
4464 | + const std::vector<SPItem*> &getRotationCenterSource() {return _rotation_center_source_items;} |
4465 | |
4466 | // freeSnapReturnByRef() is preferred over freeSnap(), because it only returns a |
4467 | // point if snapping has occurred (by overwriting p); otherwise p is untouched |
4468 | @@ -490,7 +490,7 @@ |
4469 | |
4470 | private: |
4471 | std::vector<SPItem const *> _items_to_ignore; ///< Items that should not be snapped to, for example the items that are currently being dragged. Set using the setup() method |
4472 | - GSList *_rotation_center_source_items; // to avoid snapping a rotation center to itself |
4473 | + std::vector<SPItem*> _rotation_center_source_items; // to avoid snapping a rotation center to itself |
4474 | SPGuide *_guide_to_ignore; ///< A guide that should not be snapped to, e.g. the guide that is currently being dragged |
4475 | SPDesktop const *_desktop; |
4476 | bool _snapindicator; ///< When true, an indicator will be drawn at the position that was being snapped to |
4477 | |
4478 | === modified file 'src/sp-conn-end.cpp' |
4479 | --- src/sp-conn-end.cpp 2014-03-30 22:01:25 +0000 |
4480 | +++ src/sp-conn-end.cpp 2015-04-29 21:03:59 +0000 |
4481 | @@ -50,8 +50,9 @@ |
4482 | |
4483 | // consider all first-order children |
4484 | double child_pos = 0.0; |
4485 | - for (GSList const* i = sp_item_group_item_list(group); i != NULL; i = i->next) { |
4486 | - SPItem* child_item = SP_ITEM(i->data); |
4487 | + std::vector<SPItem*> g = sp_item_group_item_list(group); |
4488 | + for (std::vector<SPItem*>::const_iterator i = g.begin();i!=g.end();i++) { |
4489 | + SPItem* child_item = *i; |
4490 | try_get_intersect_point_with_item_recursive(conn_pv, child_item, |
4491 | item_transform * child_item->transform, child_pos); |
4492 | if (intersect_pos < child_pos) |
4493 | |
4494 | === modified file 'src/sp-defs.cpp' |
4495 | --- src/sp-defs.cpp 2015-02-25 00:22:08 +0000 |
4496 | +++ src/sp-defs.cpp 2015-04-29 21:03:59 +0000 |
4497 | @@ -36,11 +36,9 @@ |
4498 | } |
4499 | |
4500 | flags &= SP_OBJECT_MODIFIED_CASCADE; |
4501 | - |
4502 | - GSList *l = g_slist_reverse(this->childList(true)); |
4503 | - while (l) { |
4504 | - SPObject *child = SP_OBJECT(l->data); |
4505 | - l = g_slist_remove(l, child); |
4506 | + std::vector<SPObject*> l(this->childList(true)); |
4507 | + for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ |
4508 | + SPObject *child = *i; |
4509 | if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { |
4510 | child->updateDisplay(ctx, flags); |
4511 | } |
4512 | |
4513 | === modified file 'src/sp-filter.cpp' |
4514 | --- src/sp-filter.cpp 2015-02-25 00:22:08 +0000 |
4515 | +++ src/sp-filter.cpp 2015-04-29 21:03:59 +0000 |
4516 | @@ -235,11 +235,9 @@ |
4517 | childflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; |
4518 | } |
4519 | childflags &= SP_OBJECT_MODIFIED_CASCADE; |
4520 | - |
4521 | - GSList *l = g_slist_reverse(this->childList(true, SPObject::ActionUpdate)); |
4522 | - while (l) { |
4523 | - SPObject *child = SP_OBJECT (l->data); |
4524 | - l = g_slist_remove (l, child); |
4525 | + std::vector<SPObject*> l(this->childList(true, SPObject::ActionUpdate)); |
4526 | + for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ |
4527 | + SPObject *child = *i; |
4528 | if( SP_IS_FILTER_PRIMITIVE( child ) ) { |
4529 | child->updateDisplay(ctx, childflags); |
4530 | } |
4531 | |
4532 | === modified file 'src/sp-item-group.cpp' |
4533 | --- src/sp-item-group.cpp 2015-03-12 08:19:08 +0000 |
4534 | +++ src/sp-item-group.cpp 2015-04-29 21:03:59 +0000 |
4535 | @@ -161,11 +161,9 @@ |
4536 | childflags |= SP_OBJECT_PARENT_MODIFIED_FLAG; |
4537 | } |
4538 | childflags &= SP_OBJECT_MODIFIED_CASCADE; |
4539 | - |
4540 | - GSList *l = g_slist_reverse(this->childList(true, SPObject::ActionUpdate)); |
4541 | - while (l) { |
4542 | - SPObject *child = SP_OBJECT (l->data); |
4543 | - l = g_slist_remove (l, child); |
4544 | + std::vector<SPObject*> l=this->childList(true, SPObject::ActionUpdate); |
4545 | + for(std::vector<SPObject*> ::const_iterator i=l.begin();i!=l.end();i++){ |
4546 | + SPObject *child = *i; |
4547 | |
4548 | if (childflags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { |
4549 | SPItem *item = dynamic_cast<SPItem *>(child); |
4550 | @@ -201,20 +199,15 @@ |
4551 | void SPGroup::modified(guint flags) { |
4552 | // std::cout << "SPGroup::modified(): " << (getId()?getId():"null") << std::endl; |
4553 | SPLPEItem::modified(flags); |
4554 | - |
4555 | - SPObject *child; |
4556 | - |
4557 | if (flags & SP_OBJECT_MODIFIED_FLAG) { |
4558 | flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; |
4559 | } |
4560 | |
4561 | flags &= SP_OBJECT_MODIFIED_CASCADE; |
4562 | |
4563 | - GSList *l = g_slist_reverse(this->childList(true)); |
4564 | - |
4565 | - while (l) { |
4566 | - child = SP_OBJECT (l->data); |
4567 | - l = g_slist_remove (l, child); |
4568 | + std::vector<SPObject*> l=this->childList(true); |
4569 | + for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ |
4570 | + SPObject *child = *i; |
4571 | |
4572 | if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { |
4573 | child->emitModified(flags); |
4574 | @@ -286,35 +279,27 @@ |
4575 | Geom::OptRect bbox; |
4576 | |
4577 | // TODO CPPIFY: replace this const_cast later |
4578 | - GSList *l = const_cast<SPGroup*>(this)->childList(false, SPObject::ActionBBox); |
4579 | - |
4580 | - while (l) { |
4581 | - SPObject *o = SP_OBJECT (l->data); |
4582 | - |
4583 | + std::vector<SPObject*> l = const_cast<SPGroup*>(this)->childList(false, SPObject::ActionBBox); |
4584 | + for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ |
4585 | + SPObject *o = *i; |
4586 | SPItem *item = dynamic_cast<SPItem *>(o); |
4587 | if (item && !item->isHidden()) { |
4588 | Geom::Affine const ct(item->transform * transform); |
4589 | bbox |= item->bounds(bboxtype, ct); |
4590 | } |
4591 | - |
4592 | - l = g_slist_remove (l, o); |
4593 | } |
4594 | |
4595 | return bbox; |
4596 | } |
4597 | |
4598 | void SPGroup::print(SPPrintContext *ctx) { |
4599 | - GSList *l = g_slist_reverse(this->childList(false)); |
4600 | - |
4601 | - while (l) { |
4602 | - SPObject *o = SP_OBJECT (l->data); |
4603 | - |
4604 | + std::vector<SPObject*> l=this->childList(false); |
4605 | + for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ |
4606 | + SPObject *o = *i; |
4607 | SPItem *item = dynamic_cast<SPItem *>(o); |
4608 | if (item) { |
4609 | item->invoke_print(ctx); |
4610 | } |
4611 | - |
4612 | - l = g_slist_remove (l, o); |
4613 | } |
4614 | } |
4615 | |
4616 | @@ -362,17 +347,14 @@ |
4617 | } |
4618 | |
4619 | void SPGroup::hide (unsigned int key) { |
4620 | - GSList *l = g_slist_reverse(this->childList(false, SPObject::ActionShow)); |
4621 | - |
4622 | - while (l) { |
4623 | - SPObject *o = SP_OBJECT (l->data); |
4624 | + std::vector<SPObject*> l=this->childList(false, SPObject::ActionShow); |
4625 | + for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ |
4626 | + SPObject *o = *i; |
4627 | |
4628 | SPItem *item = dynamic_cast<SPItem *>(o); |
4629 | if (item) { |
4630 | item->invoke_hide(key); |
4631 | } |
4632 | - |
4633 | - l = g_slist_remove (l, o); |
4634 | } |
4635 | |
4636 | // SPLPEItem::onHide(key); |
4637 | @@ -407,7 +389,7 @@ |
4638 | } |
4639 | |
4640 | void |
4641 | -sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) |
4642 | +sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children, bool do_done) |
4643 | { |
4644 | g_return_if_fail (group != NULL); |
4645 | |
4646 | @@ -564,8 +546,8 @@ |
4647 | } |
4648 | |
4649 | Inkscape::GC::release(repr); |
4650 | - if (children && item) { |
4651 | - *children = g_slist_prepend(*children, item); |
4652 | + if (!children.empty() && item) { |
4653 | + children.insert(children.begin(),item); |
4654 | } |
4655 | |
4656 | items = g_slist_remove (items, items->data); |
4657 | @@ -580,19 +562,17 @@ |
4658 | * some API for list aspect of SPGroup |
4659 | */ |
4660 | |
4661 | -GSList *sp_item_group_item_list(SPGroup * group) |
4662 | +std::vector<SPItem*> sp_item_group_item_list(SPGroup * group) |
4663 | { |
4664 | - g_return_val_if_fail(group != NULL, NULL); |
4665 | - |
4666 | - GSList *s = NULL; |
4667 | + std::vector<SPItem*> s; |
4668 | + g_return_val_if_fail(group != NULL, s); |
4669 | |
4670 | for (SPObject *o = group->firstChild() ; o ; o = o->getNext() ) { |
4671 | if ( dynamic_cast<SPItem *>(o) ) { |
4672 | - s = g_slist_prepend(s, o); |
4673 | + s.push_back((SPItem*)o); |
4674 | } |
4675 | } |
4676 | - |
4677 | - return g_slist_reverse (s); |
4678 | + return s; |
4679 | } |
4680 | |
4681 | SPObject *sp_item_group_get_child_by_name(SPGroup *group, SPObject *ref, const gchar *name) |
4682 | @@ -807,9 +787,9 @@ |
4683 | |
4684 | void SPGroup::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { |
4685 | Inkscape::DrawingItem *ac = NULL; |
4686 | - GSList *l = g_slist_reverse(this->childList(false, SPObject::ActionShow)); |
4687 | - while (l) { |
4688 | - SPObject *o = SP_OBJECT (l->data); |
4689 | + std::vector<SPObject*> l=this->childList(false, SPObject::ActionShow); |
4690 | + for(std::vector<SPObject*>::const_iterator i=l.begin();i!=l.end();i++){ |
4691 | + SPObject *o = *i; |
4692 | SPItem * child = dynamic_cast<SPItem *>(o); |
4693 | if (child) { |
4694 | ac = child->invoke_show (drawing, key, flags); |
4695 | @@ -817,7 +797,6 @@ |
4696 | ai->appendChild(ac); |
4697 | } |
4698 | } |
4699 | - l = g_slist_remove (l, o); |
4700 | } |
4701 | } |
4702 | |
4703 | @@ -826,10 +805,10 @@ |
4704 | g_message("sp_group_update_patheffect: %p\n", lpeitem); |
4705 | #endif |
4706 | |
4707 | - GSList const *item_list = sp_item_group_item_list(this); |
4708 | + std::vector<SPItem*> const item_list = sp_item_group_item_list(this); |
4709 | |
4710 | - for ( GSList const *iter = item_list; iter; iter = iter->next ) { |
4711 | - SPObject *subitem = static_cast<SPObject *>(iter->data); |
4712 | + for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { |
4713 | + SPObject *subitem = *iter; |
4714 | |
4715 | SPLPEItem *lpeItem = dynamic_cast<SPLPEItem *>(subitem); |
4716 | if (lpeItem) { |
4717 | @@ -854,10 +833,10 @@ |
4718 | static void |
4719 | sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) |
4720 | { |
4721 | - GSList const *item_list = sp_item_group_item_list(group); |
4722 | + std::vector<SPItem*> const item_list = sp_item_group_item_list(group); |
4723 | |
4724 | - for ( GSList const *iter = item_list; iter; iter = iter->next ) { |
4725 | - SPObject *subitem = static_cast<SPObject *>(iter->data); |
4726 | + for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { |
4727 | + SPObject *subitem = *iter; |
4728 | |
4729 | SPGroup *subGroup = dynamic_cast<SPGroup *>(subitem); |
4730 | if (subGroup) { |
4731 | |
4732 | === modified file 'src/sp-item-group.h' |
4733 | --- src/sp-item-group.h 2015-02-21 16:23:30 +0000 |
4734 | +++ src/sp-item-group.h 2015-04-29 21:03:59 +0000 |
4735 | @@ -95,6 +95,7 @@ |
4736 | virtual void update_patheffect(bool write); |
4737 | }; |
4738 | |
4739 | + |
4740 | /** |
4741 | * finds clones of a child of the group going out of the group; and inverse the group transform on its clones |
4742 | * Also called when moving objects between different layers |
4743 | @@ -104,10 +105,11 @@ |
4744 | */ |
4745 | void sp_item_group_ungroup_handle_clones(SPItem *parent, Geom::Affine const g); |
4746 | |
4747 | -void sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done = true); |
4748 | - |
4749 | - |
4750 | -GSList *sp_item_group_item_list (SPGroup *group); |
4751 | +void sp_item_group_ungroup (SPGroup *group, std::vector<SPItem*> &children, bool do_done = true); |
4752 | + |
4753 | + |
4754 | +std::vector<SPItem*> sp_item_group_item_list (SPGroup *group); |
4755 | + |
4756 | SPObject *sp_item_group_get_child_by_name (SPGroup *group, SPObject *ref, const char *name); |
4757 | |
4758 | #endif |
4759 | |
4760 | === modified file 'src/sp-lpe-item.cpp' |
4761 | --- src/sp-lpe-item.cpp 2015-03-12 08:19:08 +0000 |
4762 | +++ src/sp-lpe-item.cpp 2015-04-29 21:03:59 +0000 |
4763 | @@ -353,9 +353,9 @@ |
4764 | sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); |
4765 | } |
4766 | if (SP_IS_GROUP(lpeitem)) { |
4767 | - GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); |
4768 | - for ( GSList const *iter = item_list; iter; iter = iter->next ) { |
4769 | - SPObject *subitem = static_cast<SPObject *>(iter->data); |
4770 | + std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); |
4771 | + for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { |
4772 | + SPObject *subitem = *iter; |
4773 | if (SP_IS_LPE_ITEM(subitem)) { |
4774 | sp_lpe_item_create_original_path_recursive(SP_LPE_ITEM(subitem)); |
4775 | } |
4776 | @@ -387,9 +387,9 @@ |
4777 | sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(clipPath->firstChild())); |
4778 | } |
4779 | } |
4780 | - GSList const *item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); |
4781 | - for ( GSList const *iter = item_list; iter; iter = iter->next ) { |
4782 | - SPObject *subitem = static_cast<SPObject *>(iter->data); |
4783 | + std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(lpeitem)); |
4784 | + for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { |
4785 | + SPObject *subitem = *iter; |
4786 | if (SP_IS_LPE_ITEM(subitem)) { |
4787 | sp_lpe_item_cleanup_original_path_recursive(SP_LPE_ITEM(subitem)); |
4788 | } |
4789 | @@ -680,9 +680,9 @@ |
4790 | } |
4791 | } |
4792 | if(SP_IS_GROUP(item)){ |
4793 | - GSList const *item_list = sp_item_group_item_list(SP_GROUP(item)); |
4794 | - for ( GSList const *iter = item_list; iter; iter = iter->next ) { |
4795 | - SPObject *subitem = static_cast<SPObject *>(iter->data); |
4796 | + std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(item)); |
4797 | + for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { |
4798 | + SPObject *subitem = *iter; |
4799 | apply_to_clippath(SP_ITEM(subitem)); |
4800 | } |
4801 | } |
4802 | @@ -732,9 +732,9 @@ |
4803 | } |
4804 | } |
4805 | if(SP_IS_GROUP(item)){ |
4806 | - GSList const *item_list = sp_item_group_item_list(SP_GROUP(item)); |
4807 | - for ( GSList const *iter = item_list; iter; iter = iter->next ) { |
4808 | - SPObject *subitem = static_cast<SPObject *>(iter->data); |
4809 | + std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(item)); |
4810 | + for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { |
4811 | + SPObject *subitem = *iter; |
4812 | apply_to_mask(SP_ITEM(subitem)); |
4813 | } |
4814 | } |
4815 | @@ -746,9 +746,9 @@ |
4816 | if (!SP_IS_GROUP(group)) { |
4817 | return; |
4818 | } |
4819 | - GSList *item_list = sp_item_group_item_list(SP_GROUP(group)); |
4820 | - for ( GSList *iter = item_list; iter; iter = iter->next ) { |
4821 | - SPObject *subitem = static_cast<SPObject *>(iter->data); |
4822 | + std::vector<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(group)); |
4823 | + for ( std::vector<SPItem*>::const_iterator iter=item_list.begin();iter!=item_list.end();iter++) { |
4824 | + SPObject *subitem = *iter; |
4825 | if (SP_IS_GROUP(subitem)) { |
4826 | apply_to_clip_or_mask_group(SP_ITEM(subitem), item); |
4827 | } else if (SP_IS_SHAPE(subitem)) { |
4828 | |
4829 | === modified file 'src/sp-marker.cpp' |
4830 | --- src/sp-marker.cpp 2015-02-25 00:22:08 +0000 |
4831 | +++ src/sp-marker.cpp 2015-04-29 21:03:59 +0000 |
4832 | @@ -419,7 +419,7 @@ |
4833 | } |
4834 | |
4835 | |
4836 | -const gchar *generate_marker(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move) |
4837 | +const gchar *generate_marker(std::vector<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move) |
4838 | { |
4839 | Inkscape::XML::Document *xml_doc = document->getReprDoc(); |
4840 | Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); |
4841 | @@ -442,8 +442,8 @@ |
4842 | const gchar *mark_id = repr->attribute("id"); |
4843 | SPObject *mark_object = document->getObjectById(mark_id); |
4844 | |
4845 | - for (GSList *i = reprs; i != NULL; i = i->next) { |
4846 | - Inkscape::XML::Node *node = (Inkscape::XML::Node *)(i->data); |
4847 | + for (std::vector<Inkscape::XML::Node*>::const_iterator i=reprs.begin();i!=reprs.end();i++){ |
4848 | + Inkscape::XML::Node *node = *i; |
4849 | SPItem *copy = SP_ITEM(mark_object->appendChildRepr(node)); |
4850 | |
4851 | Geom::Affine dup_transform; |
4852 | |
4853 | === modified file 'src/sp-marker.h' |
4854 | --- src/sp-marker.h 2014-12-21 14:29:02 +0000 |
4855 | +++ src/sp-marker.h 2015-04-29 21:03:59 +0000 |
4856 | @@ -101,7 +101,7 @@ |
4857 | unsigned int key, unsigned int pos, |
4858 | Geom::Affine const &base, float linewidth); |
4859 | void sp_marker_hide (SPMarker *marker, unsigned int key); |
4860 | -const char *generate_marker (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move); |
4861 | +const char *generate_marker (std::vector<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Point center, Geom::Affine move); |
4862 | SPObject *sp_marker_fork_if_necessary(SPObject *marker); |
4863 | |
4864 | #endif |
4865 | |
4866 | === modified file 'src/sp-object.cpp' |
4867 | --- src/sp-object.cpp 2015-02-25 00:22:08 +0000 |
4868 | +++ src/sp-object.cpp 2015-04-29 21:03:59 +0000 |
4869 | @@ -380,14 +380,14 @@ |
4870 | sp_repr_css_change(this->getRepr(), css, attr); |
4871 | } |
4872 | |
4873 | -GSList *SPObject::childList(bool add_ref, Action) { |
4874 | - GSList *l = NULL; |
4875 | +std::vector<SPObject*> SPObject::childList(bool add_ref, Action) { |
4876 | + std::vector<SPObject*> l; |
4877 | for ( SPObject *child = firstChild() ; child; child = child->getNext() ) { |
4878 | if (add_ref) { |
4879 | sp_object_ref (child); |
4880 | } |
4881 | |
4882 | - l = g_slist_prepend (l, child); |
4883 | + l.push_back(child); |
4884 | } |
4885 | return l; |
4886 | |
4887 | |
4888 | === modified file 'src/sp-object.h' |
4889 | --- src/sp-object.h 2015-02-21 16:23:30 +0000 |
4890 | +++ src/sp-object.h 2015-04-29 21:03:59 +0000 |
4891 | @@ -52,6 +52,7 @@ |
4892 | #include <sigc++/connection.h> |
4893 | #include <sigc++/functors/slot.h> |
4894 | #include <sigc++/signal.h> |
4895 | +#include <vector> |
4896 | |
4897 | #include "version.h" |
4898 | #include "util/forward-pointer-iterator.h" |
4899 | @@ -328,10 +329,10 @@ |
4900 | enum Action { ActionGeneral, ActionBBox, ActionUpdate, ActionShow }; |
4901 | |
4902 | /** |
4903 | - * Retrieves the children as a GSList object, optionally ref'ing the children |
4904 | + * Retrieves the children as a std vector object, optionally ref'ing the children |
4905 | * in the process, if add_ref is specified. |
4906 | */ |
4907 | - GSList *childList(bool add_ref, Action action = ActionGeneral); |
4908 | + std::vector<SPObject*> childList(bool add_ref, Action action = ActionGeneral); |
4909 | |
4910 | /** |
4911 | * Append repr as child of this object. |
4912 | |
4913 | === modified file 'src/sp-pattern.cpp' |
4914 | --- src/sp-pattern.cpp 2015-02-25 00:22:08 +0000 |
4915 | +++ src/sp-pattern.cpp 2015-04-29 21:03:59 +0000 |
4916 | @@ -398,7 +398,7 @@ |
4917 | g_free(c); |
4918 | } |
4919 | |
4920 | -const gchar *pattern_tile(GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move) |
4921 | +const gchar *pattern_tile(const std::vector<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move) |
4922 | { |
4923 | Inkscape::XML::Document *xml_doc = document->getReprDoc(); |
4924 | Inkscape::XML::Node *defsrepr = document->getDefs()->getRepr(); |
4925 | @@ -416,8 +416,8 @@ |
4926 | const gchar *pat_id = repr->attribute("id"); |
4927 | SPObject *pat_object = document->getObjectById(pat_id); |
4928 | |
4929 | - for (GSList *i = reprs; i != NULL; i = i->next) { |
4930 | - Inkscape::XML::Node *node = (Inkscape::XML::Node *)(i->data); |
4931 | + for (std::vector<Inkscape::XML::Node*>::const_iterator i=reprs.begin();i!=reprs.end();i++){ |
4932 | + Inkscape::XML::Node *node = *i; |
4933 | SPItem *copy = SP_ITEM(pat_object->appendChildRepr(node)); |
4934 | |
4935 | Geom::Affine dup_transform; |
4936 | |
4937 | === modified file 'src/sp-pattern.h' |
4938 | --- src/sp-pattern.h 2014-10-08 02:22:03 +0000 |
4939 | +++ src/sp-pattern.h 2015-04-29 21:03:59 +0000 |
4940 | @@ -89,7 +89,7 @@ |
4941 | SPPattern *sp_pattern_clone_if_necessary (SPItem *item, SPPattern *pattern, const char *property); |
4942 | void sp_pattern_transform_multiply (SPPattern *pattern, Geom::Affine postmul, bool set); |
4943 | |
4944 | -const char *pattern_tile (GSList *reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); |
4945 | +const char *pattern_tile (const std::vector<Inkscape::XML::Node*> &reprs, Geom::Rect bounds, SPDocument *document, Geom::Affine transform, Geom::Affine move); |
4946 | |
4947 | SPPattern *pattern_getroot (SPPattern *pat); |
4948 | |
4949 | |
4950 | === modified file 'src/sp-switch.cpp' |
4951 | --- src/sp-switch.cpp 2015-02-25 00:22:08 +0000 |
4952 | +++ src/sp-switch.cpp 2015-04-29 21:03:59 +0000 |
4953 | @@ -41,21 +41,22 @@ |
4954 | return first; |
4955 | } |
4956 | |
4957 | -GSList *SPSwitch::_childList(bool add_ref, SPObject::Action action) { |
4958 | +std::vector<SPObject*> SPSwitch::_childList(bool add_ref, SPObject::Action action) { |
4959 | if ( action != SPObject::ActionGeneral ) { |
4960 | return this->childList(add_ref, action); |
4961 | } |
4962 | |
4963 | SPObject *child = _evaluateFirst(); |
4964 | + std::vector<SPObject*> x; |
4965 | if (NULL == child) |
4966 | - return NULL; |
4967 | + return x; |
4968 | |
4969 | if (add_ref) { |
4970 | //g_object_ref (G_OBJECT (child)); |
4971 | sp_object_ref(child); |
4972 | } |
4973 | - |
4974 | - return g_slist_prepend (NULL, child); |
4975 | + x.push_back(child); |
4976 | + return x; |
4977 | } |
4978 | |
4979 | const char *SPSwitch::displayName() const { |
4980 | @@ -95,10 +96,9 @@ |
4981 | |
4982 | _releaseLastItem(_cached_item); |
4983 | |
4984 | - for ( GSList *l = _childList(false, SPObject::ActionShow); |
4985 | - NULL != l ; l = g_slist_remove (l, l->data)) |
4986 | - { |
4987 | - SPObject *o = SP_OBJECT (l->data); |
4988 | + std::vector<SPObject*> item_list = _childList(false, SPObject::ActionShow); |
4989 | + for ( std::vector<SPObject*>::const_reverse_iterator iter=item_list.rbegin();iter!=item_list.rend();iter++) { |
4990 | + SPObject *o = *iter; |
4991 | if ( !SP_IS_ITEM (o) ) { |
4992 | continue; |
4993 | } |
4994 | @@ -130,10 +130,10 @@ |
4995 | void SPSwitch::_showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags) { |
4996 | SPObject *evaluated_child = this->_evaluateFirst(); |
4997 | |
4998 | - GSList *l = this->_childList(false, SPObject::ActionShow); |
4999 | + std::vector<SPObject*> l = this->_childList(false, SPObject::ActionShow); |
5000 |
I added some fancy new diff comments that should help show where things need fixing.