Merge lp:~inkscape.dev/inkscape/glib_hunt into lp:~inkscape.dev/inkscape/trunk
- glib_hunt
- Merge into trunk
Proposed by
Mc
Status: | Merged |
---|---|
Merged at revision: | 14520 |
Proposed branch: | lp:~inkscape.dev/inkscape/glib_hunt |
Merge into: | lp:~inkscape.dev/inkscape/trunk |
Diff against target: |
4073 lines (+703/-886) 60 files modified
src/attributes.cpp (+6/-14) src/color-profile.cpp (+5/-6) src/conn-avoid-ref.cpp (+12/-14) src/conn-avoid-ref.h (+3/-4) src/desktop-style.h (+0/-1) src/desktop.cpp (+1/-7) src/document-private.h (+7/-8) src/document-undo.cpp (+31/-39) src/document.cpp (+42/-57) src/document.h (+3/-2) src/extension/internal/cairo-render-context.cpp (+7/-7) src/extension/internal/cairo-render-context.h (+1/-1) src/gradient-chemistry.cpp (+4/-4) src/gradient-drag.cpp (+188/-205) src/gradient-drag.h (+13/-10) src/graphlayout.cpp (+3/-6) src/graphlayout.h (+0/-1) src/guide-snapper.cpp (+4/-5) src/layer-manager.cpp (+9/-11) src/path-chemistry.h (+0/-1) src/profile-manager.cpp (+3/-5) src/removeoverlap.h (+0/-2) src/resource-manager.cpp (+7/-7) src/satisfied-guide-cns.cpp (+2/-2) src/selection-chemistry.h (+0/-2) src/seltrans.h (+0/-1) src/snap.cpp (+4/-5) src/snap.h (+0/-1) src/sp-clippath.h (+0/-1) src/sp-guide.cpp (+33/-34) src/sp-guide.h (+2/-3) src/sp-item-group.h (+0/-1) src/sp-mask.cpp (+14/-25) src/sp-namedview.cpp (+65/-95) src/sp-namedview.h (+5/-4) src/sp-object.h (+0/-1) src/sp-switch.h (+0/-1) src/ui/dialog/document-properties.cpp (+36/-50) src/ui/dialog/filter-effects-dialog.cpp (+4/-3) src/ui/dialog/layers.cpp (+0/-8) src/ui/dialog/svg-fonts-dialog.cpp (+3/-3) src/ui/dialog/swatches.cpp (+13/-14) src/ui/interface.cpp (+3/-3) src/ui/tools/gradient-tool.cpp (+18/-20) src/ui/tools/mesh-tool.cpp (+16/-16) src/ui/tools/select-tool.cpp (+37/-57) src/ui/tools/select-tool.h (+4/-4) src/ui/tools/tool-base.cpp (+1/-1) src/ui/widget/color-icc-selector.cpp (+3/-4) src/unclump.h (+0/-1) src/vanishing-point.cpp (+30/-36) src/vanishing-point.h (+2/-5) src/widgets/connector-toolbar.cpp (+4/-6) src/widgets/desktop-widget.cpp (+3/-3) src/widgets/gradient-toolbar.cpp (+30/-33) src/widgets/gradient-vector.cpp (+4/-4) src/widgets/mesh-toolbar.cpp (+4/-4) src/widgets/paint-selector.cpp (+4/-4) src/xml/rebase-hrefs.cpp (+3/-3) src/xml/repr-io.cpp (+7/-11) |
To merge this branch: | bzr merge lp:~inkscape.dev/inkscape/glib_hunt |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tavmjong Bah | Needs Fixing | ||
Review via email: mp+279691@code.launchpad.net |
Commit message
Description of the change
Removal of a few GList/GSList
To post a comment you must log in.
- 14510. By Mc
-
cppification : GHashMaps replaced by stl maps. getResouceList now gives a std::set<SPObject *>.
Should give some performance improvements (quite a few linear lookups are now logarithmic) - 14511. By Mc
-
update to trunk
- 14512. By Mc
-
fix crash (oops)
- 14513. By Mc
-
update to trunk + resolve conflicts
- 14514. By Mc
-
fix warning (class was a struct)
- 14515. By Mc
-
update to trunk
- 14516. By Mc
-
0-sized arrays are supposed to be forbidden
- 14517. By Mc
-
cppification: GSList replaced by vectors (connectors)
- 14518. By Mc
-
cppification: GSList replaced by vectors (undo/redo)
- 14519. By Mc
-
finally removed all GSList from main folder .h files
- 14520. By Mc
-
replaced remaining GHashTable with std::map
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/attributes.cpp' |
2 | --- src/attributes.cpp 2015-12-05 22:55:57 +0000 |
3 | +++ src/attributes.cpp 2015-12-09 15:31:04 +0000 |
4 | @@ -536,21 +536,13 @@ |
5 | unsigned |
6 | sp_attribute_lookup(gchar const *key) |
7 | { |
8 | - static GHashTable *propdict = NULL; |
9 | - |
10 | - if (!propdict) { |
11 | - unsigned int i; |
12 | - propdict = g_hash_table_new(g_str_hash, g_str_equal); |
13 | - for (i = 1; i < n_attrs; i++) { |
14 | - g_assert(props[i].code == static_cast< gint >(i) ); |
15 | - // If this g_assert fails, then the sort order of SPAttributeEnum does not match the order in props[]! |
16 | - g_hash_table_insert(propdict, |
17 | - const_cast<void *>(static_cast<void const *>(props[i].name)), |
18 | - GINT_TO_POINTER(props[i].code)); |
19 | - } |
20 | + for (unsigned int i = 1; i < n_attrs; i++) { |
21 | + g_assert(props[i].code == static_cast< gint >(i) ); |
22 | + // If this g_assert fails, then the sort order of SPAttributeEnum does not match the order in props[]! |
23 | + if(g_str_equal(const_cast<void *>(static_cast<void const *>(props[i].name)), key)) |
24 | + return GPOINTER_TO_UINT(GINT_TO_POINTER(props[i].code)); |
25 | } |
26 | - |
27 | - return GPOINTER_TO_UINT(g_hash_table_lookup(propdict, key)); |
28 | + return SP_ATTR_INVALID; |
29 | } |
30 | |
31 | unsigned char const * |
32 | |
33 | === modified file 'src/color-profile.cpp' |
34 | --- src/color-profile.cpp 2015-07-05 09:18:18 +0000 |
35 | +++ src/color-profile.cpp 2015-12-09 15:31:04 +0000 |
36 | @@ -488,18 +488,17 @@ |
37 | static SPObject* bruteFind( SPDocument* document, gchar const* name ) |
38 | { |
39 | SPObject* result = 0; |
40 | - const GSList * current = document->getResourceList("iccprofile"); |
41 | - while ( current && !result ) { |
42 | - if ( IS_COLORPROFILE(current->data) ) { |
43 | - ColorProfile* prof = COLORPROFILE(current->data); |
44 | + std::set<SPObject *> current = document->getResourceList("iccprofile"); |
45 | + for (std::set<SPObject *>::const_iterator it = current.begin(); (!result) && (it != current.end()); ++it) { |
46 | + if ( IS_COLORPROFILE(*it) ) { |
47 | + ColorProfile* prof = COLORPROFILE(*it); |
48 | if ( prof ) { |
49 | if ( prof->name && (strcmp(prof->name, name) == 0) ) { |
50 | - result = SP_OBJECT(current->data); |
51 | + result = SP_OBJECT(*it); |
52 | break; |
53 | } |
54 | } |
55 | } |
56 | - current = g_slist_next(current); |
57 | } |
58 | |
59 | return result; |
60 | |
61 | === modified file 'src/conn-avoid-ref.cpp' |
62 | --- src/conn-avoid-ref.cpp 2015-10-28 20:43:30 +0000 |
63 | +++ src/conn-avoid-ref.cpp 2015-12-09 15:31:04 +0000 |
64 | @@ -139,9 +139,9 @@ |
65 | } |
66 | |
67 | |
68 | -GSList *SPAvoidRef::getAttachedShapes(const unsigned int type) |
69 | +std::vector<SPItem *> SPAvoidRef::getAttachedShapes(const unsigned int type) |
70 | { |
71 | - GSList *list = NULL; |
72 | + std::vector<SPItem *> list; |
73 | |
74 | Avoid::IntList shapes; |
75 | GQuark shapeId = g_quark_from_string(item->getId()); |
76 | @@ -157,15 +157,15 @@ |
77 | continue; |
78 | } |
79 | SPItem *shapeItem = SP_ITEM(obj); |
80 | - list = g_slist_prepend(list, shapeItem); |
81 | + list.push_back(shapeItem); |
82 | } |
83 | return list; |
84 | } |
85 | |
86 | |
87 | -GSList *SPAvoidRef::getAttachedConnectors(const unsigned int type) |
88 | +std::vector<SPItem *> SPAvoidRef::getAttachedConnectors(const unsigned int type) |
89 | { |
90 | - GSList *list = NULL; |
91 | + std::vector<SPItem *> list; |
92 | |
93 | Avoid::IntList conns; |
94 | GQuark shapeId = g_quark_from_string(item->getId()); |
95 | @@ -181,7 +181,7 @@ |
96 | continue; |
97 | } |
98 | SPItem *connItem = SP_ITEM(obj); |
99 | - list = g_slist_prepend(list, connItem); |
100 | + list.push_back(connItem); |
101 | } |
102 | return list; |
103 | } |
104 | @@ -331,7 +331,7 @@ |
105 | } |
106 | |
107 | |
108 | -GSList *get_avoided_items(GSList *list, SPObject *from, SPDesktop *desktop, |
109 | +std::vector<SPItem *> get_avoided_items(std::vector<SPItem *> &list, SPObject *from, SPDesktop *desktop, |
110 | bool initialised) |
111 | { |
112 | for (SPObject *child = from->firstChild() ; child != NULL; child = child->next ) { |
113 | @@ -342,7 +342,7 @@ |
114 | (!initialised || SP_ITEM(child)->avoidRef->shapeRef) |
115 | ) |
116 | { |
117 | - list = g_slist_prepend (list, SP_ITEM(child)); |
118 | + list.push_back(SP_ITEM(child)); |
119 | } |
120 | |
121 | if (SP_IS_ITEM(child) && desktop->isLayer(SP_ITEM(child))) { |
122 | @@ -376,17 +376,15 @@ |
123 | DocumentUndo::setUndoSensitive(document, false); |
124 | |
125 | bool initialised = false; |
126 | - GSList *items = get_avoided_items(NULL, desktop->currentRoot(), desktop, |
127 | + std::vector<SPItem *> tmp; |
128 | + std::vector<SPItem *> items = get_avoided_items(tmp, desktop->currentRoot(), desktop, |
129 | initialised); |
130 | |
131 | - for ( GSList const *iter = items ; iter != NULL ; iter = iter->next ) { |
132 | - SPItem *item = reinterpret_cast<SPItem *>(iter->data); |
133 | + for (std::vector<SPItem *>::const_iterator iter = items.begin(); iter != items.end(); ++iter) { |
134 | + SPItem *item = *iter; |
135 | item->avoidRef->handleSettingChange(); |
136 | } |
137 | |
138 | - if (items) { |
139 | - g_slist_free(items); |
140 | - } |
141 | DocumentUndo::setUndoSensitive(document, saved); |
142 | } |
143 | |
144 | |
145 | === modified file 'src/conn-avoid-ref.h' |
146 | --- src/conn-avoid-ref.h 2014-10-08 02:22:03 +0000 |
147 | +++ src/conn-avoid-ref.h 2015-12-09 15:31:04 +0000 |
148 | @@ -20,7 +20,6 @@ |
149 | class SPDesktop; |
150 | class SPObject; |
151 | class SPItem; |
152 | -typedef struct _GSList GSList; |
153 | namespace Avoid { class ShapeRef; } |
154 | |
155 | class SPAvoidRef { |
156 | @@ -41,8 +40,8 @@ |
157 | // Avoid::runningTo |
158 | // Avoid::runningFrom |
159 | // Avoid::runningToAndFrom |
160 | - GSList *getAttachedShapes(const unsigned int type); |
161 | - GSList *getAttachedConnectors(const unsigned int type); |
162 | + std::vector<SPItem *> getAttachedShapes(const unsigned int type); |
163 | + std::vector<SPItem *> getAttachedConnectors(const unsigned int type); |
164 | |
165 | private: |
166 | SPItem *item; |
167 | @@ -55,7 +54,7 @@ |
168 | sigc::connection _transformed_connection; |
169 | }; |
170 | |
171 | -extern GSList *get_avoided_items(GSList *list, SPObject *from, |
172 | +extern std::vector<SPItem *> get_avoided_items(std::vector<SPItem *> &list, SPObject *from, |
173 | SPDesktop *desktop, bool initialised = true); |
174 | extern void avoid_item_move(Geom::Affine const *mp, SPItem *moved_item); |
175 | extern void init_avoided_shape_geometry(SPDesktop *desktop); |
176 | |
177 | === modified file 'src/desktop-style.h' |
178 | --- src/desktop-style.h 2015-10-28 13:40:01 +0000 |
179 | +++ src/desktop-style.h 2015-12-09 15:31:04 +0000 |
180 | @@ -19,7 +19,6 @@ |
181 | class SPObject; |
182 | class SPItem; |
183 | class SPStyle; |
184 | -typedef struct _GSList GSList; |
185 | namespace Inkscape { |
186 | namespace XML { |
187 | class Node; |
188 | |
189 | === modified file 'src/desktop.cpp' |
190 | --- src/desktop.cpp 2015-12-06 21:39:31 +0000 |
191 | +++ src/desktop.cpp 2015-12-09 15:31:04 +0000 |
192 | @@ -1479,7 +1479,7 @@ |
193 | |
194 | void SPDesktop::toggleGrids() |
195 | { |
196 | - if (namedview->grids) { |
197 | + if (! namedview->grids.empty()) { |
198 | if(gridgroup) { |
199 | showGrids(!grids_visible); |
200 | } |
201 | @@ -1704,12 +1704,6 @@ |
202 | desktop->_reconstruction_old_layer_id = desktop->currentLayer()->getId() ? desktop->currentLayer()->getId() : ""; |
203 | desktop->layers->reset(); |
204 | |
205 | - /* |
206 | - GSList const * selection_objs = desktop->selection->list(); |
207 | - for (; selection_objs != NULL; selection_objs = selection_objs->next) { |
208 | - |
209 | - } |
210 | - */ |
211 | desktop->selection->clear(); |
212 | } |
213 | |
214 | |
215 | === modified file 'src/document-private.h' |
216 | --- src/document-private.h 2014-10-08 02:22:03 +0000 |
217 | +++ src/document-private.h 2015-12-09 15:31:04 +0000 |
218 | @@ -15,6 +15,8 @@ |
219 | */ |
220 | |
221 | #include <map> |
222 | +#include <set> |
223 | +#include <string> |
224 | #include <stddef.h> |
225 | #include <sigc++/sigc++.h> |
226 | #include "xml/event-fns.h" |
227 | @@ -34,14 +36,12 @@ |
228 | } |
229 | } |
230 | |
231 | -typedef struct _GHashTable GHashTable; |
232 | - |
233 | struct SPDocumentPrivate { |
234 | typedef std::map<GQuark, SPDocument::IDChangedSignal> IDChangedSignalMap; |
235 | typedef std::map<GQuark, SPDocument::ResourcesChangedSignal> ResourcesChangedSignalMap; |
236 | |
237 | - GHashTable *iddef; /**< Dictionary of id -> SPObject mappings */ |
238 | - GHashTable *reprdef; /**< Dictionary of Inkscape::XML::Node -> SPObject mappings */ |
239 | + std::map<std::string, SPObject *> iddef; |
240 | + std::map<Inkscape::XML::Node *, SPObject *> reprdef; |
241 | |
242 | unsigned long serial; |
243 | |
244 | @@ -49,8 +49,7 @@ |
245 | IDChangedSignalMap id_changed_signals; |
246 | |
247 | /* Resources */ |
248 | - /* It is GHashTable of GSLists */ |
249 | - GHashTable *resources; |
250 | + std::map<std::string, std::set<SPObject *> > resources; |
251 | ResourcesChangedSignalMap resources_changed_signals; |
252 | |
253 | sigc::signal<void> destroySignal; |
254 | @@ -65,8 +64,8 @@ |
255 | bool sensitive; /* If we save actions to undo stack */ |
256 | Inkscape::XML::Event * partial; /* partial undo log when interrupted */ |
257 | int history_size; |
258 | - GSList * undo; /* Undo stack of reprs */ |
259 | - GSList * redo; /* Redo stack of reprs */ |
260 | + std::vector<Inkscape::Event *> undo; /* Undo stack of reprs */ |
261 | + std::vector<Inkscape::Event *> redo; /* Redo stack of reprs */ |
262 | |
263 | /* Undo listener */ |
264 | Inkscape::CompositeUndoStackObserver undoStackObservers; |
265 | |
266 | === modified file 'src/document-undo.cpp' |
267 | --- src/document-undo.cpp 2015-06-10 13:56:12 +0000 |
268 | +++ src/document-undo.cpp 2015-12-09 15:31:04 +0000 |
269 | @@ -162,12 +162,12 @@ |
270 | return; |
271 | } |
272 | |
273 | - if (key && !doc->actionkey.empty() && (doc->actionkey == key) && doc->priv->undo) { |
274 | - ((Inkscape::Event *)doc->priv->undo->data)->event = |
275 | - sp_repr_coalesce_log (((Inkscape::Event *)doc->priv->undo->data)->event, log); |
276 | + if (key && !doc->actionkey.empty() && (doc->actionkey == key) && !doc->priv->undo.empty()) { |
277 | + (doc->priv->undo.back())->event = |
278 | + sp_repr_coalesce_log ((doc->priv->undo.back())->event, log); |
279 | } else { |
280 | Inkscape::Event *event = new Inkscape::Event(log, event_type, event_description); |
281 | - doc->priv->undo = g_slist_prepend (doc->priv->undo, event); |
282 | + doc->priv->undo.push_back(event); |
283 | doc->priv->history_size++; |
284 | doc->priv->undoStackObservers.notifyUndoCommitEvent(event); |
285 | } |
286 | @@ -211,7 +211,7 @@ |
287 | priv.partial = sp_repr_coalesce_log(priv.partial, log); |
288 | sp_repr_debug_print_log(priv.partial); |
289 | Inkscape::Event *event = new Inkscape::Event(priv.partial); |
290 | - priv.undo = g_slist_prepend(priv.undo, event); |
291 | + priv.undo.push_back(event); |
292 | priv.undoStackObservers.notifyUndoCommitEvent(event); |
293 | priv.partial = NULL; |
294 | } |
295 | @@ -227,8 +227,8 @@ |
296 | sp_repr_debug_print_log(update_log); |
297 | |
298 | //Coalesce the update changes with the last action performed by user |
299 | - Inkscape::Event* undo_stack_top = (Inkscape::Event *)doc.priv->undo->data; |
300 | - if (undo_stack_top) { |
301 | + if (!doc.priv->undo.empty()) { |
302 | + Inkscape::Event* undo_stack_top = doc.priv->undo.back(); |
303 | undo_stack_top->event = sp_repr_coalesce_log(undo_stack_top->event, update_log); |
304 | } else { |
305 | sp_repr_free_log(update_log); |
306 | @@ -256,13 +256,13 @@ |
307 | |
308 | finish_incomplete_transaction(*doc); |
309 | |
310 | - if (doc->priv->undo) { |
311 | - Inkscape::Event *log=(Inkscape::Event *)doc->priv->undo->data; |
312 | - doc->priv->undo = g_slist_remove (doc->priv->undo, log); |
313 | + if (! doc->priv->undo.empty()) { |
314 | + Inkscape::Event *log = doc->priv->undo.back(); |
315 | + doc->priv->undo.pop_back(); |
316 | sp_repr_undo_log (log->event); |
317 | perform_document_update(*doc); |
318 | |
319 | - doc->priv->redo = g_slist_prepend (doc->priv->redo, log); |
320 | + doc->priv->redo.push_back(log); |
321 | |
322 | doc->setModifiedSinceSave(); |
323 | doc->priv->undoStackObservers.notifyUndoEvent(log); |
324 | @@ -303,11 +303,11 @@ |
325 | |
326 | finish_incomplete_transaction(*doc); |
327 | |
328 | - if (doc->priv->redo) { |
329 | - Inkscape::Event *log=(Inkscape::Event *)doc->priv->redo->data; |
330 | - doc->priv->redo = g_slist_remove (doc->priv->redo, log); |
331 | + if (! doc->priv->redo.empty()) { |
332 | + Inkscape::Event *log = doc->priv->redo.back(); |
333 | + doc->priv->redo.pop_back(); |
334 | sp_repr_replay_log (log->event); |
335 | - doc->priv->undo = g_slist_prepend (doc->priv->undo, log); |
336 | + doc->priv->undo.push_back(log); |
337 | |
338 | doc->setModifiedSinceSave(); |
339 | doc->priv->undoStackObservers.notifyRedoEvent(log); |
340 | @@ -330,37 +330,29 @@ |
341 | |
342 | void Inkscape::DocumentUndo::clearUndo(SPDocument *doc) |
343 | { |
344 | - if (doc->priv->undo) |
345 | - doc->priv->undoStackObservers.notifyClearUndoEvent(); |
346 | - |
347 | - while (doc->priv->undo) { |
348 | - GSList *current; |
349 | - |
350 | - current = doc->priv->undo; |
351 | - doc->priv->undo = current->next; |
352 | - doc->priv->history_size--; |
353 | - |
354 | - delete ((Inkscape::Event *) current->data); |
355 | - g_slist_free_1 (current); |
356 | - } |
357 | + if (! doc->priv->undo.empty()) |
358 | + doc->priv->undoStackObservers.notifyClearUndoEvent(); |
359 | + while (! doc->priv->undo.empty()) { |
360 | + Inkscape::Event *e = doc->priv->undo.back(); |
361 | + doc->priv->undo.pop_back(); |
362 | + delete e; |
363 | + doc->priv->history_size--; |
364 | + } |
365 | } |
366 | |
367 | void Inkscape::DocumentUndo::clearRedo(SPDocument *doc) |
368 | { |
369 | - if (doc->priv->redo) |
370 | + if (!doc->priv->redo.empty()) |
371 | doc->priv->undoStackObservers.notifyClearRedoEvent(); |
372 | |
373 | - while (doc->priv->redo) { |
374 | - GSList *current; |
375 | - |
376 | - current = doc->priv->redo; |
377 | - doc->priv->redo = current->next; |
378 | - doc->priv->history_size--; |
379 | - |
380 | - delete ((Inkscape::Event *) current->data); |
381 | - g_slist_free_1 (current); |
382 | - } |
383 | + while (! doc->priv->redo.empty()) { |
384 | + Inkscape::Event *e = doc->priv->redo.back(); |
385 | + doc->priv->redo.pop_back(); |
386 | + delete e; |
387 | + doc->priv->history_size--; |
388 | + } |
389 | } |
390 | + |
391 | /* |
392 | Local Variables: |
393 | mode:c++ |
394 | |
395 | === modified file 'src/document.cpp' |
396 | --- src/document.cpp 2015-11-25 01:05:31 +0000 |
397 | +++ src/document.cpp 2015-12-09 15:31:04 +0000 |
398 | @@ -81,7 +81,7 @@ |
399 | static gint sp_document_idle_handler(gpointer data); |
400 | static gint sp_document_rerouting_handler(gpointer data); |
401 | |
402 | -gboolean sp_document_resource_list_free(gpointer key, gpointer value, gpointer data); |
403 | +//gboolean sp_document_resource_list_free(gpointer key, gpointer value, gpointer data); |
404 | |
405 | static gint doc_count = 0; |
406 | static gint doc_mem_count = 0; |
407 | @@ -105,7 +105,6 @@ |
408 | rerouting_handler_id(0), |
409 | profileManager(NULL), // deferred until after other initialization |
410 | router(new Avoid::Router(Avoid::PolyLineRouting|Avoid::OrthogonalRouting)), |
411 | - _collection_queue(NULL), |
412 | oldSignalsConnected(false), |
413 | current_persp3d(NULL), |
414 | current_persp3d_impl(NULL), |
415 | @@ -119,16 +118,9 @@ |
416 | |
417 | p->serial = next_serial++; |
418 | |
419 | - p->iddef = g_hash_table_new(g_direct_hash, g_direct_equal); |
420 | - p->reprdef = g_hash_table_new(g_direct_hash, g_direct_equal); |
421 | - |
422 | - p->resources = g_hash_table_new(g_str_hash, g_str_equal); |
423 | - |
424 | p->sensitive = false; |
425 | p->partial = NULL; |
426 | p->history_size = 0; |
427 | - p->undo = NULL; |
428 | - p->redo = NULL; |
429 | p->seeking = false; |
430 | |
431 | priv = p; |
432 | @@ -177,17 +169,10 @@ |
433 | root = NULL; |
434 | } |
435 | |
436 | - if (priv->iddef) g_hash_table_destroy(priv->iddef); |
437 | - if (priv->reprdef) g_hash_table_destroy(priv->reprdef); |
438 | - |
439 | if (rdoc) Inkscape::GC::release(rdoc); |
440 | |
441 | /* Free resources */ |
442 | - g_hash_table_foreach_remove(priv->resources, sp_document_resource_list_free, this); |
443 | - g_hash_table_destroy(priv->resources); |
444 | - |
445 | - delete priv; |
446 | - priv = NULL; |
447 | + priv->resources.clear(); |
448 | } |
449 | |
450 | cr_cascade_unref(style_cascade); |
451 | @@ -295,19 +280,18 @@ |
452 | g_return_if_fail(object->document == this); |
453 | |
454 | sp_object_ref(object, NULL); |
455 | - _collection_queue = g_slist_prepend(_collection_queue, object); |
456 | + _collection_queue.push_back(object); |
457 | } |
458 | |
459 | void SPDocument::collectOrphans() { |
460 | - while (_collection_queue) { |
461 | - GSList *objects=_collection_queue; |
462 | - _collection_queue = NULL; |
463 | - for ( GSList *iter=objects ; iter ; iter = iter->next ) { |
464 | - SPObject *object=reinterpret_cast<SPObject *>(iter->data); |
465 | + while (!_collection_queue.empty()) { |
466 | + std::vector<SPObject *> objects(_collection_queue); |
467 | + _collection_queue.clear(); |
468 | + for (std::vector<SPObject *>::const_iterator iter = objects.begin(); iter != objects.end(); ++iter) { |
469 | + SPObject *object = *iter; |
470 | object->collectOrphan(); |
471 | sp_object_unref(object, NULL); |
472 | } |
473 | - g_slist_free(objects); |
474 | } |
475 | } |
476 | |
477 | @@ -1008,11 +992,15 @@ |
478 | GQuark idq = g_quark_from_string(id); |
479 | |
480 | if (object) { |
481 | - g_assert(g_hash_table_lookup(priv->iddef, GINT_TO_POINTER(idq)) == NULL); |
482 | - g_hash_table_insert(priv->iddef, GINT_TO_POINTER(idq), object); |
483 | + g_assert(priv->iddef.find(id)==priv->iddef.end()); |
484 | + priv->iddef[id] = object; |
485 | + //g_assert(g_hash_table_lookup(priv->iddef, GINT_TO_POINTER(idq)) == NULL); |
486 | + //g_hash_table_insert(priv->iddef, GINT_TO_POINTER(idq), object); |
487 | } else { |
488 | - g_assert(g_hash_table_lookup(priv->iddef, GINT_TO_POINTER(idq)) != NULL); |
489 | - g_hash_table_remove(priv->iddef, GINT_TO_POINTER(idq)); |
490 | + g_assert(priv->iddef.find(id)!=priv->iddef.end()); |
491 | + priv->iddef.erase(id); |
492 | + //g_assert(g_hash_table_lookup(priv->iddef, GINT_TO_POINTER(idq)) != NULL); |
493 | + //g_hash_table_remove(priv->iddef, GINT_TO_POINTER(idq)); |
494 | } |
495 | |
496 | SPDocumentPrivate::IDChangedSignalMap::iterator pos; |
497 | @@ -1047,15 +1035,16 @@ |
498 | SPObject *SPDocument::getObjectById(gchar const *id) const |
499 | { |
500 | g_return_val_if_fail(id != NULL, NULL); |
501 | - if (!priv || !priv->iddef) { |
502 | + if (!priv || priv->iddef.empty()) { |
503 | return NULL; |
504 | } |
505 | |
506 | GQuark idq = g_quark_from_string(id); |
507 | - gpointer rv = g_hash_table_lookup(priv->iddef, GINT_TO_POINTER(idq)); |
508 | - if(rv != NULL) |
509 | + std::map<std::string, SPObject *>::iterator rv = priv->iddef.find(id); |
510 | + //gpointer rv = g_hash_table_lookup(priv->iddef, GINT_TO_POINTER(idq)); |
511 | + if(rv != priv->iddef.end()) |
512 | { |
513 | - return static_cast<SPObject*>(rv); |
514 | + return (rv->second); |
515 | } |
516 | else |
517 | { |
518 | @@ -1072,18 +1061,22 @@ |
519 | void SPDocument::bindObjectToRepr(Inkscape::XML::Node *repr, SPObject *object) |
520 | { |
521 | if (object) { |
522 | - g_assert(g_hash_table_lookup(priv->reprdef, repr) == NULL); |
523 | - g_hash_table_insert(priv->reprdef, repr, object); |
524 | + g_assert(priv->reprdef.find(repr)==priv->reprdef.end()); |
525 | + priv->reprdef[repr] = object; |
526 | } else { |
527 | - g_assert(g_hash_table_lookup(priv->reprdef, repr) != NULL); |
528 | - g_hash_table_remove(priv->reprdef, repr); |
529 | + g_assert(priv->reprdef.find(repr)!=priv->reprdef.end()); |
530 | + priv->reprdef.erase(repr); |
531 | } |
532 | } |
533 | |
534 | SPObject *SPDocument::getObjectByRepr(Inkscape::XML::Node *repr) const |
535 | { |
536 | g_return_val_if_fail(repr != NULL, NULL); |
537 | - return static_cast<SPObject*>(g_hash_table_lookup(priv->reprdef, repr)); |
538 | + std::map<Inkscape::XML::Node *, SPObject *>::iterator rv = priv->reprdef.find(repr); |
539 | + if(rv != priv->reprdef.end()) |
540 | + return (rv->second); |
541 | + else |
542 | + return NULL; |
543 | } |
544 | |
545 | Glib::ustring SPDocument::getLanguage() const |
546 | @@ -1528,10 +1521,9 @@ |
547 | bool result = false; |
548 | |
549 | if ( !object->cloned ) { |
550 | - GSList *rlist = (GSList*)g_hash_table_lookup(priv->resources, key); |
551 | - g_return_val_if_fail(!g_slist_find(rlist, object), false); |
552 | - rlist = g_slist_prepend(rlist, object); |
553 | - g_hash_table_insert(priv->resources, (gpointer) key, rlist); |
554 | + std::set<SPObject *> rlist = priv->resources[key]; |
555 | + g_return_val_if_fail(rlist.find(object) == rlist.end(), false); |
556 | + priv->resources[key].insert(object); |
557 | |
558 | GQuark q = g_quark_from_string(key); |
559 | |
560 | @@ -1560,11 +1552,10 @@ |
561 | bool result = false; |
562 | |
563 | if ( !object->cloned ) { |
564 | - GSList *rlist = (GSList*)g_hash_table_lookup(priv->resources, key); |
565 | - g_return_val_if_fail(rlist != NULL, false); |
566 | - g_return_val_if_fail(g_slist_find(rlist, object), false); |
567 | - rlist = g_slist_remove(rlist, object); |
568 | - g_hash_table_insert(priv->resources, (gpointer) key, rlist); |
569 | + std::set<SPObject *> rlist = priv->resources[key]; |
570 | + g_return_val_if_fail(!rlist.empty(), false); |
571 | + g_return_val_if_fail(rlist.find(object) != rlist.end(), false); |
572 | + priv->resources[key].erase(object); |
573 | |
574 | GQuark q = g_quark_from_string(key); |
575 | priv->resources_changed_signals[q].emit(); |
576 | @@ -1575,12 +1566,13 @@ |
577 | return result; |
578 | } |
579 | |
580 | -GSList const *SPDocument::getResourceList(gchar const *key) const |
581 | +std::set<SPObject *> const SPDocument::getResourceList(gchar const *key) const |
582 | { |
583 | - g_return_val_if_fail(key != NULL, NULL); |
584 | - g_return_val_if_fail(*key != '\0', NULL); |
585 | + std::set<SPObject *> emptyset; |
586 | + g_return_val_if_fail(key != NULL, emptyset); |
587 | + g_return_val_if_fail(*key != '\0', emptyset); |
588 | |
589 | - return (GSList*)g_hash_table_lookup(this->priv->resources, key); |
590 | + return this->priv->resources[key]; |
591 | } |
592 | |
593 | sigc::connection SPDocument::connectResourcesChanged(gchar const *key, |
594 | @@ -1592,13 +1584,6 @@ |
595 | |
596 | /* Helpers */ |
597 | |
598 | -gboolean |
599 | -sp_document_resource_list_free(gpointer /*key*/, gpointer value, gpointer /*data*/) |
600 | -{ |
601 | - g_slist_free((GSList *) value); |
602 | - return TRUE; |
603 | -} |
604 | - |
605 | static unsigned int count_objects_recursive(SPObject *obj, unsigned int count) |
606 | { |
607 | count++; // obj itself |
608 | |
609 | === modified file 'src/document.h' |
610 | --- src/document.h 2015-10-04 01:31:27 +0000 |
611 | +++ src/document.h 2015-12-09 15:31:04 +0000 |
612 | @@ -27,6 +27,7 @@ |
613 | #include <glibmm/ustring.h> |
614 | #include <boost/ptr_container/ptr_list.hpp> |
615 | #include <vector> |
616 | +#include <set> |
617 | |
618 | namespace Avoid { |
619 | class Router; |
620 | @@ -121,7 +122,7 @@ |
621 | // Instance of the connector router |
622 | Avoid::Router *router; |
623 | |
624 | - GSList *_collection_queue; |
625 | + std::vector<SPObject *> _collection_queue; |
626 | |
627 | bool oldSignalsConnected; |
628 | |
629 | @@ -258,7 +259,7 @@ |
630 | int ensureUpToDate(); |
631 | bool addResource(char const *key, SPObject *object); |
632 | bool removeResource(char const *key, SPObject *object); |
633 | - const GSList *getResourceList(char const *key) const; |
634 | + const std::set<SPObject *> getResourceList(char const *key) const; |
635 | std::vector<SPItem*> getItemsInBox(unsigned int dkey, Geom::Rect const &box) const; |
636 | std::vector<SPItem*> getItemsPartiallyInBox(unsigned int dkey, Geom::Rect const &box) const; |
637 | SPItem *getItemAtPoint(unsigned int key, Geom::Point const &p, bool into_groups, SPItem *upto = NULL) const; |
638 | |
639 | === modified file 'src/extension/internal/cairo-render-context.cpp' |
640 | --- src/extension/internal/cairo-render-context.cpp 2015-12-07 20:20:33 +0000 |
641 | +++ src/extension/internal/cairo-render-context.cpp 2015-12-09 15:31:04 +0000 |
642 | @@ -130,14 +130,12 @@ |
643 | _clip_mode(CLIP_MODE_MASK), |
644 | _omittext_state(EMPTY) |
645 | { |
646 | - font_table = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, font_data_free); |
647 | } |
648 | |
649 | CairoRenderContext::~CairoRenderContext(void) |
650 | { |
651 | - if(font_table != NULL) { |
652 | - g_hash_table_remove_all(font_table); |
653 | - } |
654 | + for (std::map<gpointer, cairo_font_face_t *>::const_iterator iter = font_table.begin(); iter != font_table.end(); ++iter) |
655 | + font_data_free(iter->second); |
656 | |
657 | if (_cr) cairo_destroy(_cr); |
658 | if (_surface) cairo_surface_destroy(_surface); |
659 | @@ -1645,7 +1643,9 @@ |
660 | // create a cairo_font_face from PangoFont |
661 | double size = style->font_size.computed; /// \fixme why is this variable never used? |
662 | gpointer fonthash = (gpointer)font; |
663 | - cairo_font_face_t *font_face = (cairo_font_face_t *)g_hash_table_lookup(font_table, fonthash); |
664 | + cairo_font_face_t *font_face = NULL; |
665 | + if(font_table.find(fonthash)!=font_table.end()) |
666 | + font_face = font_table[fonthash]; |
667 | |
668 | FcPattern *fc_pattern = NULL; |
669 | |
670 | @@ -1660,7 +1660,7 @@ |
671 | |
672 | if(font_face == NULL) { |
673 | font_face = cairo_win32_font_face_create_for_logfontw(&lfw); |
674 | - g_hash_table_insert(font_table, fonthash, font_face); |
675 | + font_table[fonthash] = font_face; |
676 | } |
677 | # endif |
678 | #else |
679 | @@ -1669,7 +1669,7 @@ |
680 | fc_pattern = fc_font->font_pattern; |
681 | if(font_face == NULL) { |
682 | font_face = cairo_ft_font_face_create_for_pattern(fc_pattern); |
683 | - g_hash_table_insert(font_table, fonthash, font_face); |
684 | + font_table[fonthash] = font_face; |
685 | } |
686 | # endif |
687 | #endif |
688 | |
689 | === modified file 'src/extension/internal/cairo-render-context.h' |
690 | --- src/extension/internal/cairo-render-context.h 2014-10-18 21:44:39 +0000 |
691 | +++ src/extension/internal/cairo-render-context.h 2015-12-09 15:31:04 +0000 |
692 | @@ -219,7 +219,7 @@ |
693 | void _prepareRenderGraphic(void); |
694 | void _prepareRenderText(void); |
695 | |
696 | - GHashTable *font_table; |
697 | + std::map<gpointer, cairo_font_face_t *> font_table; |
698 | static void font_data_free(gpointer data); |
699 | |
700 | CairoRenderState *_createState(void); |
701 | |
702 | === modified file 'src/gradient-chemistry.cpp' |
703 | --- src/gradient-chemistry.cpp 2015-11-13 17:53:22 +0000 |
704 | +++ src/gradient-chemistry.cpp 2015-12-09 15:31:04 +0000 |
705 | @@ -1592,7 +1592,7 @@ |
706 | GrDrag *drag = ev->get_drag(); |
707 | |
708 | // First try selected dragger |
709 | - if (drag && drag->selected) { |
710 | + if (drag && !drag->selected.empty()) { |
711 | drag->selected_reverse_vector(); |
712 | } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients) |
713 | const std::vector<SPItem*> list=selection->itemList(); |
714 | @@ -1612,9 +1612,9 @@ |
715 | SPDocument *doc = desktop ? desktop->doc() : 0; |
716 | |
717 | if (doc) { |
718 | - const GSList *gradients = doc->getResourceList("gradient"); |
719 | - for (const GSList *item = gradients; item; item = item->next) { |
720 | - SPGradient* grad = SP_GRADIENT(item->data); |
721 | + const std::set<SPObject *> gradients = doc->getResourceList("gradient"); |
722 | + for (std::set<SPObject *>::const_iterator i = gradients.begin(); i != gradients.end(); ++i) { |
723 | + SPGradient* grad = SP_GRADIENT(*i); |
724 | if ( id == grad->getId() ) { |
725 | grad->setSwatch(false); |
726 | DocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT, |
727 | |
728 | === modified file 'src/gradient-drag.cpp' |
729 | --- src/gradient-drag.cpp 2015-11-13 17:53:22 +0000 |
730 | +++ src/gradient-drag.cpp 2015-12-09 15:31:04 +0000 |
731 | @@ -142,7 +142,7 @@ |
732 | return QUERY_STYLE_NOTHING; |
733 | } |
734 | |
735 | - if (!drag->selected) { |
736 | + if (drag->selected.empty()) { |
737 | return QUERY_STYLE_NOTHING; |
738 | } else { |
739 | int ret = QUERY_STYLE_NOTHING; |
740 | @@ -151,11 +151,10 @@ |
741 | cf[0] = cf[1] = cf[2] = cf[3] = 0; |
742 | |
743 | int count = 0; |
744 | - |
745 | - for (GList *i = drag->selected; i != NULL; i = i->next) { // for all selected draggers |
746 | - GrDragger *d = (GrDragger *) i->data; |
747 | - for (GSList const* j = d->draggables; j != NULL; j = j->next) { // for all draggables of dragger |
748 | - GrDraggable *draggable = (GrDraggable *) j->data; |
749 | + for(std::set<GrDragger *>::const_iterator it = drag->selected.begin(); it != drag->selected.end(); ++it) { //for all selected draggers |
750 | + GrDragger *d = *it; |
751 | + for(std::vector<GrDraggable *>::const_iterator it2 = d->draggables.begin(); it2 != d->draggables.end(); ++it2 ) { //for all draggables of dragger |
752 | + GrDraggable *draggable = *it2; |
753 | |
754 | if (ret == QUERY_STYLE_NOTHING) { |
755 | ret = QUERY_STYLE_SINGLE; |
756 | @@ -209,9 +208,9 @@ |
757 | Glib::ustring::size_type pos = colorStr.find("url(#"); |
758 | if ( pos != Glib::ustring::npos ) { |
759 | Glib::ustring targetName = colorStr.substr(pos + 5, colorStr.length() - 6); |
760 | - const GSList *gradients = desktop->doc()->getResourceList("gradient"); |
761 | - for (const GSList *item = gradients; item; item = item->next) { |
762 | - SPGradient* grad = SP_GRADIENT(item->data); |
763 | + std::set<SPObject *> gradients = desktop->doc()->getResourceList("gradient"); |
764 | + for (std::set<SPObject *>::const_iterator it = gradients.begin(); it != gradients.end(); ++it) { |
765 | + SPGradient* grad = SP_GRADIENT(*it); |
766 | if ( targetName == grad->getId() ) { |
767 | SPGradient *vect = grad->getVector(); |
768 | SPStop *firstStop = (vect) ? vect->getFirstStop() : grad->getFirstStop(); |
769 | @@ -239,7 +238,7 @@ |
770 | |
771 | bool GrDrag::styleSet( const SPCSSAttr *css ) |
772 | { |
773 | - if (!selected) { |
774 | + if (selected.empty()) { |
775 | return false; |
776 | } |
777 | |
778 | @@ -307,11 +306,10 @@ |
779 | return false; |
780 | } |
781 | |
782 | - for (GList const* sel = selected; sel != NULL; sel = sel->next) { // for all selected draggers |
783 | - GrDragger* dragger = reinterpret_cast<GrDragger*>(sel->data); |
784 | - for (GSList const* i = dragger->draggables; i != NULL; i = i->next) { // for all draggables of dragger |
785 | - GrDraggable *draggable = reinterpret_cast<GrDraggable *>(i->data); |
786 | - |
787 | + for(std::set<GrDragger *>::const_iterator it = selected.begin(); it != selected.end(); ++it) { //for all selected draggers |
788 | + GrDragger *d = *it; |
789 | + for(std::vector<GrDraggable *>::const_iterator it2 = d->draggables.begin(); it2 != d->draggables.end(); ++it2 ) { //for all draggables of dragger |
790 | + GrDraggable *draggable = *it2; |
791 | local_change = true; |
792 | sp_item_gradient_stop_set_style(draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke, stop); |
793 | } |
794 | @@ -324,17 +322,17 @@ |
795 | |
796 | guint32 GrDrag::getColor() |
797 | { |
798 | - if (!selected) return 0; |
799 | + if (selected.empty()) return 0; |
800 | |
801 | float cf[4]; |
802 | cf[0] = cf[1] = cf[2] = cf[3] = 0; |
803 | |
804 | int count = 0; |
805 | |
806 | - for (GList *i = selected; i != NULL; i = i->next) { // for all selected draggers |
807 | - GrDragger *d = (GrDragger *) i->data; |
808 | - for (GSList const* j = d->draggables; j != NULL; j = j->next) { // for all draggables of dragger |
809 | - GrDraggable *draggable = (GrDraggable *) j->data; |
810 | + for(std::set<GrDragger *>::const_iterator it = selected.begin(); it != selected.end(); ++it) { //for all selected draggers |
811 | + GrDragger *d = *it; |
812 | + for(std::vector<GrDraggable *>::const_iterator it2 = d->draggables.begin(); it2 != d->draggables.end(); ++it2 ) { //for all draggables of dragger |
813 | + GrDraggable *draggable = *it2; |
814 | |
815 | guint32 c = sp_item_gradient_stop_query_style (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke); |
816 | cf[0] += SP_RGBA32_R_F (c); |
817 | @@ -580,15 +578,15 @@ |
818 | Glib::ustring toUse = makeStopSafeColor( c, stopIsNull ); |
819 | |
820 | // first, see if we can drop onto one of the existing draggers |
821 | - for (GList *i = draggers; i != NULL; i = i->next) { // for all draggables of dragger |
822 | - GrDragger *d = (GrDragger *) i->data; |
823 | + for(std::vector<GrDragger *>::const_iterator i = draggers.begin(); i != draggers.end(); ++i) { //for all draggers |
824 | + GrDragger *d = *i ; |
825 | |
826 | if (Geom::L2(p - d->point)*desktop->current_zoom() < 5) { |
827 | SPCSSAttr *stop = sp_repr_css_attr_new (); |
828 | sp_repr_css_set_property( stop, "stop-color", stopIsNull ? 0 : toUse.c_str() ); |
829 | sp_repr_css_set_property( stop, "stop-opacity", "1" ); |
830 | - for (GSList *j = d->draggables; j != NULL; j = j->next) { // for all draggables of dragger |
831 | - GrDraggable *draggable = (GrDraggable *) j->data; |
832 | + for(std::vector<GrDraggable *>::const_iterator j = d->draggables.begin(); j != d->draggables.end(); ++j) { //for all draggables of dragger |
833 | + GrDraggable *draggable = *j; |
834 | local_change = true; |
835 | sp_item_gradient_stop_set_style (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke, stop); |
836 | } |
837 | @@ -599,9 +597,9 @@ |
838 | |
839 | // now see if we're over line and create a new stop |
840 | bool over_line = false; |
841 | - if (lines) { |
842 | - for (GSList *l = lines; (l != NULL) && (!over_line); l = l->next) { |
843 | - SPCtrlLine *line = (SPCtrlLine*) l->data; |
844 | + if (!lines.empty()) { |
845 | + for (std::vector<SPCtrlLine *>::const_iterator l = lines.begin(); l != lines.end() && (!over_line); ++l) { |
846 | + SPCtrlLine *line = *l; |
847 | Geom::LineSegment ls(line->s, line->e); |
848 | Geom::Point nearest = ls.pointAt(ls.nearestTime(p)); |
849 | double dist_screen = Geom::L2(p - nearest) * desktop->current_zoom(); |
850 | @@ -623,7 +621,6 @@ |
851 | |
852 | |
853 | GrDrag::GrDrag(SPDesktop *desktop) : |
854 | - selected(0), |
855 | keep_selection(false), |
856 | local_change(false), |
857 | desktop(desktop), |
858 | @@ -676,8 +673,8 @@ |
859 | this->style_set_connection.disconnect(); |
860 | this->style_query_connection.disconnect(); |
861 | |
862 | - if (this->selected) { |
863 | - GrDraggable *draggable = (GrDraggable *) ((GrDragger*)this->selected->data)->draggables->data; |
864 | + if (! this->selected.empty()) { |
865 | + GrDraggable *draggable = (*(this->selected.begin()))->draggables[0]; |
866 | desktop->gr_item = draggable->item; |
867 | desktop->gr_point_type = draggable->point_type; |
868 | desktop->gr_point_i = draggable->point_i; |
869 | @@ -690,18 +687,16 @@ |
870 | } |
871 | |
872 | deselect_all(); |
873 | - for (GList *l = this->draggers; l != NULL; l = l->next) { |
874 | - delete ((GrDragger *) l->data); |
875 | + for (std::vector<GrDragger *>::const_iterator it = this->draggers.begin(); it != this->draggers.end(); ++it) { |
876 | + delete (*it); |
877 | } |
878 | - g_list_free (this->draggers); |
879 | - this->draggers = NULL; |
880 | - this->selected = NULL; |
881 | + this->draggers.clear(); |
882 | + this->selected.clear(); |
883 | |
884 | - for (GSList *l = this->lines; l != NULL; l = l->next) { |
885 | - sp_canvas_item_destroy(SP_CANVAS_ITEM(l->data)); |
886 | + for (std::vector<SPCtrlLine *>::const_iterator it = this->lines.begin(); it != this->lines.end(); ++it) { |
887 | + sp_canvas_item_destroy(SP_CANVAS_ITEM(*it)); |
888 | } |
889 | - g_slist_free (this->lines); |
890 | - this->lines = NULL; |
891 | + this->lines.clear(); |
892 | } |
893 | |
894 | GrDraggable::GrDraggable(SPItem *item, GrPointType point_type, guint point_i, Inkscape::PaintTarget fill_or_stroke) : |
895 | @@ -751,39 +746,43 @@ |
896 | |
897 | if (state & GDK_SHIFT_MASK) { |
898 | // with Shift; unsnap if we carry more than one draggable |
899 | - if (dragger->draggables && dragger->draggables->next) { |
900 | + if (dragger->draggables.size()>1) { |
901 | // create a new dragger |
902 | GrDragger *dr_new = new GrDragger (dragger->parent, dragger->point, NULL); |
903 | - dragger->parent->draggers = g_list_prepend (dragger->parent->draggers, dr_new); |
904 | + dragger->parent->draggers.insert(dragger->parent->draggers.begin(), dr_new); |
905 | // relink to it all but the first draggable in the list |
906 | - for (GSList const* i = dragger->draggables->next; i != NULL; i = i->next) { |
907 | - GrDraggable *draggable = (GrDraggable *) i->data; |
908 | + std::vector<GrDraggable *>::const_iterator i = dragger->draggables.begin(); |
909 | + for ( ++i ; i != dragger->draggables.end(); ++i ) { |
910 | + GrDraggable *draggable = *i; |
911 | dr_new->addDraggable (draggable); |
912 | } |
913 | dr_new->updateKnotShape(); |
914 | - g_slist_free (dragger->draggables->next); |
915 | - dragger->draggables->next = NULL; |
916 | + if(dragger->draggables.size()>1){ |
917 | + GrDraggable *tmp = dragger->draggables[0]; |
918 | + dragger->draggables.clear(); |
919 | + dragger->draggables.push_back(tmp); |
920 | + } |
921 | dragger->updateKnotShape(); |
922 | dragger->updateTip(); |
923 | } |
924 | } else if (!(state & GDK_CONTROL_MASK)) { |
925 | // without Shift or Ctrl; see if we need to snap to another dragger |
926 | - for (GList *di = dragger->parent->draggers; di != NULL; di = di->next) { |
927 | - GrDragger *d_new = (GrDragger *) di->data; |
928 | + for (std::vector<GrDragger *>::const_iterator di = dragger->parent->draggers.begin(); di != dragger->parent->draggers.end() ; ++di) { |
929 | + GrDragger *d_new = *di; |
930 | if (dragger->mayMerge(d_new) && Geom::L2 (d_new->point - p) < snap_dist) { |
931 | |
932 | // Merge draggers: |
933 | - for (GSList const* i = dragger->draggables; i != NULL; i = i->next) { // for all draggables of dragger |
934 | - GrDraggable *draggable = (GrDraggable *) i->data; |
935 | + for (std::vector<GrDraggable *>::const_iterator i = dragger->draggables.begin(); i != dragger->draggables.end(); ++i) { |
936 | + GrDraggable *draggable = *i; |
937 | // copy draggable to d_new: |
938 | GrDraggable *da_new = new GrDraggable (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke); |
939 | d_new->addDraggable (da_new); |
940 | } |
941 | |
942 | // unlink and delete this dragger |
943 | - dragger->parent->draggers = g_list_remove (dragger->parent->draggers, dragger); |
944 | - d_new->parent->draggers = g_list_remove (d_new->parent->draggers, dragger); |
945 | - d_new->parent->selected = g_list_remove (d_new->parent->selected, dragger); |
946 | + dragger->parent->draggers.erase(std::remove(dragger->parent->draggers.begin(),dragger->parent->draggers.end(), dragger),dragger->parent->draggers.end()); |
947 | + d_new->parent->draggers.erase(std::remove(d_new->parent->draggers.begin(),d_new->parent->draggers.end(), dragger),d_new->parent->draggers.end()); |
948 | + d_new->parent->selected.erase(dragger); |
949 | delete dragger; |
950 | |
951 | // throw out delayed snap context |
952 | @@ -817,14 +816,14 @@ |
953 | unsigned snaps = abs(prefs->getInt("/options/rotationsnapsperpi/value", 12)); |
954 | /* 0 means no snapping. */ |
955 | |
956 | - for (GSList const* i = dragger->draggables; i != NULL; i = i->next) { |
957 | - GrDraggable *draggable = (GrDraggable *) i->data; |
958 | + for (std::vector<GrDraggable *>::const_iterator i = dragger->draggables.begin(); i != dragger->draggables.end(); ++i) { |
959 | + GrDraggable *draggable = *i; |
960 | |
961 | Geom::Point dr_snap(Geom::infinity(), Geom::infinity()); |
962 | |
963 | if (draggable->point_type == POINT_LG_BEGIN || draggable->point_type == POINT_LG_END) { |
964 | - for (GList *di = dragger->parent->draggers; di != NULL; di = di->next) { |
965 | - GrDragger *d_new = (GrDragger *) di->data; |
966 | + for (std::vector<GrDragger *>::const_iterator di = dragger->parent->draggers.begin() ; di != dragger->parent->draggers.end() ; ++di) { |
967 | + GrDragger *d_new = *di; |
968 | if (d_new == dragger) |
969 | continue; |
970 | if (d_new->isA (draggable->item, |
971 | @@ -842,8 +841,8 @@ |
972 | } |
973 | } |
974 | } else if (draggable->point_type == POINT_RG_R1 || draggable->point_type == POINT_RG_R2 || draggable->point_type == POINT_RG_FOCUS) { |
975 | - for (GList *di = dragger->parent->draggers; di != NULL; di = di->next) { |
976 | - GrDragger *d_new = (GrDragger *) di->data; |
977 | + for (std::vector<GrDragger *>::const_iterator di = dragger->parent->draggers.begin(); di != dragger->parent->draggers.end(); ++di) { |
978 | + GrDragger *d_new = *di; |
979 | if (d_new == dragger) |
980 | continue; |
981 | if (d_new->isA (draggable->item, |
982 | @@ -896,7 +895,7 @@ |
983 | knot->moveto(p); |
984 | } |
985 | |
986 | - drag->keep_selection = (bool) g_list_find(drag->selected, dragger); |
987 | + drag->keep_selection = (drag->selected.find(dragger)!=drag->selected.end()); |
988 | bool scale_radial = (state & GDK_CONTROL_MASK) && (state & GDK_SHIFT_MASK); |
989 | |
990 | if (drag->keep_selection) { |
991 | @@ -912,16 +911,16 @@ |
992 | } |
993 | |
994 | |
995 | -static void gr_midpoint_limits(GrDragger *dragger, SPObject *server, Geom::Point *begin, Geom::Point *end, Geom::Point *low_lim, Geom::Point *high_lim, GSList **moving) |
996 | +static void gr_midpoint_limits(GrDragger *dragger, SPObject *server, Geom::Point *begin, Geom::Point *end, Geom::Point *low_lim, Geom::Point *high_lim, std::vector<GrDragger *> &moving) |
997 | { |
998 | |
999 | GrDrag *drag = dragger->parent; |
1000 | // a midpoint dragger can (logically) only contain one GrDraggable |
1001 | - GrDraggable *draggable = (GrDraggable *) dragger->draggables->data; |
1002 | + GrDraggable *draggable = dragger->draggables[0]; |
1003 | |
1004 | // get begin and end points between which dragging is allowed: |
1005 | // the draglimits are between knot(lowest_i - 1) and knot(highest_i + 1) |
1006 | - *moving = g_slist_append(*moving, dragger); |
1007 | + moving.push_back(dragger); |
1008 | |
1009 | guint lowest_i = draggable->point_i; |
1010 | guint highest_i = draggable->point_i; |
1011 | @@ -932,9 +931,9 @@ |
1012 | while ( true ) |
1013 | { |
1014 | d_add = drag->getDraggerFor(draggable->item, draggable->point_type, lowest_i - 1, draggable->fill_or_stroke); |
1015 | - if ( d_add && g_list_find(drag->selected, d_add) ) { |
1016 | + if ( d_add && drag->selected.find(d_add)!=drag->selected.end() ) { |
1017 | lowest_i = lowest_i - 1; |
1018 | - *moving = g_slist_prepend(*moving, d_add); |
1019 | + moving.insert(moving.begin(),d_add); |
1020 | lowest_dragger = d_add; |
1021 | } else { |
1022 | break; |
1023 | @@ -944,9 +943,9 @@ |
1024 | while ( true ) |
1025 | { |
1026 | d_add = drag->getDraggerFor(draggable->item, draggable->point_type, highest_i + 1, draggable->fill_or_stroke); |
1027 | - if ( d_add && g_list_find(drag->selected, d_add) ) { |
1028 | + if ( d_add && drag->selected.find(d_add)!=drag->selected.end() ) { |
1029 | highest_i = highest_i + 1; |
1030 | - *moving = g_slist_append(*moving, d_add); |
1031 | + moving.push_back(d_add); |
1032 | highest_dragger = d_add; |
1033 | } else { |
1034 | break; |
1035 | @@ -1002,7 +1001,7 @@ |
1036 | GrDragger *dragger = (GrDragger *) data; |
1037 | GrDrag *drag = dragger->parent; |
1038 | // a midpoint dragger can (logically) only contain one GrDraggable |
1039 | - GrDraggable *draggable = (GrDraggable *) dragger->draggables->data; |
1040 | + GrDraggable *draggable = dragger->draggables[0]; |
1041 | |
1042 | // FIXME: take from prefs |
1043 | double snap_fraction = 0.1; |
1044 | @@ -1013,8 +1012,8 @@ |
1045 | |
1046 | SPObject *server = draggable->getServer(); |
1047 | |
1048 | - GSList *moving = NULL; |
1049 | - gr_midpoint_limits(dragger, server, &begin, &end, &low_lim, &high_lim, &moving); |
1050 | + std::vector<GrDragger *> moving; |
1051 | + gr_midpoint_limits(dragger, server, &begin, &end, &low_lim, &high_lim, moving); |
1052 | |
1053 | if (state & GDK_CONTROL_MASK) { |
1054 | Geom::LineSegment ls(low_lim, high_lim); |
1055 | @@ -1033,8 +1032,8 @@ |
1056 | } |
1057 | Geom::Point displacement = p - dragger->point; |
1058 | |
1059 | - for (GSList const* i = moving; i != NULL; i = i->next) { |
1060 | - GrDragger *drg = (GrDragger*) i->data; |
1061 | + for (std::vector<GrDragger *>::const_iterator i = moving.begin(); i!= moving.end(); ++i ) { |
1062 | + GrDragger *drg = *i; |
1063 | SPKnot *drgknot = drg->knot; |
1064 | Geom::Point this_move = displacement; |
1065 | if (state & GDK_MOD1_MASK) { |
1066 | @@ -1054,8 +1053,6 @@ |
1067 | drg->updateDependencies(false); |
1068 | } |
1069 | |
1070 | - g_slist_free(moving); |
1071 | - |
1072 | drag->keep_selection = dragger->isSelected(); |
1073 | } |
1074 | |
1075 | @@ -1085,12 +1082,11 @@ |
1076 | dragger->fireDraggables (true); |
1077 | } |
1078 | dragger->updateHandles( dragger->point_original, MG_NODE_NO_SCALE ); |
1079 | - |
1080 | - for (GList *i = dragger->parent->selected; i != NULL; i = i->next) { |
1081 | - GrDragger *d = (GrDragger *) i->data; |
1082 | - if (d == dragger) |
1083 | + |
1084 | + for (std::set<GrDragger *>::const_iterator it = dragger->parent->selected.begin(); it != dragger->parent->selected.end() ; ++it ) { |
1085 | + if (*it == dragger) |
1086 | continue; |
1087 | - d->fireDraggables (true); |
1088 | + (*it)->fireDraggables (true); |
1089 | } |
1090 | |
1091 | // make this dragger selected |
1092 | @@ -1112,7 +1108,7 @@ |
1093 | static void gr_knot_clicked_handler(SPKnot */*knot*/, guint state, gpointer data) |
1094 | { |
1095 | GrDragger *dragger = (GrDragger *) data; |
1096 | - GrDraggable *draggable = (GrDraggable *) dragger->draggables->data; |
1097 | + GrDraggable *draggable = dragger->draggables[0]; |
1098 | if (!draggable) return; |
1099 | |
1100 | if ( (state & GDK_CONTROL_MASK) && (state & GDK_MOD1_MASK ) ) { |
1101 | @@ -1185,7 +1181,7 @@ |
1102 | |
1103 | dragger->point_original = dragger->point; |
1104 | |
1105 | - if (dragger->draggables == NULL) |
1106 | + if (dragger->draggables.empty()) |
1107 | return; |
1108 | |
1109 | /* |
1110 | @@ -1200,8 +1196,8 @@ |
1111 | */ |
1112 | void GrDragger::fireDraggables(bool write_repr, bool scale_radial, bool merging_focus) |
1113 | { |
1114 | - for (GSList const* i = this->draggables; i != NULL; i = i->next) { |
1115 | - GrDraggable *draggable = (GrDraggable *) i->data; |
1116 | + for (std::vector<GrDraggable *>::const_iterator i = this->draggables.begin(); i != this->draggables.end(); ++i) { |
1117 | + GrDraggable *draggable = *i; |
1118 | |
1119 | // set local_change flag so that selection_changed callback does not regenerate draggers |
1120 | this->parent->local_change = true; |
1121 | @@ -1221,8 +1217,8 @@ |
1122 | */ |
1123 | bool GrDragger::isA(GrPointType point_type) |
1124 | { |
1125 | - for (GSList const* i = this->draggables; i != NULL; i = i->next) { |
1126 | - GrDraggable *draggable = reinterpret_cast<GrDraggable *>(i->data); |
1127 | + for (std::vector<GrDraggable *>::const_iterator i = this->draggables.begin(); i != this->draggables.end(); ++i) { |
1128 | + GrDraggable *draggable = *i; |
1129 | if (draggable->point_type == point_type) { |
1130 | return true; |
1131 | } |
1132 | @@ -1235,8 +1231,8 @@ |
1133 | */ |
1134 | bool GrDragger::isA(SPItem *item, GrPointType point_type, gint point_i, Inkscape::PaintTarget fill_or_stroke) |
1135 | { |
1136 | - for (GSList const* i = this->draggables; i != NULL; i = i->next) { |
1137 | - GrDraggable *draggable = (GrDraggable *) i->data; |
1138 | + for (std::vector<GrDraggable *>::const_iterator i = this->draggables.begin(); i != this->draggables.end(); ++i) { |
1139 | + GrDraggable *draggable = *i; |
1140 | if ( (draggable->point_type == point_type) && (draggable->point_i == point_i) && (draggable->item == item) && (draggable->fill_or_stroke == fill_or_stroke) ) { |
1141 | return true; |
1142 | } |
1143 | @@ -1249,8 +1245,8 @@ |
1144 | */ |
1145 | bool GrDragger::isA(SPItem *item, GrPointType point_type, Inkscape::PaintTarget fill_or_stroke) |
1146 | { |
1147 | - for (GSList const* i = this->draggables; i != NULL; i = i->next) { |
1148 | - GrDraggable *draggable = (GrDraggable *) i->data; |
1149 | + for (std::vector<GrDraggable *>::const_iterator i = this->draggables.begin(); i != this->draggables.end(); ++i) { |
1150 | + GrDraggable *draggable = *i; |
1151 | if ( (draggable->point_type == point_type) && (draggable->item == item) && (draggable->fill_or_stroke == fill_or_stroke) ) { |
1152 | return true; |
1153 | } |
1154 | @@ -1282,10 +1278,10 @@ |
1155 | if (this == other) |
1156 | return false; |
1157 | |
1158 | - for (GSList const* i = this->draggables; i != NULL; i = i->next) { // for all draggables of this |
1159 | - GrDraggable *da1 = (GrDraggable *) i->data; |
1160 | - for (GSList const* j = other->draggables; j != NULL; j = j->next) { // for all draggables of other |
1161 | - GrDraggable *da2 = (GrDraggable *) j->data; |
1162 | + for (std::vector<GrDraggable *>::const_iterator i = this->draggables.begin(); i != this->draggables.end(); ++i) { |
1163 | + GrDraggable *da1 = *i; |
1164 | + for (std::vector<GrDraggable *>::const_iterator j = other->draggables.begin(); j != other->draggables.end(); ++j) { |
1165 | + GrDraggable *da2 = *j; |
1166 | if (!da1->mayMerge(da2)) |
1167 | return false; |
1168 | } |
1169 | @@ -1295,8 +1291,8 @@ |
1170 | |
1171 | bool GrDragger::mayMerge(GrDraggable *da2) |
1172 | { |
1173 | - for (GSList const* i = this->draggables; i != NULL; i = i->next) { // for all draggables of this |
1174 | - GrDraggable *da1 = (GrDraggable *) i->data; |
1175 | + for (std::vector<GrDraggable *>::const_iterator i = this->draggables.begin(); i != this->draggables.end(); ++i) { |
1176 | + GrDraggable *da1 = *i; |
1177 | if (!da1->mayMerge(da2)) |
1178 | return false; |
1179 | } |
1180 | @@ -1339,10 +1335,10 @@ |
1181 | bool scale = false; |
1182 | if( scale == true ) { |
1183 | |
1184 | - for ( GList *i = drag->selected; i != NULL; i = i->next ) { |
1185 | - GrDragger *dragger = (GrDragger *) i->data; |
1186 | - for ( GSList *j = dragger->draggables; j != NULL; j = j->next ) { |
1187 | - GrDraggable *draggable = (GrDraggable *) j->data; |
1188 | + for( std::set<GrDragger *>::const_iterator it = drag->selected.begin(); it != drag->selected.end(); ++it ) { |
1189 | + GrDragger *dragger = *it; |
1190 | + for (std::vector<GrDraggable *>::const_iterator it2 = dragger->draggables.begin(); it2 != dragger->draggables.end(); ++it2 ) { |
1191 | + GrDraggable *draggable = *it2; |
1192 | |
1193 | // Check draggable is of type POINT_MG_CORNER (don't allow selection of POINT_MG_HANDLE) |
1194 | if( draggable->point_type != POINT_MG_CORNER ) continue; |
1195 | @@ -1360,8 +1356,8 @@ |
1196 | |
1197 | // Loop over all draggables in moved corner |
1198 | std::map<SPGradient*, std::vector<guint> > dragger_corners; |
1199 | - for ( GSList *j = draggables; j != NULL; j = j->next ) { |
1200 | - GrDraggable *draggable = (GrDraggable *) j->data; |
1201 | + for (std::vector<GrDraggable *>::const_iterator j = draggables.begin(); j != draggables.end(); ++j ) { |
1202 | + GrDraggable *draggable = *j; |
1203 | |
1204 | SPItem *item = draggable->item; |
1205 | gint point_type = draggable->point_type; |
1206 | @@ -1417,8 +1413,8 @@ |
1207 | this->knot->tip = NULL; |
1208 | } |
1209 | |
1210 | - if (g_slist_length (this->draggables) == 1) { |
1211 | - GrDraggable *draggable = (GrDraggable *) this->draggables->data; |
1212 | + if (this->draggables.size() == 1) { |
1213 | + GrDraggable *draggable = this->draggables[0]; |
1214 | char *item_desc = draggable->item->detailedDescription(); |
1215 | switch (draggable->point_type) { |
1216 | case POINT_LG_MID: |
1217 | @@ -1439,10 +1435,10 @@ |
1218 | break; |
1219 | } |
1220 | g_free(item_desc); |
1221 | - } else if (g_slist_length (draggables) == 2 && isA (POINT_RG_CENTER) && isA (POINT_RG_FOCUS)) { |
1222 | + } else if (draggables.size() == 2 && isA (POINT_RG_CENTER) && isA (POINT_RG_FOCUS)) { |
1223 | this->knot->tip = g_strdup_printf ("%s", _("Radial gradient <b>center</b> and <b>focus</b>; drag with <b>Shift</b> to separate focus")); |
1224 | } else { |
1225 | - int length = g_slist_length (this->draggables); |
1226 | + int length = this->draggables.size(); |
1227 | this->knot->tip = g_strdup_printf (ngettext("Gradient point shared by <b>%d</b> gradient; drag with <b>Shift</b> to separate", |
1228 | "Gradient point shared by <b>%d</b> gradients; drag with <b>Shift</b> to separate", |
1229 | length), |
1230 | @@ -1455,9 +1451,9 @@ |
1231 | */ |
1232 | void GrDragger::updateKnotShape() |
1233 | { |
1234 | - if (!draggables) |
1235 | + if (draggables.empty()) |
1236 | return; |
1237 | - GrDraggable *last = (GrDraggable *) g_slist_last(draggables)->data; |
1238 | + GrDraggable *last = draggables.back(); |
1239 | g_object_set (G_OBJECT (this->knot->item), "shape", gr_knot_shapes[last->point_type], NULL); |
1240 | } |
1241 | |
1242 | @@ -1466,7 +1462,7 @@ |
1243 | */ |
1244 | void GrDragger::addDraggable(GrDraggable *draggable) |
1245 | { |
1246 | - this->draggables = g_slist_prepend (this->draggables, draggable); |
1247 | + this->draggables.insert(this->draggables.begin(), draggable); |
1248 | |
1249 | this->updateTip(); |
1250 | } |
1251 | @@ -1477,18 +1473,18 @@ |
1252 | */ |
1253 | void GrDragger::moveThisToDraggable(SPItem *item, GrPointType point_type, gint point_i, Inkscape::PaintTarget fill_or_stroke, bool write_repr) |
1254 | { |
1255 | - GrDraggable *dr_first = reinterpret_cast<GrDraggable *>(draggables->data); |
1256 | - if (!dr_first) { |
1257 | + if (draggables.empty()) |
1258 | return; |
1259 | - } |
1260 | + |
1261 | + GrDraggable *dr_first = draggables[0]; |
1262 | |
1263 | this->point = getGradientCoords(dr_first->item, dr_first->point_type, dr_first->point_i, dr_first->fill_or_stroke); |
1264 | this->point_original = this->point; |
1265 | |
1266 | this->knot->moveto(this->point); |
1267 | |
1268 | - for (GSList const* i = draggables; i != NULL; i = i->next) { |
1269 | - GrDraggable *da = (GrDraggable *) i->data; |
1270 | + for (std::vector<GrDraggable *>::const_iterator j = draggables.begin(); j != draggables.end(); ++j ) { |
1271 | + GrDraggable *da = *j; |
1272 | if ( (da->item == item) && |
1273 | (point_type == -1 || da->point_type == point_type) && |
1274 | (point_i == -1 || da->point_i == point_i) && |
1275 | @@ -1531,8 +1527,8 @@ |
1276 | */ |
1277 | void GrDragger::updateDependencies(bool write_repr) |
1278 | { |
1279 | - for (GSList const* i = this->draggables; i != NULL; i = i->next) { |
1280 | - GrDraggable *draggable = (GrDraggable *) i->data; |
1281 | + for (std::vector<GrDraggable *>::const_iterator j = draggables.begin(); j != draggables.end(); ++j ) { |
1282 | + GrDraggable *draggable = *j; |
1283 | switch (draggable->point_type) { |
1284 | case POINT_LG_BEGIN: |
1285 | { |
1286 | @@ -1590,7 +1586,7 @@ |
1287 | : point(p), |
1288 | point_original(p) |
1289 | { |
1290 | - this->draggables = NULL; |
1291 | + this->draggables.clear(); |
1292 | |
1293 | this->parent = parent; |
1294 | |
1295 | @@ -1649,12 +1645,10 @@ |
1296 | knot_unref(this->knot); |
1297 | |
1298 | // delete all draggables |
1299 | - for (GSList const* i = this->draggables; i != NULL; i = i->next) { |
1300 | - delete ((GrDraggable *) i->data); |
1301 | + for (std::vector<GrDraggable *>::const_iterator j = this->draggables.begin(); j != this->draggables.end(); ++j ) { |
1302 | + delete (*j); |
1303 | } |
1304 | - |
1305 | - g_slist_free (this->draggables); |
1306 | - this->draggables = NULL; |
1307 | + this->draggables.clear(); |
1308 | } |
1309 | |
1310 | /** |
1311 | @@ -1662,10 +1656,10 @@ |
1312 | */ |
1313 | GrDragger *GrDrag::getDraggerFor(SPItem *item, GrPointType point_type, gint point_i, Inkscape::PaintTarget fill_or_stroke) |
1314 | { |
1315 | - for (GList const* i = this->draggers; i != NULL; i = i->next) { |
1316 | - GrDragger *dragger = (GrDragger *) i->data; |
1317 | - for (GSList const* j = dragger->draggables; j != NULL; j = j->next) { |
1318 | - GrDraggable *da2 = (GrDraggable *) j->data; |
1319 | + for (std::vector<GrDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i ) { |
1320 | + GrDragger *dragger = *i; |
1321 | + for (std::vector<GrDraggable *>::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end(); ++j ) { |
1322 | + GrDraggable *da2 = *j; |
1323 | if ( (da2->item == item) && |
1324 | (point_type == -1 || da2->point_type == point_type) && // -1 means this does not matter |
1325 | (point_i == -1 || da2->point_i == point_i) && // -1 means this does not matter |
1326 | @@ -1716,7 +1710,7 @@ |
1327 | bool |
1328 | GrDragger::isSelected() |
1329 | { |
1330 | - return g_list_find (parent->selected, this); |
1331 | + return parent->selected.find(this) != parent->selected.end(); |
1332 | } |
1333 | |
1334 | /** |
1335 | @@ -1724,10 +1718,9 @@ |
1336 | */ |
1337 | void GrDrag::deselect_all() |
1338 | { |
1339 | - while (selected) { |
1340 | - ( (GrDragger*) selected->data)->deselect(); |
1341 | - selected = g_list_remove(selected, selected->data); |
1342 | - } |
1343 | + for (std::set<GrDragger *>::const_iterator it = selected.begin(); it != selected.end(); ++it ) |
1344 | + (*it)->deselect(); |
1345 | + selected.clear(); |
1346 | } |
1347 | |
1348 | /** |
1349 | @@ -1744,8 +1737,8 @@ |
1350 | */ |
1351 | void GrDrag::selectAll() |
1352 | { |
1353 | - for (GList *l = this->draggers; l != NULL; l = l->next) { |
1354 | - GrDragger *d = ((GrDragger *) l->data); |
1355 | + for (std::vector<GrDragger *>::const_iterator l = this->draggers.begin(); l != this->draggers.end(); ++l) { |
1356 | + GrDragger *d = *l; |
1357 | setSelected (d, true, true); |
1358 | } |
1359 | } |
1360 | @@ -1755,8 +1748,8 @@ |
1361 | */ |
1362 | void GrDrag::selectByCoords(std::vector<Geom::Point> coords) |
1363 | { |
1364 | - for (GList *l = this->draggers; l != NULL; l = l->next) { |
1365 | - GrDragger *d = ((GrDragger *) l->data); |
1366 | + for (std::vector<GrDragger *>::const_iterator l = this->draggers.begin(); l != this->draggers.end(); ++l) { |
1367 | + GrDragger *d = *l; |
1368 | for (guint k = 0; k < coords.size(); k++) { |
1369 | if (Geom::L2 (d->point - coords[k]) < 1e-4) { |
1370 | setSelected (d, true, true); |
1371 | @@ -1770,12 +1763,12 @@ |
1372 | */ |
1373 | void GrDrag::selectByStop(SPStop *stop, bool add_to_selection, bool override ) |
1374 | { |
1375 | - for (GList *i = this->draggers; i != NULL; i = i->next) { |
1376 | - |
1377 | - GrDragger *dragger = (GrDragger *) i->data; |
1378 | - for (GSList const* j = dragger->draggables; j != NULL; j = j->next) { |
1379 | - |
1380 | - GrDraggable *d = (GrDraggable *) j->data; |
1381 | + for (std::vector<GrDragger *>::const_iterator l = this->draggers.begin(); l != this->draggers.end(); ++l) { |
1382 | + |
1383 | + GrDragger *dragger = *l; |
1384 | + for (std::vector<GrDraggable *>::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end(); ++j) { |
1385 | + |
1386 | + GrDraggable *d = *j; |
1387 | SPGradient *gradient = getGradient(d->item, d->fill_or_stroke); |
1388 | SPGradient *vector = gradient->getVector(false); |
1389 | SPStop *stop_i = sp_get_stop_i(vector, d->point_i); |
1390 | @@ -1791,8 +1784,8 @@ |
1391 | */ |
1392 | void GrDrag::selectRect(Geom::Rect const &r) |
1393 | { |
1394 | - for (GList *l = this->draggers; l != NULL; l = l->next) { |
1395 | - GrDragger *d = ((GrDragger *) l->data); |
1396 | + for (std::vector<GrDragger *>::const_iterator l = this->draggers.begin(); l != this->draggers.end(); ++l) { |
1397 | + GrDragger *d = *l; |
1398 | if (r.contains(d->point)) { |
1399 | setSelected (d, true, true); |
1400 | } |
1401 | @@ -1816,20 +1809,18 @@ |
1402 | if (add_to_selection) { |
1403 | if (!dragger) return; |
1404 | if (override) { |
1405 | - if (!g_list_find(selected, dragger)) { |
1406 | - selected = g_list_prepend(selected, dragger); |
1407 | - } |
1408 | + selected.insert(dragger); |
1409 | dragger->select(); |
1410 | seldragger = dragger; |
1411 | } else { // toggle |
1412 | - if (g_list_find(selected, dragger)) { |
1413 | - selected = g_list_remove(selected, dragger); |
1414 | + if(selected.find(dragger)!=selected.end()) { |
1415 | + selected.erase(dragger); |
1416 | dragger->deselect(); |
1417 | - if (selected) { |
1418 | - seldragger = (GrDragger*) selected->data; // select the dragger that is first in the list |
1419 | + if (!selected.empty()) { |
1420 | + seldragger = *(selected.begin()); // select the dragger that is first in the list |
1421 | } |
1422 | } else { |
1423 | - selected = g_list_prepend(selected, dragger); |
1424 | + selected.insert(dragger); |
1425 | dragger->select(); |
1426 | seldragger = dragger; |
1427 | } |
1428 | @@ -1837,7 +1828,7 @@ |
1429 | } else { |
1430 | deselect_all(); |
1431 | if (dragger) { |
1432 | - selected = g_list_prepend(selected, dragger); |
1433 | + selected.insert(dragger); |
1434 | dragger->select(); |
1435 | seldragger = dragger; |
1436 | } |
1437 | @@ -1853,11 +1844,11 @@ |
1438 | */ |
1439 | void GrDrag::setDeselected(GrDragger *dragger) |
1440 | { |
1441 | - if (g_list_find(selected, dragger)) { |
1442 | - selected = g_list_remove(selected, dragger); |
1443 | + if (selected.find(dragger) != selected.end()) { |
1444 | + selected.erase(dragger); |
1445 | dragger->deselect(); |
1446 | } |
1447 | - this->desktop->emitToolSubselectionChanged((gpointer) (selected ? selected->data : NULL )); |
1448 | + this->desktop->emitToolSubselectionChanged((gpointer) (selected.empty() ? NULL :*(selected.begin()))); |
1449 | } |
1450 | |
1451 | |
1452 | @@ -1873,7 +1864,7 @@ |
1453 | sp_canvas_item_move_to_z(line, 0); |
1454 | line->item = item; |
1455 | sp_canvas_item_show(line); |
1456 | - this->lines = g_slist_append(this->lines, line); |
1457 | + this->lines.push_back(line); |
1458 | } |
1459 | |
1460 | |
1461 | @@ -1889,7 +1880,7 @@ |
1462 | sp_canvas_item_move_to_z(line, 0); |
1463 | line->item = item; |
1464 | sp_canvas_item_show (line); |
1465 | - this->lines = g_slist_append (this->lines, line); |
1466 | + this->lines.push_back(line); |
1467 | } |
1468 | |
1469 | |
1470 | @@ -1901,8 +1892,8 @@ |
1471 | { |
1472 | Geom::Point p = getGradientCoords(draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke); |
1473 | |
1474 | - for (GList *i = this->draggers; i != NULL; i = i->next) { |
1475 | - GrDragger *dragger = (GrDragger *) i->data; |
1476 | + for (std::vector<GrDragger *>::const_iterator l = this->draggers.begin(); l != this->draggers.end(); ++l) { |
1477 | + GrDragger *dragger = *l; |
1478 | if (dragger->mayMerge (draggable) && Geom::L2 (dragger->point - p) < MERGE_DIST) { |
1479 | // distance is small, merge this draggable into dragger, no need to create new dragger |
1480 | dragger->addDraggable (draggable); |
1481 | @@ -1913,7 +1904,7 @@ |
1482 | |
1483 | GrDragger *new_dragger = new GrDragger(this, p, draggable); |
1484 | // fixme: draggers should be added AFTER the last one: this way tabbing through them will be from begin to end. |
1485 | - this->draggers = g_list_append (this->draggers, new_dragger); |
1486 | + this->draggers.push_back(new_dragger); |
1487 | } |
1488 | |
1489 | /** |
1490 | @@ -2071,15 +2062,12 @@ |
1491 | */ |
1492 | void GrDrag::updateDraggers() |
1493 | { |
1494 | - while (selected) { |
1495 | - selected = g_list_remove(selected, selected->data); |
1496 | - } |
1497 | + selected.clear(); |
1498 | // delete old draggers |
1499 | - for (GList const* i = this->draggers; i != NULL; i = i->next) { |
1500 | - delete static_cast<GrDragger *>(i->data); |
1501 | + for (std::vector<GrDragger *>::const_iterator l = this->draggers.begin(); l != this->draggers.end(); ++l) { |
1502 | + delete (*l); |
1503 | } |
1504 | - g_list_free(this->draggers); |
1505 | - this->draggers = NULL; |
1506 | + this->draggers.clear(); |
1507 | |
1508 | g_return_if_fail(this->selection != NULL); |
1509 | std::vector<SPItem*> list = this->selection->itemList(); |
1510 | @@ -2127,8 +2115,8 @@ |
1511 | */ |
1512 | bool GrDrag::mouseOver() |
1513 | { |
1514 | - for (GList const* i = this->draggers; i != NULL; i = i->next) { |
1515 | - GrDragger *d = (GrDragger *) i->data; |
1516 | + for (std::vector<GrDragger *>::const_iterator l = this->draggers.begin(); l != this->draggers.end(); ++l) { |
1517 | + GrDragger *d = *l; |
1518 | if (d->knot && (d->knot->flags & SP_KNOT_MOUSEOVER)) { |
1519 | return true; |
1520 | } |
1521 | @@ -2143,11 +2131,10 @@ |
1522 | void GrDrag::updateLines() |
1523 | { |
1524 | // delete old lines |
1525 | - for (GSList const *i = this->lines; i != NULL; i = i->next) { |
1526 | - sp_canvas_item_destroy(SP_CANVAS_ITEM(i->data)); |
1527 | + for (std::vector<SPCtrlLine *>::const_iterator i = this->lines.begin(); i != this->lines.end(); ++i) { |
1528 | + sp_canvas_item_destroy(SP_CANVAS_ITEM(*i)); |
1529 | } |
1530 | - g_slist_free(this->lines); |
1531 | - this->lines = NULL; |
1532 | + this->lines.clear(); |
1533 | |
1534 | g_return_if_fail(this->selection != NULL); |
1535 | |
1536 | @@ -2313,13 +2300,11 @@ |
1537 | |
1538 | void GrDrag::selected_reverse_vector() |
1539 | { |
1540 | - if (selected == NULL) |
1541 | + if (selected.empty()) |
1542 | return; |
1543 | |
1544 | - for (GSList const* i = ( (GrDragger*) selected->data )->draggables; i != NULL; i = i->next) { |
1545 | - GrDraggable *draggable = (GrDraggable *) i->data; |
1546 | - |
1547 | - sp_item_gradient_reverse_vector (draggable->item, draggable->fill_or_stroke); |
1548 | + for(std::vector<GrDraggable *>::const_iterator it = (*(selected.begin()))->draggables.begin(); it != (*(selected.begin()))->draggables.end(); ++it) { |
1549 | + sp_item_gradient_reverse_vector ((*it)->item, (*it)->fill_or_stroke); |
1550 | } |
1551 | } |
1552 | |
1553 | @@ -2330,13 +2315,13 @@ |
1554 | |
1555 | void GrDrag::selected_move(double x, double y, bool write_repr, bool scale_radial) |
1556 | { |
1557 | - if (selected == NULL) |
1558 | + if (selected.empty()) |
1559 | return; |
1560 | |
1561 | bool did = false; |
1562 | |
1563 | - for (GList *i = selected; i != NULL; i = i->next) { |
1564 | - GrDragger *d = (GrDragger *) i->data; |
1565 | + for(std::set<GrDragger *>::const_iterator it = selected.begin(); it != selected.end(); ++it) { |
1566 | + GrDragger *d = *it; |
1567 | |
1568 | if (!d->isA(POINT_LG_MID) && !d->isA(POINT_RG_MID1) && !d->isA(POINT_RG_MID2)) { |
1569 | // if this is an endpoint, |
1570 | @@ -2347,12 +2332,12 @@ |
1571 | if (d->isA(POINT_RG_R1) || d->isA(POINT_RG_R2) || |
1572 | (d->isA(POINT_RG_FOCUS) && !d->isA(POINT_RG_CENTER))) { |
1573 | bool skip_radius_with_center = false; |
1574 | - for (GList *di = selected; di != NULL; di = di->next) { |
1575 | - GrDragger *d_new = (GrDragger *) di->data; |
1576 | - if (d_new->isA (((GrDraggable *) d->draggables->data)->item, |
1577 | + for(std::set<GrDragger *>::const_iterator di = selected.begin(); di != selected.end(); ++di) { |
1578 | + GrDragger *d_new = *di; |
1579 | + if (d_new->isA (( d->draggables[0])->item, |
1580 | POINT_RG_CENTER, |
1581 | 0, |
1582 | - ((GrDraggable *) d->draggables->data)->fill_or_stroke)) { |
1583 | + (d->draggables[0])->fill_or_stroke)) { |
1584 | // FIXME: here we take into account only the first draggable! |
1585 | skip_radius_with_center = true; |
1586 | } |
1587 | @@ -2382,23 +2367,23 @@ |
1588 | |
1589 | if (!did) { // none of the end draggers are selected, so let's try to move the mids |
1590 | |
1591 | - GrDragger *dragger = (GrDragger *) selected->data; |
1592 | + GrDragger *dragger = *(selected.begin()); |
1593 | // a midpoint dragger can (logically) only contain one GrDraggable |
1594 | - GrDraggable *draggable = (GrDraggable *) dragger->draggables->data; |
1595 | + GrDraggable *draggable = dragger->draggables[0]; |
1596 | |
1597 | Geom::Point begin(0,0), end(0,0); |
1598 | Geom::Point low_lim(0,0), high_lim(0,0); |
1599 | |
1600 | SPObject *server = draggable->getServer(); |
1601 | - GSList *moving = NULL; |
1602 | - gr_midpoint_limits(dragger, server, &begin, &end, &low_lim, &high_lim, &moving); |
1603 | + std::vector<GrDragger *> moving; |
1604 | + gr_midpoint_limits(dragger, server, &begin, &end, &low_lim, &high_lim, moving); |
1605 | |
1606 | Geom::LineSegment ls(low_lim, high_lim); |
1607 | Geom::Point p = ls.pointAt(ls.nearestTime(dragger->point + Geom::Point(x,y))); |
1608 | Geom::Point displacement = p - dragger->point; |
1609 | |
1610 | - for (GSList const* i = moving; i != NULL; i = i->next) { |
1611 | - GrDragger *drg = (GrDragger*) i->data; |
1612 | + for(std::vector<GrDragger *>::const_iterator i = moving.begin(); i!= moving.end();++i) { |
1613 | + GrDragger *drg = *i; |
1614 | SPKnot *drgknot = drg->knot; |
1615 | drg->point += displacement; |
1616 | drgknot->moveto(drg->point); |
1617 | @@ -2407,8 +2392,6 @@ |
1618 | did = true; |
1619 | } |
1620 | |
1621 | - g_slist_free(moving); |
1622 | - |
1623 | if (write_repr && did) { |
1624 | // we did an undoable action |
1625 | DocumentUndo::maybeDone(desktop->getDocument(), "grmovem", SP_VERB_CONTEXT_GRADIENT, |
1626 | @@ -2432,11 +2415,11 @@ |
1627 | GrDragger *GrDrag::select_next() |
1628 | { |
1629 | GrDragger *d = NULL; |
1630 | - if (selected == NULL || g_list_find(draggers, selected->data)->next == NULL) { |
1631 | - if (draggers) |
1632 | - d = (GrDragger *) draggers->data; |
1633 | + if (selected.empty() || (++find(draggers.begin(),draggers.end(),*(selected.begin())))==draggers.end()) { |
1634 | + if (!draggers.empty()) |
1635 | + d = draggers[0]; |
1636 | } else { |
1637 | - d = (GrDragger *) g_list_find(draggers, selected->data)->next->data; |
1638 | + d = *(++find(draggers.begin(),draggers.end(),*(selected.begin()))); |
1639 | } |
1640 | if (d) |
1641 | setSelected (d); |
1642 | @@ -2449,11 +2432,11 @@ |
1643 | GrDragger *GrDrag::select_prev() |
1644 | { |
1645 | GrDragger *d = NULL; |
1646 | - if (selected == NULL || g_list_find(draggers, selected->data)->prev == NULL) { |
1647 | - if (draggers) |
1648 | - d = (GrDragger *) g_list_last (draggers)->data; |
1649 | + if (selected.empty() || draggers[0] == (*(selected.begin()))) { |
1650 | + if (!draggers.empty()) |
1651 | + d = draggers[draggers.size()-1]; |
1652 | } else { |
1653 | - d = (GrDragger *) g_list_find(draggers, selected->data)->prev->data; |
1654 | + d = *(--find(draggers.begin(),draggers.end(),*(selected.begin()))); |
1655 | } |
1656 | if (d) |
1657 | setSelected (d); |
1658 | @@ -2464,7 +2447,7 @@ |
1659 | // FIXME: i.m.o. an ugly function that I just made to work, but... aargh! (Johan) |
1660 | void GrDrag::deleteSelected(bool just_one) |
1661 | { |
1662 | - if (!selected) return; |
1663 | + if (selected.empty()) return; |
1664 | |
1665 | SPDocument *document = NULL; |
1666 | |
1667 | @@ -2477,10 +2460,10 @@ |
1668 | |
1669 | GSList *midstoplist = NULL; // list of stops that must be deleted (will be deleted first) |
1670 | GSList *endstoplist = NULL; // list of stops that must be deleted |
1671 | - while (selected) { |
1672 | - GrDragger *dragger = (GrDragger*) selected->data; |
1673 | - for (GSList * drgble = dragger->draggables; drgble != NULL; drgble = drgble->next) { |
1674 | - GrDraggable *draggable = (GrDraggable*) drgble->data; |
1675 | + while (!selected.empty()) { |
1676 | + GrDragger *dragger = *(selected.begin()); |
1677 | + for(std::vector<GrDraggable *>::const_iterator drgble = dragger->draggables.begin(); drgble != dragger->draggables.end(); ++drgble) { |
1678 | + GrDraggable *draggable = *drgble; |
1679 | SPGradient *gradient = getGradient(draggable->item, draggable->fill_or_stroke); |
1680 | SPGradient *vector = sp_gradient_get_forked_vector_if_necessary (gradient, false); |
1681 | |
1682 | @@ -2538,7 +2521,7 @@ |
1683 | break; |
1684 | } |
1685 | } |
1686 | - selected = g_list_remove(selected, dragger); |
1687 | + selected.erase(dragger); |
1688 | if ( just_one ) break; // iterate once if just_one is set. |
1689 | } |
1690 | while (midstoplist) { |
1691 | |
1692 | === modified file 'src/gradient-drag.h' |
1693 | --- src/gradient-drag.h 2015-03-01 08:57:53 +0000 |
1694 | +++ src/gradient-drag.h 2015-12-09 15:31:04 +0000 |
1695 | @@ -20,6 +20,7 @@ |
1696 | #include <stddef.h> |
1697 | #include <sigc++/sigc++.h> |
1698 | #include <vector> |
1699 | +#include <set> |
1700 | #include <glib.h> |
1701 | #include <glibmm/ustring.h> |
1702 | |
1703 | @@ -86,7 +87,7 @@ |
1704 | // position of the knot before it began to drag; updated when released |
1705 | Geom::Point point_original; |
1706 | |
1707 | - GSList *draggables; |
1708 | + std::vector<GrDraggable *> draggables; |
1709 | |
1710 | void addDraggable(GrDraggable *draggable); |
1711 | |
1712 | @@ -123,6 +124,7 @@ |
1713 | sigc::connection _ungrabbed_connection; |
1714 | }; |
1715 | |
1716 | +struct SPCtrlLine; |
1717 | /** |
1718 | This is the root class of the gradient dragging machinery. It holds lists of GrDraggers |
1719 | and of lines (simple canvas items). It also remembers one of the draggers as selected. |
1720 | @@ -133,20 +135,21 @@ |
1721 | GrDrag(SPDesktop *desktop); |
1722 | virtual ~GrDrag(); |
1723 | |
1724 | - bool isNonEmpty() {return (draggers != NULL);} |
1725 | - bool hasSelection() {return (selected != NULL);} |
1726 | - guint numSelected() {return (selected? g_list_length(selected) : 0);} |
1727 | - guint numDraggers() {return (draggers? g_list_length(draggers) : 0);} |
1728 | + bool isNonEmpty() {return !draggers.empty();} |
1729 | + bool hasSelection() {return !selected.empty();} |
1730 | + guint numSelected() {return selected.size();} |
1731 | + guint numDraggers() {return draggers.size();} |
1732 | |
1733 | guint singleSelectedDraggerNumDraggables() { |
1734 | - return (selected? g_slist_length(( static_cast<GrDragger *>(selected->data))->draggables) : 0); |
1735 | + return (selected.empty()? 0 : (*(selected.begin()))->draggables.size() ); |
1736 | } |
1737 | |
1738 | guint singleSelectedDraggerSingleDraggableType() { |
1739 | - return (selected? (static_cast<GrDraggable*>((static_cast<GrDragger*>(selected->data))->draggables->data))->point_type : 0);} |
1740 | + return (selected.empty() ? 0 : ((*(selected.begin()))->draggables[0]->point_type)); |
1741 | + } |
1742 | |
1743 | // especially the selection must be private, fix gradient-context to remove direct access to it |
1744 | - GList *selected; // list of GrDragger* |
1745 | + std::set<GrDragger *> selected; // list of GrDragger* |
1746 | void setSelected(GrDragger *dragger, bool add_to_selection = false, bool override = true); |
1747 | void setDeselected(GrDragger *dragger); |
1748 | void deselectAll(); |
1749 | @@ -178,8 +181,8 @@ |
1750 | std::vector<double> hor_levels; |
1751 | std::vector<double> vert_levels; |
1752 | |
1753 | - GList *draggers; |
1754 | - GSList *lines; |
1755 | + std::vector<GrDragger *> draggers; |
1756 | + std::vector<SPCtrlLine *> lines; |
1757 | |
1758 | void updateDraggers(); |
1759 | void updateLines(); |
1760 | |
1761 | === modified file 'src/graphlayout.cpp' |
1762 | --- src/graphlayout.cpp 2015-11-13 17:53:22 +0000 |
1763 | +++ src/graphlayout.cpp 2015-12-09 15:31:04 +0000 |
1764 | @@ -106,7 +106,6 @@ |
1765 | return; |
1766 | } |
1767 | |
1768 | - using Inkscape::Util::GSListIterator; |
1769 | list<SPItem *> selected; |
1770 | filterConnectors(items,selected); |
1771 | if (selected.empty()) return; |
1772 | @@ -164,10 +163,11 @@ |
1773 | continue; |
1774 | } |
1775 | unsigned u=i_iter->second; |
1776 | - GSList *nlist=iu->avoidRef->getAttachedConnectors(Avoid::runningFrom); |
1777 | + std::vector<SPItem *> nlist=iu->avoidRef->getAttachedConnectors(Avoid::runningFrom); |
1778 | list<SPItem *> connectors; |
1779 | |
1780 | - connectors.insert<GSListIterator<SPItem *> >(connectors.end(),nlist,NULL); |
1781 | + connectors.insert(connectors.end(), nlist.begin(), nlist.end()); |
1782 | + |
1783 | for (list<SPItem *>::iterator j(connectors.begin()); |
1784 | j != connectors.end(); |
1785 | ++j) { |
1786 | @@ -203,9 +203,6 @@ |
1787 | } |
1788 | } |
1789 | } |
1790 | - if(nlist) { |
1791 | - g_slist_free(nlist); |
1792 | - } |
1793 | } |
1794 | const unsigned E = es.size(); |
1795 | double eweights[E]; |
1796 | |
1797 | === modified file 'src/graphlayout.h' |
1798 | --- src/graphlayout.h 2015-02-19 03:25:21 +0000 |
1799 | +++ src/graphlayout.h 2015-12-09 15:31:04 +0000 |
1800 | @@ -16,7 +16,6 @@ |
1801 | |
1802 | #include <list> |
1803 | |
1804 | -typedef struct _GSList GSList; |
1805 | class SPItem; |
1806 | |
1807 | void graphlayout(std::vector<SPItem*> const &items); |
1808 | |
1809 | === modified file 'src/guide-snapper.cpp' |
1810 | --- src/guide-snapper.cpp 2014-10-04 01:32:26 +0000 |
1811 | +++ src/guide-snapper.cpp 2015-12-09 15:31:04 +0000 |
1812 | @@ -44,11 +44,10 @@ |
1813 | } |
1814 | |
1815 | SPGuide const *guide_to_ignore = _snapmanager->getGuideToIgnore(); |
1816 | - |
1817 | - for (GSList const *l = _snapmanager->getNamedView()->guides; l != NULL; l = l->next) { |
1818 | - SPGuide const *g = SP_GUIDE(l->data); |
1819 | - if (g != guide_to_ignore) { |
1820 | - s.push_back(std::pair<Geom::Point, Geom::Point>(g->getNormal(), g->getPoint())); |
1821 | + std::vector<SPGuide *> guides = _snapmanager->getNamedView()->guides; |
1822 | + for(std::vector<SPGuide *>::const_iterator it = guides.begin() ; it != guides.end(); ++it) { |
1823 | + if ((*it) != guide_to_ignore) { |
1824 | + s.push_back(std::pair<Geom::Point, Geom::Point>((*it)->getNormal(), (*it)->getPoint())); |
1825 | } |
1826 | } |
1827 | |
1828 | |
1829 | === modified file 'src/layer-manager.cpp' |
1830 | --- src/layer-manager.cpp 2015-02-26 02:49:35 +0000 |
1831 | +++ src/layer-manager.cpp 2015-12-09 15:31:04 +0000 |
1832 | @@ -191,15 +191,12 @@ |
1833 | } |
1834 | |
1835 | std::set<Glib::ustring> currentNames; |
1836 | - GSList const *layers=_document->getResourceList("layer"); |
1837 | + std::set<SPObject *> layers = _document->getResourceList("layer"); |
1838 | SPObject *root=_desktop->currentRoot(); |
1839 | if ( root ) { |
1840 | - for ( GSList const *iter=layers ; iter ; iter = iter->next ) { |
1841 | - SPObject *layer=static_cast<SPObject *>(iter->data); |
1842 | - if ( layer != obj ) { |
1843 | - currentNames.insert( layer->label() ? Glib::ustring(layer->label()) : Glib::ustring() ); |
1844 | - } |
1845 | - } |
1846 | + std::set<SPObject *>::iterator iter = layers.find(obj); |
1847 | + if (iter != layers.end()) |
1848 | + currentNames.insert( (*iter)->label() ? Glib::ustring((*iter)->label()) : Glib::ustring() ); |
1849 | } |
1850 | |
1851 | // Not sure if we need to cap it, but we'll just be paranoid for the moment |
1852 | @@ -262,15 +259,16 @@ |
1853 | if (!_document) // http://sourceforge.net/mailarchive/forum.php?thread_name=5747bce9a7ed077c1b4fc9f0f4f8a5e0%40localhost&forum_name=inkscape-devel |
1854 | return; |
1855 | |
1856 | - GSList const *layers = _document->getResourceList("layer"); |
1857 | + std::set<SPObject *> layers = _document->getResourceList("layer"); |
1858 | + |
1859 | SPObject *root=_desktop->currentRoot(); |
1860 | if ( root ) { |
1861 | _addOne(root); |
1862 | |
1863 | std::set<SPGroup*> layersToAdd; |
1864 | |
1865 | - for ( GSList const *iter = layers; iter; iter = iter->next ) { |
1866 | - SPObject *layer = static_cast<SPObject *>(iter->data); |
1867 | + for ( std::set<SPObject *>::const_iterator iter = layers.begin(); iter != layers.end(); ++iter ) { |
1868 | + SPObject *layer = *iter; |
1869 | // Debug::EventTracker<DebugLayerNote> tracker(Util::format("Examining %s", layer->label())); |
1870 | bool needsAdd = false; |
1871 | std::set<SPGroup*> additional; |
1872 | @@ -282,7 +280,7 @@ |
1873 | SPGroup* group = SP_GROUP(curr); |
1874 | if ( group->layerMode() == SPGroup::LAYER ) { |
1875 | // If we have a layer-group as the one or a parent, ensure it is listed as a valid layer. |
1876 | - needsAdd &= ( g_slist_find(const_cast<GSList *>(layers), curr) != NULL ); |
1877 | + needsAdd &= ( layers.find(curr) != layers.end() ); |
1878 | // XML Tree being used here directly while it shouldn't be... |
1879 | if ( (!(group->getRepr())) || (!(group->getRepr()->parent())) ) { |
1880 | needsAdd = false; |
1881 | |
1882 | === modified file 'src/path-chemistry.h' |
1883 | --- src/path-chemistry.h 2015-02-19 03:25:21 +0000 |
1884 | +++ src/path-chemistry.h 2015-12-09 15:31:04 +0000 |
1885 | @@ -24,7 +24,6 @@ |
1886 | } // namespace Inkscape |
1887 | |
1888 | typedef unsigned int guint32; |
1889 | -typedef struct _GSList GSList; |
1890 | |
1891 | void sp_selected_path_combine (SPDesktop *desktop); |
1892 | void sp_selected_path_break_apart (SPDesktop *desktop); |
1893 | |
1894 | === modified file 'src/profile-manager.cpp' |
1895 | --- src/profile-manager.cpp 2014-03-27 01:33:44 +0000 |
1896 | +++ src/profile-manager.cpp 2015-12-09 15:31:04 +0000 |
1897 | @@ -34,11 +34,9 @@ |
1898 | { |
1899 | std::vector<SPObject*> newList; |
1900 | if (_doc) { |
1901 | - const GSList *current = _doc->getResourceList( "iccprofile" ); |
1902 | - while ( current ) { |
1903 | - newList.push_back(SP_OBJECT(current->data)); |
1904 | - current = g_slist_next(current); |
1905 | - } |
1906 | + std::set<SPObject *> current = _doc->getResourceList( "iccprofile" ); |
1907 | + for (std::set<SPObject *>::const_iterator i = current.begin(); i != current.end(); ++i) |
1908 | + newList.push_back(*i); |
1909 | } |
1910 | sort( newList.begin(), newList.end() ); |
1911 | |
1912 | |
1913 | === modified file 'src/removeoverlap.h' |
1914 | --- src/removeoverlap.h 2015-02-19 03:25:21 +0000 |
1915 | +++ src/removeoverlap.h 2015-12-09 15:31:04 +0000 |
1916 | @@ -13,8 +13,6 @@ |
1917 | #ifndef SEEN_REMOVEOVERLAP_H |
1918 | #define SEEN_REMOVEOVERLAP_H |
1919 | |
1920 | -typedef struct _GSList GSList; |
1921 | - |
1922 | void removeoverlap(std::vector<SPItem*> const &items, double xGap, double yGap); |
1923 | |
1924 | #endif // SEEN_REMOVEOVERLAP_H |
1925 | |
1926 | === modified file 'src/resource-manager.cpp' |
1927 | --- src/resource-manager.cpp 2015-10-03 06:14:44 +0000 |
1928 | +++ src/resource-manager.cpp 2015-12-09 15:31:04 +0000 |
1929 | @@ -179,9 +179,9 @@ |
1930 | std::set<Glib::ustring> uniques; |
1931 | |
1932 | if ( doc ) { |
1933 | - GSList const *images = doc->getResourceList("image"); |
1934 | - for (GSList const *it = images; it; it = it->next) { |
1935 | - Inkscape::XML::Node *ir = static_cast<SPObject *>(it->data)->getRepr(); |
1936 | + std::set<SPObject *> images = doc->getResourceList("image"); |
1937 | + for (std::set<SPObject *>::const_iterator it = images.begin(); it != images.end(); ++it) { |
1938 | + Inkscape::XML::Node *ir = (*it)->getRepr(); |
1939 | |
1940 | gchar const *href = ir->attribute("xlink:href"); |
1941 | if ( href && ( uniques.find(href) == uniques.end() ) ) { |
1942 | @@ -305,10 +305,10 @@ |
1943 | |
1944 | bool savedUndoState = DocumentUndo::getUndoSensitive(doc); |
1945 | DocumentUndo::setUndoSensitive(doc, true); |
1946 | - |
1947 | - GSList const *images = doc->getResourceList("image"); |
1948 | - for (GSList const *it = images; it; it = it->next) { |
1949 | - Inkscape::XML::Node *ir = static_cast<SPObject *>(it->data)->getRepr(); |
1950 | + |
1951 | + std::set<SPObject *> images = doc->getResourceList("image"); |
1952 | + for (std::set<SPObject *>::const_iterator it = images.begin(); it != images.end(); ++it) { |
1953 | + Inkscape::XML::Node *ir = (*it)->getRepr(); |
1954 | |
1955 | gchar const *href = ir->attribute("xlink:href"); |
1956 | if ( href ) { |
1957 | |
1958 | === modified file 'src/satisfied-guide-cns.cpp' |
1959 | --- src/satisfied-guide-cns.cpp 2014-12-21 19:58:38 +0000 |
1960 | +++ src/satisfied-guide-cns.cpp 2015-12-09 15:31:04 +0000 |
1961 | @@ -10,8 +10,8 @@ |
1962 | std::vector<SPGuideConstraint> &cns) |
1963 | { |
1964 | SPNamedView const &nv = *desktop.getNamedView(); |
1965 | - for (GSList const *l = nv.guides; l != NULL; l = l->next) { |
1966 | - SPGuide &g = *SP_GUIDE(l->data); |
1967 | + for(std::vector<SPGuide *>::const_iterator it = nv.guides.begin(); it != nv.guides.end(); ++it) { |
1968 | + SPGuide &g = *(*it); |
1969 | for (unsigned int i = 0; i < snappoints.size(); ++i) { |
1970 | if (Geom::are_near(g.getDistanceFrom(snappoints[i].getPoint()), 0, 1e-2)) { |
1971 | cns.push_back(SPGuideConstraint(&g, i)); |
1972 | |
1973 | === modified file 'src/selection-chemistry.h' |
1974 | --- src/selection-chemistry.h 2015-05-09 12:59:00 +0000 |
1975 | +++ src/selection-chemistry.h 2015-12-09 15:31:04 +0000 |
1976 | @@ -22,7 +22,6 @@ |
1977 | |
1978 | class SPCSSAttr; |
1979 | class SPDesktop; |
1980 | -typedef struct _GSList GSList; |
1981 | |
1982 | namespace Inkscape { |
1983 | |
1984 | @@ -75,7 +74,6 @@ |
1985 | void sp_selection_tile(SPDesktop *desktop, bool apply = true); |
1986 | void sp_selection_untile(SPDesktop *desktop); |
1987 | |
1988 | -//void sp_selection_group_impl(GSList const *reprs_to_group, Inkscape::XML::Node *group, Inkscape::XML::Document *xml_doc, SPDocument *doc); |
1989 | void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop); |
1990 | void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop); |
1991 | |
1992 | |
1993 | === modified file 'src/seltrans.h' |
1994 | --- src/seltrans.h 2015-02-19 03:25:21 +0000 |
1995 | +++ src/seltrans.h 2015-12-09 15:31:04 +0000 |
1996 | @@ -34,7 +34,6 @@ |
1997 | struct SPCanvasItem; |
1998 | struct SPCtrlLine; |
1999 | struct SPSelTransHandle; |
2000 | -typedef struct _GSList GSList; |
2001 | |
2002 | namespace Inkscape { |
2003 | |
2004 | |
2005 | === modified file 'src/snap.cpp' |
2006 | --- src/snap.cpp 2015-10-29 22:24:26 +0000 |
2007 | +++ src/snap.cpp 2015-12-09 15:31:04 +0000 |
2008 | @@ -69,9 +69,8 @@ |
2009 | SnapperList s; |
2010 | |
2011 | if (_desktop && _desktop->gridsEnabled() && snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GRID)) { |
2012 | - for ( GSList const *l = _named_view->grids; l != NULL; l = l->next) { |
2013 | - Inkscape::CanvasGrid *grid = (Inkscape::CanvasGrid*) l->data; |
2014 | - s.push_back(grid->snapper); |
2015 | + for(std::vector<Inkscape::CanvasGrid *>::const_iterator it = _named_view->grids.begin(); it != _named_view->grids.end(); ++it) { |
2016 | + s.push_back((*it)->snapper); |
2017 | } |
2018 | } |
2019 | |
2020 | @@ -173,8 +172,8 @@ |
2021 | |
2022 | // Cannot use getGridSnappers() because we need both the grids AND their snappers |
2023 | // Therefore we iterate through all grids manually |
2024 | - for (GSList const *l = _named_view->grids; l != NULL; l = l->next) { |
2025 | - Inkscape::CanvasGrid *grid = (Inkscape::CanvasGrid*) l->data; |
2026 | + for (std::vector<Inkscape::CanvasGrid *>::const_iterator it = _named_view->grids.begin(); it != _named_view->grids.end(); ++it) { |
2027 | + Inkscape::CanvasGrid *grid = (*it); |
2028 | const Inkscape::Snapper* snapper = grid->snapper; |
2029 | if (snapper && snapper->ThisSnapperMightSnap()) { |
2030 | // To find the nearest multiple of the grid pitch for a given translation t, we |
2031 | |
2032 | === modified file 'src/snap.h' |
2033 | --- src/snap.h 2015-09-13 17:50:28 +0000 |
2034 | +++ src/snap.h 2015-12-09 15:31:04 +0000 |
2035 | @@ -39,7 +39,6 @@ |
2036 | class PureTransform; |
2037 | } |
2038 | |
2039 | -typedef struct _GSList GSList; |
2040 | |
2041 | /** |
2042 | * Class to coordinate snapping operations. |
2043 | |
2044 | === modified file 'src/sp-clippath.h' |
2045 | --- src/sp-clippath.h 2015-11-07 19:15:21 +0000 |
2046 | +++ src/sp-clippath.h 2015-12-09 15:31:04 +0000 |
2047 | @@ -19,7 +19,6 @@ |
2048 | #define SP_IS_CLIPPATH(obj) (dynamic_cast<const SPClipPath*>((SPObject*)obj) != NULL) |
2049 | |
2050 | struct SPClipPathView; |
2051 | -typedef struct _GSList GSList; |
2052 | |
2053 | #include <cstdio> |
2054 | |
2055 | |
2056 | === modified file 'src/sp-guide.cpp' |
2057 | --- src/sp-guide.cpp 2015-12-05 22:55:57 +0000 |
2058 | +++ src/sp-guide.cpp 2015-12-09 15:31:04 +0000 |
2059 | @@ -53,7 +53,6 @@ |
2060 | : SPObject() |
2061 | , label(NULL) |
2062 | , locked(0) |
2063 | - , views(NULL) |
2064 | , normal_to_line(Geom::Point(0.,1.)) |
2065 | , point_on_line(Geom::Point(0.,0.)) |
2066 | , color(0x0000ff7f) |
2067 | @@ -64,8 +63,8 @@ |
2068 | { |
2069 | color = c; |
2070 | |
2071 | - for (GSList *l = this->views; l != NULL; l = l->next) { |
2072 | - sp_guideline_set_color(SP_GUIDELINE(l->data), this->color); |
2073 | + for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) { |
2074 | + sp_guideline_set_color(*it, this->color); |
2075 | } |
2076 | } |
2077 | |
2078 | @@ -85,10 +84,10 @@ |
2079 | |
2080 | void SPGuide::release() |
2081 | { |
2082 | - while (this->views) { |
2083 | - sp_guideline_delete(SP_GUIDELINE(this->views->data)); |
2084 | - this->views = g_slist_remove(this->views, this->views->data); |
2085 | + for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) { |
2086 | + sp_guideline_delete(*it); |
2087 | } |
2088 | + this->views.clear(); |
2089 | |
2090 | if (this->document) { |
2091 | // Unregister ourselves |
2092 | @@ -265,10 +264,11 @@ |
2093 | void sp_guide_delete_all_guides(SPDesktop *dt) |
2094 | { |
2095 | SPDocument *doc=dt->getDocument(); |
2096 | - const GSList *current; |
2097 | - while ( (current = doc->getResourceList("guide")) ) { |
2098 | - SPGuide* guide = SP_GUIDE(current->data); |
2099 | + std::set<SPObject *> current = doc->getResourceList("guide"); |
2100 | + while (!current.empty()){ |
2101 | + SPGuide* guide = SP_GUIDE(*(current.begin())); |
2102 | sp_guide_remove(guide); |
2103 | + current = doc->getResourceList("guide"); |
2104 | } |
2105 | |
2106 | DocumentUndo::done(doc, SP_VERB_NONE, _("Delete All Guides")); |
2107 | @@ -281,14 +281,14 @@ |
2108 | |
2109 | g_signal_connect(G_OBJECT(item), "event", G_CALLBACK(handler), this); |
2110 | |
2111 | - views = g_slist_prepend(views, item); |
2112 | + views.push_back(SP_GUIDELINE(item)); |
2113 | } |
2114 | |
2115 | void SPGuide::showSPGuide() |
2116 | { |
2117 | - for (GSList *v = views; v != NULL; v = v->next) { |
2118 | - sp_canvas_item_show(SP_CANVAS_ITEM(v->data)); |
2119 | - sp_canvas_item_show(SP_CANVAS_ITEM(SP_GUIDELINE(v->data)->origin)); |
2120 | + for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) { |
2121 | + sp_canvas_item_show(SP_CANVAS_ITEM(*it)); |
2122 | + sp_canvas_item_show(SP_CANVAS_ITEM((*it)->origin)); |
2123 | } |
2124 | } |
2125 | |
2126 | @@ -296,11 +296,10 @@ |
2127 | { |
2128 | g_assert(canvas != NULL); |
2129 | g_assert(SP_IS_CANVAS(canvas)); |
2130 | - |
2131 | - for (GSList *l = views; l != NULL; l = l->next) { |
2132 | - if (canvas == SP_CANVAS_ITEM(l->data)->canvas) { |
2133 | - sp_guideline_delete(SP_GUIDELINE(l->data)); |
2134 | - views = g_slist_remove(views, l->data); |
2135 | + for(std::vector<SPGuideLine *>::iterator it = this->views.begin(); it != this->views.end(); ++it) { |
2136 | + if (canvas == SP_CANVAS_ITEM(*it)->canvas) { |
2137 | + sp_guideline_delete(*it); |
2138 | + views.erase(it); |
2139 | return; |
2140 | } |
2141 | } |
2142 | @@ -310,9 +309,9 @@ |
2143 | |
2144 | void SPGuide::hideSPGuide() |
2145 | { |
2146 | - for (GSList *v = views; v != NULL; v = v->next) { |
2147 | - sp_canvas_item_hide(SP_CANVAS_ITEM(v->data)); |
2148 | - sp_canvas_item_hide(SP_CANVAS_ITEM(SP_GUIDELINE(v->data)->origin)); |
2149 | + for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) { |
2150 | + sp_canvas_item_hide(SP_CANVAS_ITEM(*it)); |
2151 | + sp_canvas_item_hide(SP_CANVAS_ITEM((*it)->origin)); |
2152 | } |
2153 | } |
2154 | |
2155 | @@ -321,9 +320,9 @@ |
2156 | g_assert(canvas != NULL); |
2157 | g_assert(SP_IS_CANVAS(canvas)); |
2158 | |
2159 | - for (GSList *l = views; l != NULL; l = l->next) { |
2160 | - if (canvas == SP_CANVAS_ITEM(l->data)->canvas) { |
2161 | - sp_guideline_set_sensitive(SP_GUIDELINE(l->data), sensitive); |
2162 | + for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) { |
2163 | + if (canvas == SP_CANVAS_ITEM(*it)->canvas) { |
2164 | + sp_guideline_set_sensitive(*it, sensitive); |
2165 | return; |
2166 | } |
2167 | } |
2168 | @@ -351,8 +350,8 @@ |
2169 | if(this->locked) { |
2170 | return; |
2171 | } |
2172 | - for (GSList *l = views; l != NULL; l = l->next) { |
2173 | - sp_guideline_set_position(SP_GUIDELINE(l->data), point_on_line); |
2174 | + for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) { |
2175 | + sp_guideline_set_position(*it, point_on_line); |
2176 | } |
2177 | |
2178 | /* Calling sp_repr_set_point must precede calling sp_item_notify_moveto in the commit |
2179 | @@ -400,8 +399,8 @@ |
2180 | if(this->locked) { |
2181 | return; |
2182 | } |
2183 | - for (GSList *l = this->views; l != NULL; l = l->next) { |
2184 | - sp_guideline_set_normal(SP_GUIDELINE(l->data), normal_to_line); |
2185 | + for(std::vector<SPGuideLine *>::const_iterator it = this->views.begin(); it != this->views.end(); ++it) { |
2186 | + sp_guideline_set_normal(*it, normal_to_line); |
2187 | } |
2188 | |
2189 | /* Calling sp_repr_set_svg_point must precede calling sp_item_notify_moveto in the commit |
2190 | @@ -426,8 +425,8 @@ |
2191 | { |
2192 | this->color = (r << 24) | (g << 16) | (b << 8) | 0x7f; |
2193 | |
2194 | - if (views) { |
2195 | - sp_guideline_set_color(SP_GUIDELINE(views->data), this->color); |
2196 | + if (! views.empty()) { |
2197 | + sp_guideline_set_color(views[0], this->color); |
2198 | } |
2199 | |
2200 | if (commit) { |
2201 | @@ -441,8 +440,8 @@ |
2202 | void SPGuide::set_locked(const bool locked, bool const commit) |
2203 | { |
2204 | this->locked = locked; |
2205 | - if (views) { |
2206 | - sp_guideline_set_locked(SP_GUIDELINE(views->data), locked); |
2207 | + if ( !views.empty() ) { |
2208 | + sp_guideline_set_locked(views[0], locked); |
2209 | } |
2210 | |
2211 | if (commit) { |
2212 | @@ -452,8 +451,8 @@ |
2213 | |
2214 | void SPGuide::set_label(const char* label, bool const commit) |
2215 | { |
2216 | - if (views) { |
2217 | - sp_guideline_set_label(SP_GUIDELINE(views->data), label); |
2218 | + if (!views.empty()) { |
2219 | + sp_guideline_set_label(views[0], label); |
2220 | } |
2221 | |
2222 | if (commit) { |
2223 | |
2224 | === modified file 'src/sp-guide.h' |
2225 | --- src/sp-guide.h 2015-12-02 17:24:10 +0000 |
2226 | +++ src/sp-guide.h 2015-12-09 15:31:04 +0000 |
2227 | @@ -22,13 +22,12 @@ |
2228 | typedef unsigned int guint32; |
2229 | extern "C" { |
2230 | typedef void (*GCallback) (void); |
2231 | - typedef struct _GSList GSList; |
2232 | } |
2233 | |
2234 | class SPDesktop; |
2235 | struct SPCanvas; |
2236 | struct SPCanvasGroup; |
2237 | - |
2238 | +struct SPGuideLine; |
2239 | #define SP_GUIDE(obj) (dynamic_cast<SPGuide*>((SPObject*)obj)) |
2240 | #define SP_IS_GUIDE(obj) (dynamic_cast<const SPGuide*>((SPObject*)obj) != NULL) |
2241 | |
2242 | @@ -80,8 +79,8 @@ |
2243 | virtual void set(unsigned int key, const char* value); |
2244 | |
2245 | char* label; |
2246 | + std::vector<SPGuideLine *> views; // contains an object of type SPGuideline (see display/guideline.cpp for definition) |
2247 | bool locked; |
2248 | - GSList *views; // contains an object of type SPGuideline (see display/guideline.cpp for definition) |
2249 | Geom::Point normal_to_line; |
2250 | Geom::Point point_on_line; |
2251 | |
2252 | |
2253 | === modified file 'src/sp-item-group.h' |
2254 | --- src/sp-item-group.h 2015-02-27 02:10:36 +0000 |
2255 | +++ src/sp-item-group.h 2015-12-09 15:31:04 +0000 |
2256 | @@ -25,7 +25,6 @@ |
2257 | |
2258 | class Drawing; |
2259 | class DrawingItem; |
2260 | -typedef struct _GSList GSList; |
2261 | |
2262 | } // namespace Inkscape |
2263 | |
2264 | |
2265 | === modified file 'src/sp-mask.cpp' |
2266 | --- src/sp-mask.cpp 2015-11-13 17:53:22 +0000 |
2267 | +++ src/sp-mask.cpp 2015-12-09 15:31:04 +0000 |
2268 | @@ -138,23 +138,18 @@ |
2269 | |
2270 | flags &= SP_OBJECT_MODIFIED_CASCADE; |
2271 | |
2272 | - GSList *l = NULL; |
2273 | - for (SPObject *child = this->firstChild(); child; child = child->getNext()) { |
2274 | - sp_object_ref(child); |
2275 | - l = g_slist_prepend (l, child); |
2276 | + std::vector<SPObject *> children = this->childList(false); |
2277 | + for (std::vector<SPObject *>::const_iterator child = children.begin();child != children.end();child++) { |
2278 | + sp_object_ref(*child); |
2279 | } |
2280 | |
2281 | - l = g_slist_reverse (l); |
2282 | |
2283 | - while (l) { |
2284 | - SPObject *child = SP_OBJECT(l->data); |
2285 | - l = g_slist_remove(l, child); |
2286 | - |
2287 | - if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { |
2288 | - child->updateDisplay(ctx, flags); |
2289 | + for (std::vector<SPObject *>::const_iterator child = children.begin();child != children.end();child++) { |
2290 | + if (flags || ((*child)->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { |
2291 | + (*child)->updateDisplay(ctx, flags); |
2292 | } |
2293 | |
2294 | - sp_object_unref(child); |
2295 | + sp_object_unref(*child); |
2296 | } |
2297 | |
2298 | for (SPMaskView *v = this->display; v != NULL; v = v->next) { |
2299 | @@ -177,23 +172,17 @@ |
2300 | |
2301 | flags &= SP_OBJECT_MODIFIED_CASCADE; |
2302 | |
2303 | - GSList *l = NULL; |
2304 | - for (SPObject *child = this->firstChild(); child; child = child->getNext()) { |
2305 | - sp_object_ref(child); |
2306 | - l = g_slist_prepend(l, child); |
2307 | + std::vector<SPObject *> children = this->childList(false); |
2308 | + for (std::vector<SPObject *>::const_iterator child = children.begin();child != children.end();child++) { |
2309 | + sp_object_ref(*child); |
2310 | } |
2311 | |
2312 | - l = g_slist_reverse(l); |
2313 | - |
2314 | - while (l) { |
2315 | - SPObject *child = SP_OBJECT(l->data); |
2316 | - l = g_slist_remove(l, child); |
2317 | - |
2318 | - if (flags || (child->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { |
2319 | - child->emitModified(flags); |
2320 | + for (std::vector<SPObject *>::const_iterator child = children.begin();child != children.end();child++) { |
2321 | + if (flags || ((*child)->mflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) { |
2322 | + (*child)->emitModified(flags); |
2323 | } |
2324 | |
2325 | - sp_object_unref(child); |
2326 | + sp_object_unref(*child); |
2327 | } |
2328 | } |
2329 | |
2330 | |
2331 | === modified file 'src/sp-namedview.cpp' |
2332 | --- src/sp-namedview.cpp 2015-12-06 21:39:31 +0000 |
2333 | +++ src/sp-namedview.cpp 2015-12-09 15:31:04 +0000 |
2334 | @@ -62,7 +62,7 @@ |
2335 | this->zoom = 0; |
2336 | this->guidecolor = 0; |
2337 | this->guidehicolor = 0; |
2338 | - this->views = NULL; |
2339 | + this->views.clear(); |
2340 | this->borderlayer = 0; |
2341 | this->page_size_units = NULL; |
2342 | this->window_x = 0; |
2343 | @@ -86,9 +86,9 @@ |
2344 | this->showborder = TRUE; |
2345 | this->showpageshadow = TRUE; |
2346 | |
2347 | - this->guides = NULL; |
2348 | + this->guides.clear(); |
2349 | this->viewcount = 0; |
2350 | - this->grids = NULL; |
2351 | + this->grids.clear(); |
2352 | |
2353 | this->default_layer_id = 0; |
2354 | |
2355 | @@ -249,7 +249,7 @@ |
2356 | for (SPObject *o = this->firstChild() ; o; o = o->getNext() ) { |
2357 | if (SP_IS_GUIDE(o)) { |
2358 | SPGuide * g = SP_GUIDE(o); |
2359 | - this->guides = g_slist_prepend(this->guides, g); |
2360 | + this->guides.push_back(g); |
2361 | //g_object_set(G_OBJECT(g), "color", nv->guidecolor, "hicolor", nv->guidehicolor, NULL); |
2362 | g->setColor(this->guidecolor); |
2363 | g->setHiColor(this->guidehicolor); |
2364 | @@ -272,18 +272,12 @@ |
2365 | } |
2366 | |
2367 | void SPNamedView::release() { |
2368 | - if (this->guides) { |
2369 | - g_slist_free(this->guides); |
2370 | - this->guides = NULL; |
2371 | - } |
2372 | + this->guides.clear(); |
2373 | |
2374 | // delete grids: |
2375 | - while ( this->grids ) { |
2376 | - Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)this->grids->data; // get first entry |
2377 | - delete gr; |
2378 | - this->grids = g_slist_remove_link(this->grids, this->grids); // deletes first entry |
2379 | - } |
2380 | - |
2381 | + for(std::vector<Inkscape::CanvasGrid *>::const_iterator it=this->grids.begin();it!=this->grids.end();++it ) |
2382 | + delete *it; |
2383 | + this->grids.clear(); |
2384 | SPObjectGroup::release(); |
2385 | } |
2386 | |
2387 | @@ -329,10 +323,9 @@ |
2388 | this->guidecolor = (this->guidecolor & 0xff) | sp_svg_read_color(value, this->guidecolor); |
2389 | } |
2390 | |
2391 | - for (GSList *l = this->guides; l != NULL; l = l->next) { |
2392 | - SPGuide * g = SP_GUIDE(l->data); |
2393 | - g->setColor(this->guidecolor); |
2394 | - g->readAttr("inkscape:color"); |
2395 | + for(std::vector<SPGuide *>::const_iterator it=this->guides.begin();it!=this->guides.end();++it ) { |
2396 | + (*it)->setColor(this->guidecolor); |
2397 | + (*it)->readAttr("inkscape:color"); |
2398 | } |
2399 | |
2400 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); |
2401 | @@ -341,10 +334,9 @@ |
2402 | this->guidecolor = (this->guidecolor & 0xffffff00) | (DEFAULTGUIDECOLOR & 0xff); |
2403 | sp_nv_read_opacity(value, &this->guidecolor); |
2404 | |
2405 | - for (GSList *l = this->guides; l != NULL; l = l->next) { |
2406 | - SPGuide * g = SP_GUIDE(l->data); |
2407 | - g->setColor(this->guidecolor); |
2408 | - g->readAttr("inkscape:color"); |
2409 | + for(std::vector<SPGuide *>::const_iterator it=this->guides.begin();it!=this->guides.end();++it ) { |
2410 | + (*it)->setColor(this->guidecolor); |
2411 | + (*it)->readAttr("inkscape:color"); |
2412 | } |
2413 | |
2414 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); |
2415 | @@ -355,10 +347,8 @@ |
2416 | if (value) { |
2417 | this->guidehicolor = (this->guidehicolor & 0xff) | sp_svg_read_color(value, this->guidehicolor); |
2418 | } |
2419 | - |
2420 | - for (GSList *l = this->guides; l != NULL; l = l->next) { |
2421 | - //g_object_set(G_OBJECT(l->data), "hicolor", nv->guidehicolor, NULL); |
2422 | - SP_GUIDE(l->data)->setHiColor(this->guidehicolor); |
2423 | + for(std::vector<SPGuide *>::const_iterator it=this->guides.begin();it!=this->guides.end();++it ) { |
2424 | + (*it)->setHiColor(this->guidehicolor); |
2425 | } |
2426 | |
2427 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); |
2428 | @@ -366,10 +356,8 @@ |
2429 | case SP_ATTR_GUIDEHIOPACITY: |
2430 | this->guidehicolor = (this->guidehicolor & 0xffffff00) | (DEFAULTGUIDEHICOLOR & 0xff); |
2431 | sp_nv_read_opacity(value, &this->guidehicolor); |
2432 | - |
2433 | - for (GSList *l = this->guides; l != NULL; l = l->next) { |
2434 | - //g_object_set(G_OBJECT(l->data), "hicolor", nv->guidehicolor, NULL); |
2435 | - SP_GUIDE(l->data)->setHiColor(this->guidehicolor); |
2436 | + for(std::vector<SPGuide *>::const_iterator it=this->guides.begin();it!=this->guides.end();++it ) { |
2437 | + (*it)->setHiColor(this->guidehicolor); |
2438 | } |
2439 | |
2440 | this->requestModified(SP_OBJECT_MODIFIED_FLAG); |
2441 | @@ -623,10 +611,9 @@ |
2442 | sp_namedview_add_grid(SPNamedView *nv, Inkscape::XML::Node *repr, SPDesktop *desktop) { |
2443 | Inkscape::CanvasGrid* grid = NULL; |
2444 | //check if namedview already has an object for this grid |
2445 | - for (GSList *l = nv->grids; l != NULL; l = l->next) { |
2446 | - Inkscape::CanvasGrid* g = (Inkscape::CanvasGrid*) l->data; |
2447 | - if (repr == g->repr) { |
2448 | - grid = g; |
2449 | + for(std::vector<Inkscape::CanvasGrid *>::const_iterator it=nv->grids.begin();it!=nv->grids.end();++it ) { |
2450 | + if (repr == (*it)->repr) { |
2451 | + grid = (*it); |
2452 | break; |
2453 | } |
2454 | } |
2455 | @@ -639,14 +626,13 @@ |
2456 | return NULL; |
2457 | } |
2458 | grid = Inkscape::CanvasGrid::NewGrid(nv, repr, nv->document, gridtype); |
2459 | - nv->grids = g_slist_append(nv->grids, grid); |
2460 | + nv->grids.push_back(grid); |
2461 | } |
2462 | |
2463 | if (!desktop) { |
2464 | //add canvasitem to all desktops |
2465 | - for (GSList *l = nv->views; l != NULL; l = l->next) { |
2466 | - SPDesktop *dt = static_cast<SPDesktop*>(l->data); |
2467 | - grid->createCanvasItem(dt); |
2468 | + for(std::vector<SPDesktop *>::const_iterator it=nv->views.begin();it!=nv->views.end();++it ) { |
2469 | + grid->createCanvasItem(*it); |
2470 | } |
2471 | } else { |
2472 | //add canvasitem only for specified desktop |
2473 | @@ -669,7 +655,7 @@ |
2474 | |
2475 | if (SP_IS_GUIDE(no)) { |
2476 | SPGuide *g = (SPGuide *) no; |
2477 | - this->guides = g_slist_prepend(this->guides, g); |
2478 | + this->guides.push_back(g); |
2479 | |
2480 | //g_object_set(G_OBJECT(g), "color", this->guidecolor, "hicolor", this->guidehicolor, NULL); |
2481 | g->setColor(this->guidecolor); |
2482 | @@ -677,11 +663,11 @@ |
2483 | g->readAttr("inkscape:color"); |
2484 | |
2485 | if (this->editable) { |
2486 | - for (GSList *l = this->views; l != NULL; l = l->next) { |
2487 | - g->SPGuide::showSPGuide(static_cast<SPDesktop*>(l->data)->guides, (GCallback) sp_dt_guide_event); |
2488 | + for(std::vector<SPDesktop *>::const_iterator it=this->views.begin();it!=this->views.end();++it ) { |
2489 | + g->SPGuide::showSPGuide((*it)->guides, (GCallback) sp_dt_guide_event); |
2490 | |
2491 | - if (static_cast<SPDesktop*>(l->data)->guides_active) { |
2492 | - g->sensitize((static_cast<SPDesktop*> (l->data))->getCanvas(), TRUE); |
2493 | + if ((*it)->guides_active) { |
2494 | + g->sensitize((*it)->getCanvas(), TRUE); |
2495 | } |
2496 | |
2497 | sp_namedview_show_single_guide(SP_GUIDE(g), this->showguides); |
2498 | @@ -694,27 +680,19 @@ |
2499 | |
2500 | void SPNamedView::remove_child(Inkscape::XML::Node *child) { |
2501 | if (!strcmp(child->name(), "inkscape:grid")) { |
2502 | - for ( GSList *iter = this->grids ; iter ; iter = iter->next ) { |
2503 | - Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)iter->data; |
2504 | - |
2505 | - if ( gr->repr == child ) { |
2506 | - delete gr; |
2507 | - this->grids = g_slist_remove_link(this->grids, iter); |
2508 | + for(std::vector<Inkscape::CanvasGrid *>::iterator it=this->grids.begin();it!=this->grids.end();++it ) { |
2509 | + if ( (*it)->repr == child ) { |
2510 | + delete (*it); |
2511 | + this->grids.erase(it); |
2512 | break; |
2513 | } |
2514 | } |
2515 | } else { |
2516 | - GSList **ref = &this->guides; |
2517 | - for ( GSList *iter = this->guides ; iter ; iter = iter->next ) { |
2518 | - |
2519 | - if ( reinterpret_cast<SPObject *>(iter->data)->getRepr() == child ) { |
2520 | - *ref = iter->next; |
2521 | - iter->next = NULL; |
2522 | - g_slist_free_1(iter); |
2523 | + for(std::vector<SPGuide *>::iterator it=this->guides.begin();it!=this->guides.end();++it ) { |
2524 | + if ( (*it)->getRepr() == child ) { |
2525 | + this->guides.erase(it); |
2526 | break; |
2527 | - } |
2528 | - |
2529 | - ref = &iter->next; |
2530 | + } |
2531 | } |
2532 | } |
2533 | |
2534 | @@ -737,16 +715,16 @@ |
2535 | |
2536 | void SPNamedView::show(SPDesktop *desktop) |
2537 | { |
2538 | - for (GSList *l = guides; l != NULL; l = l->next) { |
2539 | - SP_GUIDE(l->data)->showSPGuide( desktop->guides, (GCallback) sp_dt_guide_event); |
2540 | + for(std::vector<SPGuide *>::const_iterator it=this->guides.begin();it!=this->guides.end();++it ) { |
2541 | + (*it)->showSPGuide( desktop->guides, (GCallback) sp_dt_guide_event); |
2542 | if (desktop->guides_active) { |
2543 | - SP_GUIDE(l->data)->sensitize(desktop->getCanvas(), TRUE); |
2544 | + (*it)->sensitize(desktop->getCanvas(), TRUE); |
2545 | } |
2546 | - sp_namedview_show_single_guide(SP_GUIDE(l->data), showguides); |
2547 | - sp_namedview_lock_single_guide(SP_GUIDE(l->data), lockguides); |
2548 | + sp_namedview_show_single_guide((*it), showguides); |
2549 | + sp_namedview_lock_single_guide((*it), lockguides); |
2550 | } |
2551 | |
2552 | - views = g_slist_prepend(views, desktop); |
2553 | + views.push_back(desktop); |
2554 | |
2555 | // generate grids specified in SVG: |
2556 | Inkscape::XML::Node *repr = this->getRepr(); |
2557 | @@ -935,38 +913,35 @@ |
2558 | void SPNamedView::hide(SPDesktop const *desktop) |
2559 | { |
2560 | g_assert(desktop != NULL); |
2561 | - g_assert(g_slist_find(views, desktop)); |
2562 | - |
2563 | - for (GSList *l = guides; l != NULL; l = l->next) { |
2564 | - SP_GUIDE(l->data)->hideSPGuide(desktop->getCanvas()); |
2565 | + g_assert(std::find(views.begin(),views.end(),desktop)!=views.end()); |
2566 | + for(std::vector<SPGuide *>::iterator it=this->guides.begin();it!=this->guides.end();++it ) { |
2567 | + (*it)->hideSPGuide(desktop->getCanvas()); |
2568 | } |
2569 | - |
2570 | - views = g_slist_remove(views, desktop); |
2571 | + views.erase(std::remove(views.begin(),views.end(),desktop),views.end()); |
2572 | } |
2573 | |
2574 | void SPNamedView::activateGuides(void* desktop, bool active) |
2575 | { |
2576 | g_assert(desktop != NULL); |
2577 | - g_assert(g_slist_find(views, desktop)); |
2578 | + g_assert(std::find(views.begin(),views.end(),desktop)!=views.end()); |
2579 | |
2580 | SPDesktop *dt = static_cast<SPDesktop*>(desktop); |
2581 | - |
2582 | - for (GSList *l = guides; l != NULL; l = l->next) { |
2583 | - SP_GUIDE(l->data)->sensitize(dt->getCanvas(), active); |
2584 | + for(std::vector<SPGuide *>::iterator it=this->guides.begin();it!=this->guides.end();++it ) { |
2585 | + (*it)->sensitize(dt->getCanvas(), active); |
2586 | } |
2587 | } |
2588 | |
2589 | static void sp_namedview_setup_guides(SPNamedView *nv) |
2590 | { |
2591 | - for (GSList *l = nv->guides; l != NULL; l = l->next) { |
2592 | - sp_namedview_show_single_guide(SP_GUIDE(l->data), nv->showguides); |
2593 | + for(std::vector<SPGuide *>::iterator it=nv->guides.begin();it!=nv->guides.end();++it ) { |
2594 | + sp_namedview_show_single_guide(*it, nv->showguides); |
2595 | } |
2596 | } |
2597 | |
2598 | static void sp_namedview_lock_guides(SPNamedView *nv) |
2599 | { |
2600 | - for (GSList *l = nv->guides; l != NULL; l = l->next) { |
2601 | - sp_namedview_lock_single_guide(SP_GUIDE(l->data), nv->lockguides); |
2602 | + for(std::vector<SPGuide *>::iterator it=nv->guides.begin();it!=nv->guides.end();++it ) { |
2603 | + sp_namedview_lock_single_guide(*it, nv->lockguides); |
2604 | } |
2605 | } |
2606 | |
2607 | @@ -1050,7 +1025,7 @@ |
2608 | return ++viewcount; |
2609 | } |
2610 | |
2611 | -GSList const *SPNamedView::getViewList() const |
2612 | +std::vector<SPDesktop *> const SPNamedView::getViewList() const |
2613 | { |
2614 | return views; |
2615 | } |
2616 | @@ -1185,18 +1160,17 @@ |
2617 | */ |
2618 | Inkscape::CanvasGrid * sp_namedview_get_first_enabled_grid(SPNamedView *namedview) |
2619 | { |
2620 | - for (GSList const * l = namedview->grids; l != NULL; l = l->next) { |
2621 | - Inkscape::CanvasGrid * grid = (Inkscape::CanvasGrid*) l->data; |
2622 | - if (grid->isEnabled()) |
2623 | - return grid; |
2624 | + for(std::vector<Inkscape::CanvasGrid *>::const_iterator it=namedview->grids.begin();it!=namedview->grids.end();++it ) { |
2625 | + if ((*it)->isEnabled()) |
2626 | + return (*it); |
2627 | } |
2628 | |
2629 | return NULL; |
2630 | } |
2631 | |
2632 | void SPNamedView::translateGuides(Geom::Translate const &tr) { |
2633 | - for (GSList *l = guides; l != NULL; l = l->next) { |
2634 | - SPGuide &guide = *SP_GUIDE(l->data); |
2635 | + for(std::vector<SPGuide *>::iterator it=this->guides.begin();it!=this->guides.end();++it ) { |
2636 | + SPGuide &guide = *(*it); |
2637 | Geom::Point point_on_line = guide.getPoint(); |
2638 | point_on_line *= tr; |
2639 | guide.moveto(point_on_line, true); |
2640 | @@ -1204,19 +1178,15 @@ |
2641 | } |
2642 | |
2643 | void SPNamedView::translateGrids(Geom::Translate const &tr) { |
2644 | - for (GSList *l = grids; l != NULL; l = l->next) { |
2645 | - Inkscape::CanvasGrid* g = reinterpret_cast<Inkscape::CanvasGrid*>(l->data); |
2646 | - if (g) { |
2647 | - g->setOrigin(g->origin * tr); |
2648 | - } |
2649 | + for(std::vector<Inkscape::CanvasGrid *>::iterator it=this->grids.begin();it!=this->grids.end();++it ) { |
2650 | + (*it)->setOrigin((*it)->origin * tr); |
2651 | } |
2652 | } |
2653 | |
2654 | void SPNamedView::scrollAllDesktops(double dx, double dy, bool is_scrolling) { |
2655 | - for(GSList *l = views; l; l = l->next) { |
2656 | - SPDesktop *desktop = static_cast<SPDesktop *>(l->data); |
2657 | - desktop->scroll_world_in_svg_coords(dx, dy, is_scrolling); |
2658 | - } |
2659 | + for(std::vector<SPDesktop *>::iterator it=this->views.begin();it!=this->views.end();++it ) { |
2660 | + (*it)->scroll_world_in_svg_coords(dx, dy, is_scrolling); |
2661 | + } |
2662 | } |
2663 | |
2664 | |
2665 | |
2666 | === modified file 'src/sp-namedview.h' |
2667 | --- src/sp-namedview.h 2015-12-06 21:39:31 +0000 |
2668 | +++ src/sp-namedview.h 2015-12-09 15:31:04 +0000 |
2669 | @@ -21,6 +21,7 @@ |
2670 | #include "snap.h" |
2671 | #include "document.h" |
2672 | #include "util/units.h" |
2673 | +#include <vector> |
2674 | |
2675 | namespace Inkscape { |
2676 | class CanvasGrid; |
2677 | @@ -59,7 +60,7 @@ |
2678 | int window_maximized; |
2679 | |
2680 | SnapManager snap_manager; |
2681 | - GSList * grids; |
2682 | + std::vector<Inkscape::CanvasGrid *> grids; |
2683 | bool grids_visible; |
2684 | |
2685 | Inkscape::Util::Unit const *svg_units; // Units used for the values in SVG |
2686 | @@ -76,8 +77,8 @@ |
2687 | guint32 pagecolor; |
2688 | guint32 pageshadow; |
2689 | |
2690 | - GSList *guides; |
2691 | - GSList *views; |
2692 | + std::vector<SPGuide *> guides; |
2693 | + std::vector<SPDesktop *> views; |
2694 | |
2695 | int viewcount; |
2696 | |
2697 | @@ -86,7 +87,7 @@ |
2698 | void activateGuides(void* desktop, bool active); |
2699 | char const *getName() const; |
2700 | unsigned int getViewCount(); |
2701 | - GSList const *getViewList() const; |
2702 | + std::vector<SPDesktop *> const getViewList() const; |
2703 | Inkscape::Util::Unit const * getDisplayUnit() const; |
2704 | Inkscape::Util::Unit const & getSVGUnit() const; |
2705 | |
2706 | |
2707 | === modified file 'src/sp-object.h' |
2708 | --- src/sp-object.h 2015-05-02 01:47:39 +0000 |
2709 | +++ src/sp-object.h 2015-12-09 15:31:04 +0000 |
2710 | @@ -59,7 +59,6 @@ |
2711 | |
2712 | class SPCSSAttr; |
2713 | class SPStyle; |
2714 | -typedef struct _GSList GSList; |
2715 | |
2716 | namespace Inkscape { |
2717 | namespace XML { |
2718 | |
2719 | === modified file 'src/sp-switch.h' |
2720 | --- src/sp-switch.h 2015-02-19 19:20:09 +0000 |
2721 | +++ src/sp-switch.h 2015-12-09 15:31:04 +0000 |
2722 | @@ -17,7 +17,6 @@ |
2723 | |
2724 | #include "sp-item-group.h" |
2725 | |
2726 | -typedef struct _GSList GSList; |
2727 | |
2728 | #define SP_SWITCH(obj) (dynamic_cast<SPSwitch*>((SPObject*)obj)) |
2729 | #define SP_IS_SWITCH(obj) (dynamic_cast<const SPSwitch*>((SPObject*)obj) != NULL) |
2730 | |
2731 | === modified file 'src/ui/dialog/document-properties.cpp' |
2732 | --- src/ui/dialog/document-properties.cpp 2015-05-08 13:46:25 +0000 |
2733 | +++ src/ui/dialog/document-properties.cpp 2015-12-09 15:31:04 +0000 |
2734 | @@ -511,17 +511,16 @@ |
2735 | void DocumentProperties::populate_linked_profiles_box() |
2736 | { |
2737 | _LinkedProfilesListStore->clear(); |
2738 | - const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" ); |
2739 | - if (current) { |
2740 | - _emb_profiles_observer.set(SP_OBJECT(current->data)->parent); |
2741 | + std::set<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" ); |
2742 | + if (! current.empty()) { |
2743 | + _emb_profiles_observer.set((*(current.begin()))->parent); |
2744 | } |
2745 | - while ( current ) { |
2746 | - SPObject* obj = SP_OBJECT(current->data); |
2747 | + for (std::set<SPObject *>::const_iterator it = current.begin(); it != current.end(); ++it) { |
2748 | + SPObject* obj = *it; |
2749 | Inkscape::ColorProfile* prof = reinterpret_cast<Inkscape::ColorProfile*>(obj); |
2750 | Gtk::TreeModel::Row row = *(_LinkedProfilesListStore->append()); |
2751 | row[_LinkedProfilesListColumns.nameColumn] = prof->name; |
2752 | // row[_LinkedProfilesListColumns.previewColumn] = "Color Preview"; |
2753 | - current = g_slist_next(current); |
2754 | } |
2755 | } |
2756 | |
2757 | @@ -594,10 +593,9 @@ |
2758 | return; |
2759 | } |
2760 | } |
2761 | - |
2762 | - const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" ); |
2763 | - while ( current ) { |
2764 | - SPObject* obj = SP_OBJECT(current->data); |
2765 | + std::set<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList( "iccprofile" ); |
2766 | + for (std::set<SPObject *>::const_iterator it = current.begin(); it != current.end(); ++it) { |
2767 | + SPObject* obj = *it; |
2768 | Inkscape::ColorProfile* prof = reinterpret_cast<Inkscape::ColorProfile*>(obj); |
2769 | if (!name.compare(prof->name)){ |
2770 | |
2771 | @@ -606,7 +604,6 @@ |
2772 | DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_REMOVE_COLOR_PROFILE, _("Remove linked color profile")); |
2773 | break; // removing the color profile likely invalidates part of the traversed list, stop traversing here. |
2774 | } |
2775 | - current = g_slist_next(current); |
2776 | } |
2777 | |
2778 | populate_linked_profiles_box(); |
2779 | @@ -722,9 +719,9 @@ |
2780 | _LinkedProfilesList.signal_button_release_event().connect_notify(sigc::mem_fun(*this, &DocumentProperties::linked_profiles_list_button_release)); |
2781 | cms_create_popup_menu(_LinkedProfilesList, sigc::mem_fun(*this, &DocumentProperties::removeSelectedProfile)); |
2782 | |
2783 | - const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "defs" ); |
2784 | - if (current) { |
2785 | - _emb_profiles_observer.set(SP_OBJECT(current->data)->parent); |
2786 | + std::set<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList( "defs" ); |
2787 | + if (!current.empty()) { |
2788 | + _emb_profiles_observer.set((*(current.begin()))->parent); |
2789 | } |
2790 | _emb_profiles_observer.signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::populate_linked_profiles_box)); |
2791 | onColorProfileSelectRow(); |
2792 | @@ -959,9 +956,9 @@ |
2793 | #endif // defined(HAVE_LIBLCMS1) || defined(HAVE_LIBLCMS2) |
2794 | |
2795 | //TODO: review this observers code: |
2796 | - const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); |
2797 | - if (current) { |
2798 | - _scripts_observer.set(SP_OBJECT(current->data)->parent); |
2799 | + std::set<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); |
2800 | + if (! current.empty()) { |
2801 | + _scripts_observer.set((*(current.begin()))->parent); |
2802 | } |
2803 | _scripts_observer.signal_changed().connect(sigc::mem_fun(*this, &DocumentProperties::populate_script_lists)); |
2804 | onEmbeddedScriptSelectRow(); |
2805 | @@ -1174,9 +1171,9 @@ |
2806 | } |
2807 | } |
2808 | |
2809 | - const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); |
2810 | - while ( current ) { |
2811 | - SPObject* obj = reinterpret_cast<SPObject *>(current->data); |
2812 | + std::set<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); |
2813 | + for (std::set<SPObject *>::const_iterator it = current.begin(); it != current.end(); ++it) { |
2814 | + SPObject* obj = *it; |
2815 | if (obj) { |
2816 | SPScript* script = dynamic_cast<SPScript *>(obj); |
2817 | if (script && (name == script->xlinkhref)) { |
2818 | @@ -1191,7 +1188,6 @@ |
2819 | } |
2820 | } |
2821 | } |
2822 | - current = g_slist_next(current); |
2823 | } |
2824 | |
2825 | populate_script_lists(); |
2826 | @@ -1253,9 +1249,9 @@ |
2827 | } |
2828 | |
2829 | bool voidscript=true; |
2830 | - const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); |
2831 | - while ( current ) { |
2832 | - SPObject* obj = SP_OBJECT(current->data); |
2833 | + std::set<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); |
2834 | + for (std::set<SPObject *>::const_iterator it = current.begin(); it != current.end(); ++it) { |
2835 | + SPObject* obj = *it; |
2836 | if (id == obj->getId()){ |
2837 | |
2838 | int count=0; |
2839 | @@ -1279,7 +1275,6 @@ |
2840 | } |
2841 | } |
2842 | } |
2843 | - current = g_slist_next(current); |
2844 | } |
2845 | |
2846 | if (voidscript) |
2847 | @@ -1299,9 +1294,9 @@ |
2848 | } |
2849 | |
2850 | Inkscape::XML::Document *xml_doc = SP_ACTIVE_DOCUMENT->getReprDoc(); |
2851 | - const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); |
2852 | - while ( current ) { |
2853 | - SPObject* obj = SP_OBJECT(current->data); |
2854 | + std::set<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); |
2855 | + for (std::set<SPObject *>::const_iterator it = current.begin(); it != current.end(); ++it) { |
2856 | + SPObject* obj = *it; |
2857 | if (id == obj->getId()){ |
2858 | |
2859 | //XML Tree being used directly here while it shouldn't be. |
2860 | @@ -1317,21 +1312,20 @@ |
2861 | DocumentUndo::done(SP_ACTIVE_DOCUMENT, SP_VERB_EDIT_EMBEDDED_SCRIPT, _("Edit embedded script")); |
2862 | } |
2863 | } |
2864 | - current = g_slist_next(current); |
2865 | } |
2866 | } |
2867 | |
2868 | void DocumentProperties::populate_script_lists(){ |
2869 | _ExternalScriptsListStore->clear(); |
2870 | _EmbeddedScriptsListStore->clear(); |
2871 | - const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); |
2872 | - if (current) { |
2873 | - SPObject *obj = reinterpret_cast<SPObject *>(current->data); |
2874 | + std::set<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList( "script" ); |
2875 | + if (!current.empty()) { |
2876 | + SPObject *obj = *(current.begin()); |
2877 | g_assert(obj != NULL); |
2878 | _scripts_observer.set(obj->parent); |
2879 | } |
2880 | - while ( current ) { |
2881 | - SPObject* obj = reinterpret_cast<SPObject *>(current->data); |
2882 | + for (std::set<SPObject *>::const_iterator it = current.begin(); it != current.end(); ++it) { |
2883 | + SPObject* obj = *it; |
2884 | SPScript* script = dynamic_cast<SPScript *>(obj); |
2885 | g_assert(script != NULL); |
2886 | if (script->xlinkhref) |
2887 | @@ -1344,8 +1338,6 @@ |
2888 | Gtk::TreeModel::Row row = *(_EmbeddedScriptsListStore->append()); |
2889 | row[_EmbeddedScriptsListColumns.idColumn] = obj->getId(); |
2890 | } |
2891 | - |
2892 | - current = g_slist_next(current); |
2893 | } |
2894 | } |
2895 | |
2896 | @@ -1364,12 +1356,11 @@ |
2897 | |
2898 | //add tabs |
2899 | bool grids_present = false; |
2900 | - for (GSList const * l = nv->grids; l != NULL; l = l->next) { |
2901 | - Inkscape::CanvasGrid * grid = (Inkscape::CanvasGrid*) l->data; |
2902 | - if (!grid->repr->attribute("id")) continue; // update_gridspage is called again when "id" is added |
2903 | - Glib::ustring name(grid->repr->attribute("id")); |
2904 | + for(std::vector<Inkscape::CanvasGrid *>::const_iterator it = nv->grids.begin(); it != nv->grids.end(); ++it) { |
2905 | + if (!(*it)->repr->attribute("id")) continue; // update_gridspage is called again when "id" is added |
2906 | + Glib::ustring name((*it)->repr->attribute("id")); |
2907 | const char *icon = NULL; |
2908 | - switch (grid->getGridType()) { |
2909 | + switch ((*it)->getGridType()) { |
2910 | case GRID_RECTANGULAR: |
2911 | icon = "grid-rectangular"; |
2912 | break; |
2913 | @@ -1379,7 +1370,7 @@ |
2914 | default: |
2915 | break; |
2916 | } |
2917 | - _grids_notebook.append_page(*grid->newWidget(), _createPageTabLabel(name, icon)); |
2918 | + _grids_notebook.append_page(*(*it)->newWidget(), _createPageTabLabel(name, icon)); |
2919 | grids_present = true; |
2920 | } |
2921 | _grids_notebook.show_all(); |
2922 | @@ -1639,14 +1630,9 @@ |
2923 | SPDesktop *dt = getDesktop(); |
2924 | SPNamedView *nv = dt->getNamedView(); |
2925 | Inkscape::CanvasGrid * found_grid = NULL; |
2926 | - int i = 0; |
2927 | - for (GSList const * l = nv->grids; l != NULL; l = l->next, i++) { // not a very nice fix, but works. |
2928 | - Inkscape::CanvasGrid * grid = (Inkscape::CanvasGrid*) l->data; |
2929 | - if (pagenum == i) { |
2930 | - found_grid = grid; |
2931 | - break; // break out of for-loop |
2932 | - } |
2933 | - } |
2934 | + if( pagenum < nv->grids.size()) |
2935 | + found_grid = nv->grids[pagenum]; |
2936 | + |
2937 | if (found_grid) { |
2938 | // delete the grid that corresponds with the selected tab |
2939 | // when the grid is deleted from SVG, the SPNamedview handler automatically deletes the object, so found_grid becomes an invalid pointer! |
2940 | |
2941 | === modified file 'src/ui/dialog/filter-effects-dialog.cpp' |
2942 | --- src/ui/dialog/filter-effects-dialog.cpp 2015-11-13 17:53:22 +0000 |
2943 | +++ src/ui/dialog/filter-effects-dialog.cpp 2015-12-09 15:31:04 +0000 |
2944 | @@ -1589,13 +1589,14 @@ |
2945 | { |
2946 | SPDesktop* desktop = _dialog.getDesktop(); |
2947 | SPDocument* document = desktop->getDocument(); |
2948 | - const GSList* filters = document->getResourceList("filter"); |
2949 | + |
2950 | + std::set<SPObject *> filters = document->getResourceList( "filter" ); |
2951 | |
2952 | _model->clear(); |
2953 | |
2954 | - for(const GSList *l = filters; l; l = l->next) { |
2955 | + for (std::set<SPObject *>::const_iterator it = filters.begin(); it != filters.end(); ++it) { |
2956 | Gtk::TreeModel::Row row = *_model->append(); |
2957 | - SPFilter* f = SP_FILTER(l->data); |
2958 | + SPFilter* f = SP_FILTER(*it); |
2959 | row[_columns.filter] = f; |
2960 | const gchar* lbl = f->label(); |
2961 | const gchar* id = f->getId(); |
2962 | |
2963 | === modified file 'src/ui/dialog/layers.cpp' |
2964 | --- src/ui/dialog/layers.cpp 2015-06-03 04:50:17 +0000 |
2965 | +++ src/ui/dialog/layers.cpp 2015-12-09 15:31:04 +0000 |
2966 | @@ -1040,14 +1040,6 @@ |
2967 | _layersChanged(); |
2968 | } |
2969 | } |
2970 | -/* |
2971 | - GSList const *layers = _desktop->doc()->getResourceList( "layer" ); |
2972 | - g_message( "layers list starts at %p", layers ); |
2973 | - for ( GSList const *iter=layers ; iter ; iter = iter->next ) { |
2974 | - SPObject *layer=static_cast<SPObject *>(iter->data); |
2975 | - g_message(" {%s} [%s]", layer->id, layer->label() ); |
2976 | - } |
2977 | -*/ |
2978 | deskTrack.setBase(desktop); |
2979 | } |
2980 | |
2981 | |
2982 | === modified file 'src/ui/dialog/svg-fonts-dialog.cpp' |
2983 | --- src/ui/dialog/svg-fonts-dialog.cpp 2015-02-18 10:25:23 +0000 |
2984 | +++ src/ui/dialog/svg-fonts-dialog.cpp 2015-12-09 15:31:04 +0000 |
2985 | @@ -266,12 +266,12 @@ |
2986 | { |
2987 | SPDesktop* desktop = this->getDesktop(); |
2988 | SPDocument* document = desktop->getDocument(); |
2989 | - const GSList* fonts = document->getResourceList("font"); |
2990 | + std::set<SPObject *> fonts = document->getResourceList( "fonts" ); |
2991 | |
2992 | _model->clear(); |
2993 | - for(const GSList *l = fonts; l; l = l->next) { |
2994 | + for (std::set<SPObject *>::const_iterator it = fonts.begin(); it != fonts.end(); ++it) { |
2995 | Gtk::TreeModel::Row row = *_model->append(); |
2996 | - SPFont* f = SP_FONT(l->data); |
2997 | + SPFont* f = SP_FONT(*it); |
2998 | row[_columns.spfont] = f; |
2999 | row[_columns.svgfont] = new SvgFont(f); |
3000 | const gchar* lbl = f->label(); |
3001 | |
3002 | === modified file 'src/ui/dialog/swatches.cpp' |
3003 | --- src/ui/dialog/swatches.cpp 2015-02-19 03:25:21 +0000 |
3004 | +++ src/ui/dialog/swatches.cpp 2015-12-09 15:31:04 +0000 |
3005 | @@ -171,9 +171,9 @@ |
3006 | SPDocument *doc = desktop ? desktop->doc() : 0; |
3007 | if (doc) { |
3008 | std::string targetName(bounceTarget->def.descr); |
3009 | - const GSList *gradients = doc->getResourceList("gradient"); |
3010 | - for (const GSList *item = gradients; item; item = item->next) { |
3011 | - SPGradient* grad = SP_GRADIENT(item->data); |
3012 | + std::set<SPObject *> gradients = doc->getResourceList("gradient"); |
3013 | + for (std::set<SPObject *>::const_iterator item = gradients.begin(); item != gradients.end(); ++item) { |
3014 | + SPGradient* grad = SP_GRADIENT(*item); |
3015 | if ( targetName == grad->getId() ) { |
3016 | editGradientImpl( desktop, grad ); |
3017 | break; |
3018 | @@ -192,10 +192,10 @@ |
3019 | gint index = GPOINTER_TO_INT(userData); |
3020 | if ( doc && (index >= 0) && (static_cast<guint>(index) < popupItems.size()) ) { |
3021 | Glib::ustring targetName = popupItems[index]; |
3022 | + std::set<SPObject *> gradients = doc->getResourceList("gradient"); |
3023 | + for (std::set<SPObject *>::const_iterator item = gradients.begin(); item != gradients.end(); ++item) { |
3024 | + SPGradient* grad = SP_GRADIENT(*item); |
3025 | |
3026 | - const GSList *gradients = doc->getResourceList("gradient"); |
3027 | - for (const GSList *item = gradients; item; item = item->next) { |
3028 | - SPGradient* grad = SP_GRADIENT(item->data); |
3029 | if ( targetName == grad->getId() ) { |
3030 | grad->setSwatch(); |
3031 | DocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT, |
3032 | @@ -326,10 +326,10 @@ |
3033 | SPDesktopWidget *dtw = SP_DESKTOP_WIDGET(wdgt); |
3034 | if ( dtw && dtw->desktop ) { |
3035 | // Pick up all gradients with vectors |
3036 | - const GSList *gradients = (dtw->desktop->doc())->getResourceList("gradient"); |
3037 | + std::set<SPObject *> gradients = (dtw->desktop->doc())->getResourceList("gradient"); |
3038 | gint index = 0; |
3039 | - for (const GSList *curr = gradients; curr; curr = curr->next) { |
3040 | - SPGradient* grad = SP_GRADIENT(curr->data); |
3041 | + for (std::set<SPObject *>::const_iterator item = gradients.begin(); item != gradients.end(); ++item) { |
3042 | + SPGradient* grad = SP_GRADIENT(*item); |
3043 | if ( grad->hasStops() && !grad->isSwatch() ) { |
3044 | //gl = g_slist_prepend(gl, curr->data); |
3045 | processed = true; |
3046 | @@ -923,12 +923,11 @@ |
3047 | std::map<ColorItem*, SPGradient*> &gradMappings) |
3048 | { |
3049 | std::vector<SPGradient*> newList; |
3050 | - |
3051 | - const GSList *gradients = doc->getResourceList("gradient"); |
3052 | - for (const GSList *item = gradients; item; item = item->next) { |
3053 | - SPGradient* grad = SP_GRADIENT(item->data); |
3054 | + std::set<SPObject *> gradients = doc->getResourceList("gradient"); |
3055 | + for (std::set<SPObject *>::const_iterator item = gradients.begin(); item != gradients.end(); ++item) { |
3056 | + SPGradient* grad = SP_GRADIENT(*item); |
3057 | if ( grad->isSwatch() ) { |
3058 | - newList.push_back(SP_GRADIENT(item->data)); |
3059 | + newList.push_back(SP_GRADIENT(*item)); |
3060 | } |
3061 | } |
3062 | |
3063 | |
3064 | === modified file 'src/ui/interface.cpp' |
3065 | --- src/ui/interface.cpp 2015-12-08 01:24:07 +0000 |
3066 | +++ src/ui/interface.cpp 2015-12-09 15:31:04 +0000 |
3067 | @@ -1116,9 +1116,9 @@ |
3068 | unsigned int b = color.getB(); |
3069 | |
3070 | SPGradient* matches = 0; |
3071 | - const GSList *gradients = doc->getResourceList("gradient"); |
3072 | - for (const GSList *item = gradients; item; item = item->next) { |
3073 | - SPGradient* grad = SP_GRADIENT(item->data); |
3074 | + std::set<SPObject *> gradients = doc->getResourceList("gradient"); |
3075 | + for (std::set<SPObject *>::const_iterator item = gradients.begin(); item != gradients.end(); ++item) { |
3076 | + SPGradient* grad = SP_GRADIENT(*item); |
3077 | if ( color.descr == grad->getId() ) { |
3078 | if ( grad->hasStops() ) { |
3079 | matches = grad; |
3080 | |
3081 | === modified file 'src/ui/tools/gradient-tool.cpp' |
3082 | --- src/ui/tools/gradient-tool.cpp 2015-11-13 17:53:22 +0000 |
3083 | +++ src/ui/tools/gradient-tool.cpp 2015-12-09 15:31:04 +0000 |
3084 | @@ -225,13 +225,13 @@ |
3085 | std::vector<Geom::Point> coords; |
3086 | |
3087 | // for all selected draggers |
3088 | - for (GList *i = drag->selected; i != NULL; i = i->next) { |
3089 | - GrDragger *dragger = (GrDragger *) i->data; |
3090 | + for (std::set<GrDragger *>::const_iterator i = drag->selected.begin(); i != drag->selected.end() ; ++i ) { |
3091 | + GrDragger *dragger = *i; |
3092 | // remember the coord of the dragger to reselect it later |
3093 | coords.push_back(dragger->point); |
3094 | // for all draggables of dragger |
3095 | - for (GSList const* j = dragger->draggables; j != NULL; j = j->next) { |
3096 | - GrDraggable *d = (GrDraggable *) j->data; |
3097 | + for (std::vector<GrDraggable *>::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end(); ++j) { |
3098 | + GrDraggable *d = *j; |
3099 | |
3100 | // find the gradient |
3101 | SPGradient *gradient = getGradient(d->item, d->fill_or_stroke); |
3102 | @@ -315,9 +315,9 @@ |
3103 | |
3104 | if (g_slist_length(these_stops) == 0 && drag->numSelected() == 1) { |
3105 | // if a single stop is selected, add between that stop and the next one |
3106 | - GrDragger *dragger = (GrDragger *) drag->selected->data; |
3107 | - for (GSList const* j = dragger->draggables; j != NULL; j = j->next) { |
3108 | - GrDraggable *d = (GrDraggable *) j->data; |
3109 | + GrDragger *dragger = *(drag->selected.begin()); |
3110 | + for (std::vector<GrDraggable *>::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end(); ++j) { |
3111 | + GrDraggable *d = *j; |
3112 | if (d->point_type == POINT_RG_FOCUS) { |
3113 | /* |
3114 | * There are 2 draggables at the center (start) of a radial gradient |
3115 | @@ -482,9 +482,9 @@ |
3116 | bool over_line = false; |
3117 | SPCtrlLine *line = NULL; |
3118 | |
3119 | - if (drag->lines) { |
3120 | - for (GSList *l = drag->lines; (l != NULL) && (!over_line); l = l->next) { |
3121 | - line = (SPCtrlLine*) l->data; |
3122 | + if (!drag->lines.empty()) { |
3123 | + for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); ++l) { |
3124 | + line = *l; |
3125 | over_line |= sp_gradient_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y)); |
3126 | } |
3127 | } |
3128 | @@ -588,9 +588,9 @@ |
3129 | |
3130 | bool over_line = false; |
3131 | |
3132 | - if (drag->lines) { |
3133 | - for (GSList *l = drag->lines; l != NULL; l = l->next) { |
3134 | - over_line |= sp_gradient_context_is_over_line (this, (SPItem*) l->data, Geom::Point(event->motion.x, event->motion.y)); |
3135 | + if (!drag->lines.empty()) { |
3136 | + for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end(); ++l) { |
3137 | + over_line |= sp_gradient_context_is_over_line (this, (SPItem*) (*l), Geom::Point(event->motion.x, event->motion.y)); |
3138 | } |
3139 | } |
3140 | |
3141 | @@ -613,12 +613,10 @@ |
3142 | bool over_line = false; |
3143 | SPCtrlLine *line = NULL; |
3144 | |
3145 | - if (drag->lines) { |
3146 | - for (GSList *l = drag->lines; (l != NULL) && (!over_line); l = l->next) { |
3147 | - line = (SPCtrlLine*) l->data; |
3148 | + if (!drag->lines.empty()) { |
3149 | + for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); ++l) { |
3150 | + line = *l; |
3151 | over_line = sp_gradient_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y)); |
3152 | - if (over_line) |
3153 | - break; |
3154 | } |
3155 | } |
3156 | |
3157 | @@ -663,7 +661,7 @@ |
3158 | } |
3159 | } else { |
3160 | // click in an empty space; do the same as Esc |
3161 | - if (drag->selected) { |
3162 | + if (!drag->selected.empty()) { |
3163 | drag->deselectAll(); |
3164 | } else { |
3165 | selection->clear(); |
3166 | @@ -719,7 +717,7 @@ |
3167 | break; |
3168 | |
3169 | case GDK_KEY_Escape: |
3170 | - if (drag->selected) { |
3171 | + if (!drag->selected.empty()) { |
3172 | drag->deselectAll(); |
3173 | } else { |
3174 | Inkscape::SelectionHelper::selectNone(desktop); |
3175 | |
3176 | === modified file 'src/ui/tools/mesh-tool.cpp' |
3177 | --- src/ui/tools/mesh-tool.cpp 2015-12-07 20:20:33 +0000 |
3178 | +++ src/ui/tools/mesh-tool.cpp 2015-12-09 15:31:04 +0000 |
3179 | @@ -332,11 +332,11 @@ |
3180 | |
3181 | // Get list of selected draggers for each mesh. |
3182 | // For all selected draggers |
3183 | - for (GList *i = drag->selected; i != NULL; i = i->next) { |
3184 | - GrDragger *dragger = (GrDragger *) i->data; |
3185 | + for (std::set<GrDragger *>::const_iterator i = drag->selected.begin(); i != drag->selected.end(); ++i) { |
3186 | + GrDragger *dragger = *i; |
3187 | // For all draggables of dragger |
3188 | - for (GSList const* j = dragger->draggables; j != NULL; j = j->next) { |
3189 | - GrDraggable *d = (GrDraggable *) j->data; |
3190 | + for (std::vector<GrDraggable *>::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end() ; ++j) { |
3191 | + GrDraggable *d = *j; |
3192 | |
3193 | // Only mesh corners |
3194 | if( d->point_type != POINT_MG_CORNER ) continue; |
3195 | @@ -457,9 +457,9 @@ |
3196 | bool over_line = false; |
3197 | SPCtrlCurve *line = NULL; |
3198 | |
3199 | - if (drag->lines) { |
3200 | - for (GSList *l = drag->lines; (l != NULL) && (!over_line); l = l->next) { |
3201 | - line = (SPCtrlCurve*) l->data; |
3202 | + if (! drag->lines.empty()) { |
3203 | + for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); l++) { |
3204 | + line = (SPCtrlCurve*) (*l); |
3205 | over_line |= sp_mesh_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y)); |
3206 | } |
3207 | } |
3208 | @@ -593,9 +593,9 @@ |
3209 | // Change cursor shape if over line |
3210 | bool over_line = false; |
3211 | |
3212 | - if (drag->lines) { |
3213 | - for (GSList *l = drag->lines; l != NULL; l = l->next) { |
3214 | - over_line |= sp_mesh_context_is_over_line (this, (SPItem*) l->data, Geom::Point(event->motion.x, event->motion.y)); |
3215 | + if (!drag->lines.empty()) { |
3216 | + for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() ; l++) { |
3217 | + over_line |= sp_mesh_context_is_over_line (this, (SPItem*)(*l), Geom::Point(event->motion.x, event->motion.y)); |
3218 | } |
3219 | } |
3220 | |
3221 | @@ -624,9 +624,9 @@ |
3222 | bool over_line = false; |
3223 | SPCtrlLine *line = NULL; |
3224 | |
3225 | - if (drag->lines) { |
3226 | - for (GSList *l = drag->lines; (l != NULL) && (!over_line); l = l->next) { |
3227 | - line = (SPCtrlLine*) l->data; |
3228 | + if (!drag->lines.empty()) { |
3229 | + for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); l++) { |
3230 | + line = (SPCtrlLine*)(*l); |
3231 | over_line = sp_mesh_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y)); |
3232 | |
3233 | if (over_line) { |
3234 | @@ -678,7 +678,7 @@ |
3235 | } |
3236 | } else { |
3237 | // click in an empty space; do the same as Esc |
3238 | - if (drag->selected) { |
3239 | + if (!drag->selected.empty()) { |
3240 | drag->deselectAll(); |
3241 | } else { |
3242 | selection->clear(); |
3243 | @@ -724,7 +724,7 @@ |
3244 | break; |
3245 | |
3246 | case GDK_KEY_Escape: |
3247 | - if (drag->selected) { |
3248 | + if (!drag->selected.empty()) { |
3249 | drag->deselectAll(); |
3250 | } else { |
3251 | selection->clear(); |
3252 | @@ -841,7 +841,7 @@ |
3253 | case GDK_KEY_Delete: |
3254 | case GDK_KEY_KP_Delete: |
3255 | case GDK_KEY_BackSpace: |
3256 | - if ( drag->selected ) { |
3257 | + if ( !drag->selected.empty() ) { |
3258 | std::cout << "Deleting mesh stops not implemented yet" << std::endl; |
3259 | ret = TRUE; |
3260 | } |
3261 | |
3262 | === modified file 'src/ui/tools/select-tool.cpp' |
3263 | --- src/ui/tools/select-tool.cpp 2015-05-08 13:46:25 +0000 |
3264 | +++ src/ui/tools/select-tool.cpp 2015-12-09 15:31:04 +0000 |
3265 | @@ -89,10 +89,6 @@ |
3266 | , button_press_shift(false) |
3267 | , button_press_ctrl(false) |
3268 | , button_press_alt(false) |
3269 | - , cycling_items(NULL) |
3270 | - , cycling_items_cmp(NULL) |
3271 | - , cycling_items_selected_before(NULL) |
3272 | - , cycling_cur_item(NULL) |
3273 | , cycling_wrap(true) |
3274 | , item(NULL) |
3275 | , grabbed(NULL) |
3276 | @@ -390,16 +386,16 @@ |
3277 | } |
3278 | |
3279 | void SelectTool::sp_select_context_cycle_through_items(Inkscape::Selection *selection, GdkEventScroll *scroll_event, bool shift_pressed) { |
3280 | - if (!this->cycling_cur_item) { |
3281 | + if (this->cycling_cur_item == this->cycling_items.end()) { |
3282 | return; |
3283 | } |
3284 | |
3285 | Inkscape::DrawingItem *arenaitem; |
3286 | - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(cycling_cur_item->data)); |
3287 | + SPItem *item = *cycling_cur_item; |
3288 | g_assert(item != NULL); |
3289 | |
3290 | // Deactivate current item |
3291 | - if (!g_list_find(this->cycling_items_selected_before, item) && selection->includes(item)) { |
3292 | + if (std::find(cycling_items_selected_before.begin(), cycling_items_selected_before.end(), item) == cycling_items_selected_before.end() && selection->includes(item)) { |
3293 | selection->remove(item); |
3294 | } |
3295 | |
3296 | @@ -407,20 +403,20 @@ |
3297 | arenaitem->setOpacity(0.3); |
3298 | |
3299 | // Find next item and activate it |
3300 | - GList *next; |
3301 | + std::vector<SPItem *>::iterator next = this->cycling_cur_item; |
3302 | if (scroll_event->direction == GDK_SCROLL_UP) { |
3303 | - next = this->cycling_cur_item->next; |
3304 | - if (next == NULL && this->cycling_wrap) |
3305 | - next = this->cycling_items; |
3306 | + next++; |
3307 | + if (next == this->cycling_items.end() && this->cycling_wrap) |
3308 | + next = this->cycling_items.begin(); |
3309 | } else { |
3310 | - next = this->cycling_cur_item->prev; |
3311 | - if (next == NULL && this->cycling_wrap) |
3312 | - next = g_list_last(this->cycling_items); |
3313 | + if(next == this->cycling_items.begin()) |
3314 | + next = this->cycling_items.end(); |
3315 | + next--; |
3316 | } |
3317 | |
3318 | - if (next) { |
3319 | + if (next!=this->cycling_items.end()) { |
3320 | this->cycling_cur_item = next; |
3321 | - item = dynamic_cast<SPItem *>(static_cast<SPObject *>(this->cycling_cur_item->data)); |
3322 | + item = *next; |
3323 | g_assert(item != NULL); |
3324 | } |
3325 | |
3326 | @@ -435,8 +431,8 @@ |
3327 | } |
3328 | |
3329 | void SelectTool::sp_select_context_reset_opacities() { |
3330 | - for (GList *l = this->cycling_items; l != NULL; l = g_list_next(l)) { |
3331 | - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(l->data)); |
3332 | + for (std::vector<SPItem *>::const_iterator l = this->cycling_items.begin(); l != this->cycling_items.end(); ++l ) { |
3333 | + SPItem *item = *l; |
3334 | if (item) { |
3335 | Inkscape::DrawingItem *arenaitem = item->get_arenaitem(desktop->dkey); |
3336 | arenaitem->setOpacity(SP_SCALE24_TO_FLOAT(item->style->opacity.value)); |
3337 | @@ -445,14 +441,10 @@ |
3338 | } |
3339 | } |
3340 | |
3341 | - g_list_free(this->cycling_items); |
3342 | - g_list_free(this->cycling_items_selected_before); |
3343 | - g_list_free(this->cycling_items_cmp); |
3344 | - |
3345 | - this->cycling_items = NULL; |
3346 | - this->cycling_items_selected_before = NULL; |
3347 | - this->cycling_cur_item = NULL; |
3348 | - this->cycling_items_cmp = NULL; |
3349 | + this->cycling_items.clear(); |
3350 | + this->cycling_items_selected_before.clear(); |
3351 | + this->cycling_cur_item = this->cycling_items.end(); |
3352 | + this->cycling_items_cmp.clear(); |
3353 | } |
3354 | |
3355 | bool SelectTool::root_handler(GdkEvent* event) { |
3356 | @@ -819,70 +811,57 @@ |
3357 | SPItem *item = desktop->getItemAtPoint(p, true, NULL); |
3358 | |
3359 | // Save pointer to current cycle-item so that we can find it again later, in the freshly built list |
3360 | - SPItem *tmp_cur_item = this->cycling_cur_item ? dynamic_cast<SPItem *>(static_cast<SPObject *>(this->cycling_cur_item->data)) : NULL; |
3361 | - g_list_free(this->cycling_items); |
3362 | - this->cycling_items = NULL; |
3363 | - this->cycling_cur_item = NULL; |
3364 | - |
3365 | + SPItem *tmp_cur_item = this->cycling_cur_item!=this->cycling_items.end() ? (*(this->cycling_cur_item)) : NULL; |
3366 | + this->cycling_items.clear(); |
3367 | + this->cycling_cur_item = this->cycling_items.end(); |
3368 | while(item != NULL) { |
3369 | - this->cycling_items = g_list_append(this->cycling_items, item); |
3370 | + this->cycling_items.push_back(item); |
3371 | item = desktop->getItemAtPoint(p, true, item); |
3372 | } |
3373 | |
3374 | /* Compare current item list with item list during previous scroll ... */ |
3375 | - GList *l1, *l2; |
3376 | - bool item_lists_differ = false; |
3377 | - |
3378 | - // Note that we can do an 'or' comparison in the loop because it is safe to call g_list_next with a NULL pointer. |
3379 | - for (l1 = this->cycling_items, l2 = this->cycling_items_cmp; l1 != NULL || l2 != NULL; l1 = g_list_next(l1), l2 = g_list_next(l2)) { |
3380 | - if ((l1 !=NULL && l2 == NULL) || (l1 == NULL && l2 != NULL) || (l1->data != l2->data)) { |
3381 | - item_lists_differ = true; |
3382 | - break; |
3383 | - } |
3384 | - } |
3385 | + bool item_lists_differ = this->cycling_items != this->cycling_items_cmp; |
3386 | |
3387 | /* If list of items under mouse pointer hasn't changed ... */ |
3388 | if (!item_lists_differ) { |
3389 | // ... find current item in the freshly built list and continue cycling ... |
3390 | // TODO: This wouldn't be necessary if cycling_cur_item pointed to an element of cycling_items_cmp instead |
3391 | - this->cycling_cur_item = g_list_find(this->cycling_items, tmp_cur_item); |
3392 | - g_assert(this->cycling_cur_item != NULL || this->cycling_items == NULL); |
3393 | + this->cycling_cur_item = std::find(this->cycling_items.begin(), this->cycling_items.end(), tmp_cur_item); |
3394 | + g_assert(this->cycling_cur_item != this->cycling_items.end() || this->cycling_items.empty()); |
3395 | } else { |
3396 | // ... otherwise reset opacities for outdated items ... |
3397 | Inkscape::DrawingItem *arenaitem; |
3398 | |
3399 | - for(GList *l = this->cycling_items_cmp; l != NULL; l = l->next) { |
3400 | - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(l->data)); |
3401 | + for (std::vector<SPItem *>::const_iterator l = this->cycling_items_cmp.begin(); l != this->cycling_items_cmp.end(); ++l) { |
3402 | + SPItem *item = *l; |
3403 | if (item) { |
3404 | arenaitem = item->get_arenaitem(desktop->dkey); |
3405 | arenaitem->setOpacity(1.0); |
3406 | //if (!shift_pressed && !g_list_find(this->cycling_items_selected_before, item) && selection->includes(item)) |
3407 | - if (!g_list_find(this->cycling_items_selected_before, item) && selection->includes(item)) { |
3408 | + if (std::find(this->cycling_items_selected_before.begin(),this->cycling_items_selected_before.end(), item)==this->cycling_items_selected_before.end() && selection->includes(item)) { |
3409 | selection->remove(item); |
3410 | } |
3411 | } |
3412 | } |
3413 | |
3414 | // ... clear the lists ... |
3415 | - g_list_free(this->cycling_items_cmp); |
3416 | - g_list_free(this->cycling_items_selected_before); |
3417 | |
3418 | - this->cycling_items_cmp = NULL; |
3419 | - this->cycling_items_selected_before = NULL; |
3420 | - this->cycling_cur_item = NULL; |
3421 | + this->cycling_items_cmp.clear(); |
3422 | + this->cycling_items_selected_before.clear(); |
3423 | + this->cycling_cur_item = this->cycling_items.end(); |
3424 | |
3425 | // ... and rebuild them with the new items. |
3426 | - this->cycling_items_cmp = g_list_copy(this->cycling_items); |
3427 | + this->cycling_items_cmp = (this->cycling_items); |
3428 | |
3429 | - for(GList *l = this->cycling_items; l != NULL; l = l->next) { |
3430 | - SPItem *item = dynamic_cast<SPItem *>(static_cast<SPObject *>(l->data)); |
3431 | + for(std::vector<SPItem *>::const_iterator l = this->cycling_items.begin(); l != this->cycling_items.end(); ++l) { |
3432 | + SPItem *item =*l; |
3433 | if (item) { |
3434 | arenaitem = item->get_arenaitem(desktop->dkey); |
3435 | arenaitem->setOpacity(0.3); |
3436 | |
3437 | if (selection->includes(item)) { |
3438 | // already selected items are stored separately, too |
3439 | - this->cycling_items_selected_before = g_list_append(this->cycling_items_selected_before, item); |
3440 | + this->cycling_items_selected_before.push_back(item); |
3441 | } |
3442 | } else { |
3443 | g_assert_not_reached(); |
3444 | @@ -890,7 +869,8 @@ |
3445 | } |
3446 | |
3447 | // set the current item to the bottommost one so that the cycling step below re-starts at the top |
3448 | - this->cycling_cur_item = g_list_last(this->cycling_items); |
3449 | + this->cycling_cur_item = this->cycling_items.end(); |
3450 | + this->cycling_cur_item--; |
3451 | } |
3452 | |
3453 | this->cycling_wrap = prefs->getBool("/options/selection/cycleWrap", true); |
3454 | |
3455 | === modified file 'src/ui/tools/select-tool.h' |
3456 | --- src/ui/tools/select-tool.h 2014-10-08 02:22:03 +0000 |
3457 | +++ src/ui/tools/select-tool.h 2015-12-09 15:31:04 +0000 |
3458 | @@ -40,10 +40,10 @@ |
3459 | bool button_press_ctrl; |
3460 | bool button_press_alt; |
3461 | |
3462 | - GList *cycling_items; |
3463 | - GList *cycling_items_cmp; |
3464 | - GList *cycling_items_selected_before; |
3465 | - GList *cycling_cur_item; |
3466 | + std::vector<SPItem *> cycling_items; |
3467 | + std::vector<SPItem *> cycling_items_cmp; |
3468 | + std::vector<SPItem *> cycling_items_selected_before; |
3469 | + std::vector<SPItem *>::iterator cycling_cur_item; |
3470 | bool cycling_wrap; |
3471 | |
3472 | SPItem *item; |
3473 | |
3474 | === modified file 'src/ui/tools/tool-base.cpp' |
3475 | --- src/ui/tools/tool-base.cpp 2015-10-03 14:09:07 +0000 |
3476 | +++ src/ui/tools/tool-base.cpp 2015-12-09 15:31:04 +0000 |
3477 | @@ -924,7 +924,7 @@ |
3478 | */ |
3479 | bool ToolBase::deleteSelectedDrag(bool just_one) { |
3480 | |
3481 | - if (_grdrag && _grdrag->selected) { |
3482 | + if (_grdrag && !_grdrag->selected.empty()) { |
3483 | _grdrag->deleteSelected(just_one); |
3484 | return TRUE; |
3485 | } |
3486 | |
3487 | === modified file 'src/ui/widget/color-icc-selector.cpp' |
3488 | --- src/ui/widget/color-icc-selector.cpp 2015-05-17 11:43:24 +0000 |
3489 | +++ src/ui/widget/color-icc-selector.cpp 2015-12-09 15:31:04 +0000 |
3490 | @@ -676,9 +676,9 @@ |
3491 | gtk_combo_box_set_active(combo, 0); |
3492 | |
3493 | int index = 1; |
3494 | - const GSList *current = SP_ACTIVE_DOCUMENT->getResourceList("iccprofile"); |
3495 | - while (current) { |
3496 | - SPObject *obj = SP_OBJECT(current->data); |
3497 | + std::set<SPObject *> current = SP_ACTIVE_DOCUMENT->getResourceList("iccprofile"); |
3498 | + for (std::set<SPObject *>::const_iterator it = current.begin(); it != current.end(); ++it) { |
3499 | + SPObject *obj = *it; |
3500 | Inkscape::ColorProfile *prof = reinterpret_cast<Inkscape::ColorProfile *>(obj); |
3501 | |
3502 | gtk_list_store_append(store, &iter); |
3503 | @@ -690,7 +690,6 @@ |
3504 | } |
3505 | |
3506 | index++; |
3507 | - current = g_slist_next(current); |
3508 | } |
3509 | |
3510 | g_signal_handler_unblock(G_OBJECT(_profileSel), _profChangedID); |
3511 | |
3512 | === modified file 'src/unclump.h' |
3513 | --- src/unclump.h 2015-02-27 02:10:36 +0000 |
3514 | +++ src/unclump.h 2015-12-09 15:31:04 +0000 |
3515 | @@ -11,7 +11,6 @@ |
3516 | #ifndef SEEN_DIALOGS_UNCLUMP_H |
3517 | #define SEEN_DIALOGS_UNCLUMP_H |
3518 | |
3519 | -typedef struct _GSList GSList; |
3520 | |
3521 | void unclump(std::vector<SPItem*> &items); |
3522 | |
3523 | |
3524 | === modified file 'src/vanishing-point.cpp' |
3525 | --- src/vanishing-point.cpp 2015-12-07 20:19:14 +0000 |
3526 | +++ src/vanishing-point.cpp 2015-12-09 15:31:04 +0000 |
3527 | @@ -137,8 +137,8 @@ |
3528 | |
3529 | if (!(state & GDK_SHIFT_MASK)) { |
3530 | // without Shift; see if we need to snap to another dragger |
3531 | - for (GList *di = dragger->parent->draggers; di != NULL; di = di->next) { |
3532 | - VPDragger *d_new = (VPDragger *) di->data; |
3533 | + for (std::vector<VPDragger *>::const_iterator di = dragger->parent->draggers.begin(); di != dragger->parent->draggers.end(); ++di) { |
3534 | + VPDragger *d_new = *di; |
3535 | if ((d_new != dragger) && (Geom::L2 (d_new->point - p) < snap_dist)) { |
3536 | if (have_VPs_of_same_perspective (dragger, d_new)) { |
3537 | // this would result in degenerate boxes, which we disallow for the time being |
3538 | @@ -155,7 +155,7 @@ |
3539 | d_new->vps.merge(dragger->vps); |
3540 | |
3541 | // ... delete old dragger ... |
3542 | - drag->draggers = g_list_remove (drag->draggers, dragger); |
3543 | + drag->draggers.erase(std::remove(drag->draggers.begin(), drag->draggers.end(), dragger),drag->draggers.end()); |
3544 | delete dragger; |
3545 | dragger = NULL; |
3546 | |
3547 | @@ -494,8 +494,6 @@ |
3548 | this->document = document; |
3549 | this->selection = SP_ACTIVE_DESKTOP->getSelection(); |
3550 | |
3551 | - this->draggers = NULL; |
3552 | - this->lines = NULL; |
3553 | this->show_lines = true; |
3554 | this->front_or_rear_lines = 0x1; |
3555 | |
3556 | @@ -522,17 +520,15 @@ |
3557 | this->sel_changed_connection.disconnect(); |
3558 | this->sel_modified_connection.disconnect(); |
3559 | |
3560 | - for (GList *l = this->draggers; l != NULL; l = l->next) { |
3561 | - delete ((VPDragger *) l->data); |
3562 | + for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) { |
3563 | + delete (*i); |
3564 | } |
3565 | - g_list_free (this->draggers); |
3566 | - this->draggers = NULL; |
3567 | + this->draggers.clear(); |
3568 | |
3569 | - for (GSList const *i = this->lines; i != NULL; i = i->next) { |
3570 | - sp_canvas_item_destroy(SP_CANVAS_ITEM(i->data)); |
3571 | + for (std::vector<SPCtrlLine *>::const_iterator i = this->lines.begin(); i != this->lines.end(); ++i) { |
3572 | + sp_canvas_item_destroy(SP_CANVAS_ITEM(*i)); |
3573 | } |
3574 | - g_slist_free (this->lines); |
3575 | - this->lines = NULL; |
3576 | + this->lines.clear(); |
3577 | } |
3578 | |
3579 | /** |
3580 | @@ -541,8 +537,8 @@ |
3581 | VPDragger * |
3582 | VPDrag::getDraggerFor (VanishingPoint const &vp) |
3583 | { |
3584 | - for (GList const* i = this->draggers; i != NULL; i = i->next) { |
3585 | - VPDragger *dragger = (VPDragger *) i->data; |
3586 | + for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) { |
3587 | + VPDragger *dragger = *i; |
3588 | for (std::list<VanishingPoint>::iterator j = dragger->vps.begin(); j != dragger->vps.end(); ++j) { |
3589 | // TODO: Should we compare the pointers or the VPs themselves!?!?!?! |
3590 | if (*j == vp) { |
3591 | @@ -557,8 +553,8 @@ |
3592 | VPDrag::printDraggers () |
3593 | { |
3594 | g_print ("=== VPDrag info: =================================\n"); |
3595 | - for (GList const* i = this->draggers; i != NULL; i = i->next) { |
3596 | - ((VPDragger *) i->data)->printVPs(); |
3597 | + for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) { |
3598 | + (*i)->printVPs(); |
3599 | g_print ("========\n"); |
3600 | } |
3601 | g_print ("=================================================\n"); |
3602 | @@ -573,11 +569,10 @@ |
3603 | if (this->dragging) |
3604 | return; |
3605 | // delete old draggers |
3606 | - for (GList const* i = this->draggers; i != NULL; i = i->next) { |
3607 | - delete ((VPDragger *) i->data); |
3608 | + for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) { |
3609 | + delete (*i); |
3610 | } |
3611 | - g_list_free (this->draggers); |
3612 | - this->draggers = NULL; |
3613 | + this->draggers.clear(); |
3614 | |
3615 | g_return_if_fail (this->selection != NULL); |
3616 | |
3617 | @@ -603,11 +598,10 @@ |
3618 | VPDrag::updateLines () |
3619 | { |
3620 | // delete old lines |
3621 | - for (GSList const *i = this->lines; i != NULL; i = i->next) { |
3622 | - sp_canvas_item_destroy(SP_CANVAS_ITEM(i->data)); |
3623 | + for (std::vector<SPCtrlLine *>::const_iterator i = this->lines.begin(); i != this->lines.end(); ++i) { |
3624 | + sp_canvas_item_destroy(SP_CANVAS_ITEM(*i)); |
3625 | } |
3626 | - g_slist_free (this->lines); |
3627 | - this->lines = NULL; |
3628 | + this->lines.clear(); |
3629 | |
3630 | // do nothing if perspective lines are currently disabled |
3631 | if (this->show_lines == 0) return; |
3632 | @@ -651,8 +645,8 @@ |
3633 | void |
3634 | VPDrag::updateBoxReprs () |
3635 | { |
3636 | - for (GList *i = this->draggers; i != NULL; i = i->next) { |
3637 | - VPDragger *dragger = (VPDragger *) i->data; |
3638 | + for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) { |
3639 | + VPDragger *dragger = *i; |
3640 | for (std::list<VanishingPoint>::iterator i = dragger->vps.begin(); i != dragger->vps.end(); ++i) { |
3641 | (*i).updateBoxReprs(); |
3642 | } |
3643 | @@ -662,8 +656,8 @@ |
3644 | void |
3645 | VPDrag::updateBoxDisplays () |
3646 | { |
3647 | - for (GList *i = this->draggers; i != NULL; i = i->next) { |
3648 | - VPDragger *dragger = (VPDragger *) i->data; |
3649 | + for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) { |
3650 | + VPDragger *dragger = *i; |
3651 | for (std::list<VanishingPoint>::iterator i = dragger->vps.begin(); i != dragger->vps.end(); ++i) { |
3652 | (*i).updateBoxDisplays(); |
3653 | } |
3654 | @@ -758,8 +752,8 @@ |
3655 | } |
3656 | Geom::Point p = vp.get_pos(); |
3657 | |
3658 | - for (GList *i = this->draggers; i != NULL; i = i->next) { |
3659 | - VPDragger *dragger = (VPDragger *) i->data; |
3660 | + for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) { |
3661 | + VPDragger *dragger = *i; |
3662 | if (Geom::L2 (dragger->point - p) < MERGE_DIST) { |
3663 | // distance is small, merge this draggable into dragger, no need to create new dragger |
3664 | dragger->addVP (vp); |
3665 | @@ -769,16 +763,16 @@ |
3666 | |
3667 | VPDragger *new_dragger = new VPDragger(this, p, vp); |
3668 | // fixme: draggers should be added AFTER the last one: this way tabbing through them will be from begin to end. |
3669 | - this->draggers = g_list_append (this->draggers, new_dragger); |
3670 | + this->draggers.push_back(new_dragger); |
3671 | } |
3672 | |
3673 | void |
3674 | VPDrag::swap_perspectives_of_VPs(Persp3D *persp2, Persp3D *persp1) |
3675 | { |
3676 | // iterate over all VP in all draggers and replace persp2 with persp1 |
3677 | - for (GList *i = this->draggers; i != NULL; i = i->next) { |
3678 | - for (std::list<VanishingPoint>::iterator j = ((VPDragger *) (i->data))->vps.begin(); |
3679 | - j != ((VPDragger *) (i->data))->vps.end(); ++j) { |
3680 | + for (std::vector<VPDragger *>::const_iterator i = this->draggers.begin(); i != this->draggers.end(); ++i) { |
3681 | + for (std::list<VanishingPoint>::iterator j = (*i)->vps.begin(); |
3682 | + j != (*i)->vps.end(); ++j) { |
3683 | if ((*j).get_perspective() == persp2) { |
3684 | (*j).set_perspective(persp1); |
3685 | } |
3686 | @@ -790,7 +784,7 @@ |
3687 | { |
3688 | SPCtrlLine *line = ControlManager::getManager().createControlLine(SP_ACTIVE_DESKTOP->getControls(), p1, p2, type); |
3689 | sp_canvas_item_show(line); |
3690 | - this->lines = g_slist_append(this->lines, line); |
3691 | + this->lines.push_back(line); |
3692 | } |
3693 | |
3694 | } // namespace Box3D |
3695 | |
3696 | === modified file 'src/vanishing-point.h' |
3697 | --- src/vanishing-point.h 2014-10-08 02:22:03 +0000 |
3698 | +++ src/vanishing-point.h 2015-12-09 15:31:04 +0000 |
3699 | @@ -23,8 +23,6 @@ |
3700 | #include "ui/control-manager.h" // TODO break enums out separately |
3701 | |
3702 | class SPBox3D; |
3703 | -typedef struct _GList GList; |
3704 | -typedef struct _GSList GSList; |
3705 | |
3706 | namespace Box3D { |
3707 | |
3708 | @@ -173,8 +171,8 @@ |
3709 | bool dragging; |
3710 | |
3711 | SPDocument *document; |
3712 | - GList *draggers; |
3713 | - GSList *lines; |
3714 | + std::vector<VPDragger *> draggers; |
3715 | + std::vector<SPCtrlLine *> lines; |
3716 | |
3717 | void printDraggers(); // convenience for debugging |
3718 | /* |
3719 | @@ -195,7 +193,6 @@ |
3720 | |
3721 | inline bool hasEmptySelection() { return this->selection->isEmpty(); } |
3722 | bool allBoxesAreSelected (VPDragger *dragger); |
3723 | - GSList * selectedBoxesWithVPinDragger (VPDragger *dragger); |
3724 | |
3725 | // FIXME: Should this be private? (It's the case with the corresponding function in gradient-drag.h) |
3726 | // But vp_knot_grabbed_handler |
3727 | |
3728 | === modified file 'src/widgets/connector-toolbar.cpp' |
3729 | --- src/widgets/connector-toolbar.cpp 2015-11-05 21:27:44 +0000 |
3730 | +++ src/widgets/connector-toolbar.cpp 2015-12-09 15:31:04 +0000 |
3731 | @@ -200,17 +200,15 @@ |
3732 | desktop->namedview->updateRepr(); |
3733 | bool modmade = false; |
3734 | |
3735 | - GSList *items = get_avoided_items(NULL, desktop->currentRoot(), desktop); |
3736 | - for ( GSList const *iter = items ; iter != NULL ; iter = iter->next ) { |
3737 | - SPItem *item = reinterpret_cast<SPItem *>(iter->data); |
3738 | + std::vector<SPItem *> items; |
3739 | + items = get_avoided_items(items, desktop->currentRoot(), desktop); |
3740 | + for (std::vector<SPItem *>::const_iterator iter = items.begin(); iter != items.end(); ++iter ) { |
3741 | + SPItem *item = *iter; |
3742 | Geom::Affine m = Geom::identity(); |
3743 | avoid_item_move(&m, item); |
3744 | modmade = true; |
3745 | } |
3746 | |
3747 | - if (items) { |
3748 | - g_slist_free(items); |
3749 | - } |
3750 | if(modmade) { |
3751 | DocumentUndo::done(doc, SP_VERB_CONTEXT_CONNECTOR, |
3752 | _("Change connector spacing")); |
3753 | |
3754 | === modified file 'src/widgets/desktop-widget.cpp' |
3755 | --- src/widgets/desktop-widget.cpp 2015-12-09 15:06:31 +0000 |
3756 | +++ src/widgets/desktop-widget.cpp 2015-12-09 15:31:04 +0000 |
3757 | @@ -1868,9 +1868,9 @@ |
3758 | { |
3759 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
3760 | if (prefs->getBool("/options/bitmapautoreload/value", true)) { |
3761 | - GSList const *imageList = (desktop->doc())->getResourceList("image"); |
3762 | - for (GSList const *p = imageList; p; p = p->next) { |
3763 | - SPImage* image = SP_IMAGE(p->data); |
3764 | + std::set<SPObject *> imageList = (desktop->doc())->getResourceList("image"); |
3765 | + for (std::set<SPObject *>::const_iterator it = imageList.begin(); it != imageList.end(); ++it) { |
3766 | + SPImage* image = SP_IMAGE(*it); |
3767 | sp_image_refresh_if_outdated( image ); |
3768 | } |
3769 | } |
3770 | |
3771 | === modified file 'src/widgets/gradient-toolbar.cpp' |
3772 | --- src/widgets/gradient-toolbar.cpp 2015-11-05 21:27:44 +0000 |
3773 | +++ src/widgets/gradient-toolbar.cpp 2015-12-09 15:31:04 +0000 |
3774 | @@ -106,10 +106,10 @@ |
3775 | // GRADIENTFIXME: make this work for multiple selected draggers. |
3776 | |
3777 | // First try selected dragger |
3778 | - if (drag && drag->selected) { |
3779 | - GrDragger *dragger = static_cast<GrDragger*>(drag->selected->data); |
3780 | - for (GSList const* i = dragger->draggables; i != NULL; i = i->next) { // for all draggables of dragger |
3781 | - GrDraggable *draggable = static_cast<GrDraggable*>(i->data); |
3782 | + if (drag && !drag->selected.empty()) { |
3783 | + GrDragger *dragger = *(drag->selected.begin()); |
3784 | + for(std::vector<GrDraggable *>::const_iterator i = dragger->draggables.begin(); i != dragger->draggables.end(); ++i) { //for all draggables of dragger |
3785 | + GrDraggable *draggable = *i; |
3786 | gr_apply_gradient_to_item(draggable->item, gr, initialType, initialMode, draggable->fill_or_stroke); |
3787 | } |
3788 | return; |
3789 | @@ -139,19 +139,18 @@ |
3790 | /* Clear old list, if there is any */ |
3791 | gtk_list_store_clear(store); |
3792 | |
3793 | - GSList *gl = NULL; |
3794 | - const GSList *gradients = document->getResourceList("gradient"); |
3795 | - for (const GSList *i = gradients; i != NULL; i = i->next) { |
3796 | - SPGradient *grad = SP_GRADIENT(i->data); |
3797 | + std::vector<SPObject *> gl; |
3798 | + std::set<SPObject *> gradients = document->getResourceList( "gradient" ); |
3799 | + for (std::set<SPObject *>::const_iterator it = gradients.begin(); it != gradients.end(); ++it) { |
3800 | + SPGradient *grad = SP_GRADIENT(*it); |
3801 | if ( grad->hasStops() && !grad->isSolid() ) { |
3802 | - gl = g_slist_prepend(gl, i->data); |
3803 | + gl.push_back(*it); |
3804 | } |
3805 | } |
3806 | - gl = g_slist_reverse(gl); |
3807 | |
3808 | guint pos = 0; |
3809 | |
3810 | - if (!gl) { |
3811 | + if (gl.empty()) { |
3812 | // The document has no gradients |
3813 | gtk_list_store_append(store, &iter); |
3814 | gtk_list_store_set(store, &iter, 0, _("No gradient"), 1, NULL, 2, NULL, -1); |
3815 | @@ -180,9 +179,8 @@ |
3816 | } |
3817 | |
3818 | guint idx = 0; |
3819 | - while (gl) { |
3820 | - SPGradient *gradient = SP_GRADIENT(gl->data); |
3821 | - gl = g_slist_remove(gl, gradient); |
3822 | + for (std::vector<SPObject *>::const_iterator it = gl.begin(); it != gl.end(); ++it) { |
3823 | + SPGradient *gradient = SP_GRADIENT(*it); |
3824 | |
3825 | Glib::ustring label = gr_prepare_label(gradient); |
3826 | GdkPixbuf *pixb = sp_gradient_to_pixbuf(gradient, 64, 16); |
3827 | @@ -255,11 +253,11 @@ |
3828 | SPGradientSpread &spr_selected, |
3829 | bool &spr_multi ) |
3830 | { |
3831 | - if (drag && drag->selected) { |
3832 | + if (drag && !drag->selected.empty()) { |
3833 | // GRADIENTFIXME: make this work for more than one selected dragger? |
3834 | - GrDragger *dragger = static_cast<GrDragger*>(drag->selected->data); |
3835 | - for (GSList const* i = dragger->draggables; i; i = i->next) { // for all draggables of dragger |
3836 | - GrDraggable *draggable = static_cast<GrDraggable *>(i->data); |
3837 | + GrDragger *dragger = *(drag->selected.begin()); |
3838 | + for(std::vector<GrDraggable *>::const_iterator i = dragger->draggables.begin(); i != dragger->draggables.end(); ++i) { //for all draggables of dragger |
3839 | + GrDraggable *draggable = *i; |
3840 | SPGradient *gradient = sp_item_gradient_get_vector(draggable->item, draggable->fill_or_stroke); |
3841 | SPGradientSpread spread = sp_item_gradient_get_spread(draggable->item, draggable->fill_or_stroke); |
3842 | |
3843 | @@ -394,10 +392,10 @@ |
3844 | } |
3845 | |
3846 | InkAction *add = (InkAction *) g_object_get_data(G_OBJECT(widget), "gradient_stops_add_action"); |
3847 | - gtk_action_set_sensitive(GTK_ACTION(add), (gr_selected && !gr_multi && drag && drag->selected)); |
3848 | + gtk_action_set_sensitive(GTK_ACTION(add), (gr_selected && !gr_multi && drag && !drag->selected.empty())); |
3849 | |
3850 | InkAction *del = (InkAction *) g_object_get_data(G_OBJECT(widget), "gradient_stops_delete_action"); |
3851 | - gtk_action_set_sensitive(GTK_ACTION(del), (gr_selected && !gr_multi && drag && drag->selected)); |
3852 | + gtk_action_set_sensitive(GTK_ACTION(del), (gr_selected && !gr_multi && drag && !drag->selected.empty())); |
3853 | |
3854 | InkAction *reverse = (InkAction *) g_object_get_data(G_OBJECT(widget), "gradient_stops_reverse_action"); |
3855 | gtk_action_set_sensitive(GTK_ACTION(reverse), (gr_selected!= NULL)); |
3856 | @@ -649,7 +647,7 @@ |
3857 | |
3858 | GrDrag *drag = ev->get_drag(); |
3859 | |
3860 | - if (!drag || !drag->selected) { |
3861 | + if (!drag || drag->selected.empty()) { |
3862 | blocked = TRUE; |
3863 | gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box) , 0); |
3864 | gr_stop_set_offset(GTK_COMBO_BOX(combo_box), data); |
3865 | @@ -660,11 +658,10 @@ |
3866 | gint n = 0; |
3867 | |
3868 | // for all selected draggers |
3869 | - for (GList *i = drag->selected; i != NULL; i = i->next) { |
3870 | - GrDragger *dragger = static_cast<GrDragger*>(i->data); |
3871 | - // for all draggables of dragger |
3872 | - for (GSList const* j = dragger->draggables; j != NULL; j = j->next) { |
3873 | - GrDraggable *draggable = static_cast<GrDraggable*>(j->data); |
3874 | + for(std::set<GrDragger *>::const_iterator i = drag->selected.begin(); i != drag->selected.end(); ++i) { //for all draggables of dragger |
3875 | + GrDragger *dragger = *i; |
3876 | + for(std::vector<GrDraggable *>::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end(); ++j) { //for all draggables of dragger |
3877 | + GrDraggable *draggable = *j; |
3878 | |
3879 | if (draggable->point_type != POINT_RG_FOCUS) { |
3880 | n++; |
3881 | @@ -766,25 +763,25 @@ |
3882 | } |
3883 | |
3884 | /* Populate the combobox store */ |
3885 | - GSList *sl = NULL; |
3886 | + std::vector<SPObject *> sl; |
3887 | if ( gradient->hasStops() ) { |
3888 | for ( SPObject *ochild = gradient->firstChild() ; ochild ; ochild = ochild->getNext() ) { |
3889 | if (SP_IS_STOP(ochild)) { |
3890 | - sl = g_slist_append(sl, ochild); |
3891 | + sl.push_back(ochild); |
3892 | } |
3893 | } |
3894 | } |
3895 | - if (!sl) { |
3896 | + if (sl.empty()) { |
3897 | gtk_list_store_append(store, &iter); |
3898 | gtk_list_store_set(store, &iter, 0, _("No stops in gradient"), 1, NULL, 2, NULL, -1); |
3899 | sensitive = FALSE; |
3900 | |
3901 | } else { |
3902 | |
3903 | - for (; sl != NULL; sl = sl->next){ |
3904 | - if (SP_IS_STOP(sl->data)){ |
3905 | - SPStop *stop = SP_STOP(sl->data); |
3906 | - Inkscape::XML::Node *repr = reinterpret_cast<SPItem *>(sl->data)->getRepr(); |
3907 | + for (std::vector<SPObject *>::const_iterator it = sl.begin(); it != sl.end(); ++it) { |
3908 | + if (SP_IS_STOP(*it)){ |
3909 | + SPStop *stop = SP_STOP(*it); |
3910 | + Inkscape::XML::Node *repr = reinterpret_cast<SPItem *>(*it)->getRepr(); |
3911 | Inkscape::UI::Widget::ColorPreview *cpv = Gtk::manage(new Inkscape::UI::Widget::ColorPreview(stop->get_rgba32())); |
3912 | GdkPixbuf *pb = cpv->toPixbuf(32, 16); |
3913 | Glib::ustring label = gr_ellipsize_text(repr->attribute("id"), 25); |
3914 | |
3915 | === modified file 'src/widgets/gradient-vector.cpp' |
3916 | --- src/widgets/gradient-vector.cpp 2015-10-14 11:20:09 +0000 |
3917 | +++ src/widgets/gradient-vector.cpp 2015-12-09 15:31:04 +0000 |
3918 | @@ -298,11 +298,11 @@ |
3919 | /* Pick up all gradients with vectors */ |
3920 | GSList *gl = NULL; |
3921 | if (gvs->gr) { |
3922 | - const GSList *gradients = gvs->gr->document->getResourceList("gradient"); |
3923 | - for (const GSList *curr = gradients; curr; curr = curr->next) { |
3924 | - SPGradient* grad = SP_GRADIENT(curr->data); |
3925 | + std::set<SPObject *> gradients = gvs->gr->document->getResourceList("gradient"); |
3926 | + for (std::set<SPObject *>::const_iterator it = gradients.begin(); it != gradients.end(); ++it) { |
3927 | + SPGradient* grad = SP_GRADIENT(*it); |
3928 | if ( grad->hasStops() && (grad->isSwatch() == gvs->swatched) ) { |
3929 | - gl = g_slist_prepend(gl, curr->data); |
3930 | + gl = g_slist_prepend(gl, *it); |
3931 | } |
3932 | } |
3933 | } |
3934 | |
3935 | === modified file 'src/widgets/mesh-toolbar.cpp' |
3936 | --- src/widgets/mesh-toolbar.cpp 2015-11-24 09:25:42 +0000 |
3937 | +++ src/widgets/mesh-toolbar.cpp 2015-12-09 15:31:04 +0000 |
3938 | @@ -433,14 +433,14 @@ |
3939 | |
3940 | /* Number of mesh rows */ |
3941 | { |
3942 | - gchar const* labels[] = {}; |
3943 | + gchar const** labels = NULL; |
3944 | gdouble values[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; |
3945 | eact = create_adjustment_action( "MeshRowAction", |
3946 | _("Rows"), _("Rows:"), _("Number of rows in new mesh"), |
3947 | "/tools/mesh/mesh_rows", 1, |
3948 | GTK_WIDGET(desktop->canvas), holder, FALSE, NULL, |
3949 | 1, 20, 1, 1, |
3950 | - labels, values, G_N_ELEMENTS(labels), |
3951 | + labels, values, 0, |
3952 | ms_row_changed, NULL /*unit tracker*/, |
3953 | 1.0, 0 ); |
3954 | gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); |
3955 | @@ -449,14 +449,14 @@ |
3956 | |
3957 | /* Number of mesh columns */ |
3958 | { |
3959 | - gchar const* labels[] = {}; |
3960 | + gchar const** labels = NULL; |
3961 | gdouble values[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; |
3962 | eact = create_adjustment_action( "MeshColumnAction", |
3963 | _("Columns"), _("Columns:"), _("Number of columns in new mesh"), |
3964 | "/tools/mesh/mesh_cols", 1, |
3965 | GTK_WIDGET(desktop->canvas), holder, FALSE, NULL, |
3966 | 1, 20, 1, 1, |
3967 | - labels, values, G_N_ELEMENTS(labels), |
3968 | + labels, values, 0, |
3969 | ms_col_changed, NULL /*unit tracker*/, |
3970 | 1.0, 0 ); |
3971 | gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); |
3972 | |
3973 | === modified file 'src/widgets/paint-selector.cpp' |
3974 | --- src/widgets/paint-selector.cpp 2015-09-14 17:11:44 +0000 |
3975 | +++ src/widgets/paint-selector.cpp 2015-12-09 15:31:04 +0000 |
3976 | @@ -844,10 +844,10 @@ |
3977 | return NULL; |
3978 | |
3979 | GSList *pl = NULL; |
3980 | - GSList const *patterns = source->getResourceList("pattern"); |
3981 | - for (GSList *l = const_cast<GSList *>(patterns); l != NULL; l = l->next) { |
3982 | - if (SP_PATTERN(l->data) == SP_PATTERN(l->data)->rootPattern()) { // only if this is a root pattern |
3983 | - pl = g_slist_prepend(pl, l->data); |
3984 | + std::set<SPObject *> patterns = source->getResourceList("pattern"); |
3985 | + for (std::set<SPObject *>::const_iterator it = patterns.begin(); it != patterns.end(); ++it) { |
3986 | + if (SP_PATTERN(*it) == SP_PATTERN(*it)->rootPattern()) { // only if this is a root pattern |
3987 | + pl = g_slist_prepend(pl, *it); |
3988 | } |
3989 | } |
3990 | |
3991 | |
3992 | === modified file 'src/xml/rebase-hrefs.cpp' |
3993 | --- src/xml/rebase-hrefs.cpp 2011-12-08 11:53:54 +0000 |
3994 | +++ src/xml/rebase-hrefs.cpp 2015-12-09 15:31:04 +0000 |
3995 | @@ -220,9 +220,9 @@ |
3996 | * |
3997 | * Note also that Inkscape only supports fragment hrefs (href="#pattern257") for many of these |
3998 | * cases. */ |
3999 | - GSList const *images = doc->getResourceList("image"); |
4000 | - for (GSList const *l = images; l != NULL; l = l->next) { |
4001 | - Inkscape::XML::Node *ir = static_cast<SPObject *>(l->data)->getRepr(); |
4002 | + std::set<SPObject *> images = doc->getResourceList("image"); |
4003 | + for (std::set<SPObject *>::const_iterator it = images.begin(); it != images.end(); ++it) { |
4004 | + Inkscape::XML::Node *ir = (*it)->getRepr(); |
4005 | |
4006 | std::string uri; |
4007 | { |
4008 | |
4009 | === modified file 'src/xml/repr-io.cpp' |
4010 | --- src/xml/repr-io.cpp 2014-10-12 12:27:21 +0000 |
4011 | +++ src/xml/repr-io.cpp 2015-12-09 15:31:04 +0000 |
4012 | @@ -38,6 +38,7 @@ |
4013 | #include "preferences.h" |
4014 | |
4015 | #include <glibmm/miscutils.h> |
4016 | +#include <map> |
4017 | |
4018 | using Inkscape::IO::Writer; |
4019 | using Inkscape::Util::List; |
4020 | @@ -50,8 +51,8 @@ |
4021 | using Inkscape::XML::rebase_href_attrs; |
4022 | |
4023 | Document *sp_repr_do_read (xmlDocPtr doc, const gchar *default_ns); |
4024 | -static Node *sp_repr_svg_read_node (Document *xml_doc, xmlNodePtr node, const gchar *default_ns, GHashTable *prefix_map); |
4025 | -static gint sp_repr_qualified_name (gchar *p, gint len, xmlNsPtr ns, const xmlChar *name, const gchar *default_ns, GHashTable *prefix_map); |
4026 | +static Node *sp_repr_svg_read_node (Document *xml_doc, xmlNodePtr node, const gchar *default_ns, std::map<std::string, std::string> &prefix_map); |
4027 | +static gint sp_repr_qualified_name (gchar *p, gint len, xmlNsPtr ns, const xmlChar *name, const gchar *default_ns, std::map<std::string, std::string> &prefix_map); |
4028 | static void sp_repr_write_stream_root_element(Node *repr, Writer &out, |
4029 | bool add_whitespace, gchar const *default_ns, |
4030 | int inlineattrs, int indent, |
4031 | @@ -486,8 +487,7 @@ |
4032 | return NULL; |
4033 | } |
4034 | |
4035 | - GHashTable * prefix_map; |
4036 | - prefix_map = g_hash_table_new (g_str_hash, g_str_equal); |
4037 | + std::map<std::string, std::string> prefix_map; |
4038 | |
4039 | Document *rdoc = new Inkscape::XML::SimpleDocument(); |
4040 | |
4041 | @@ -536,21 +536,17 @@ |
4042 | } |
4043 | } |
4044 | |
4045 | - g_hash_table_destroy (prefix_map); |
4046 | - |
4047 | return rdoc; |
4048 | } |
4049 | |
4050 | -gint sp_repr_qualified_name (gchar *p, gint len, xmlNsPtr ns, const xmlChar *name, const gchar */*default_ns*/, GHashTable *prefix_map) |
4051 | +gint sp_repr_qualified_name (gchar *p, gint len, xmlNsPtr ns, const xmlChar *name, const gchar */*default_ns*/, std::map<std::string, std::string> &prefix_map) |
4052 | { |
4053 | const xmlChar *prefix; |
4054 | if (ns){ |
4055 | if (ns->href ) { |
4056 | prefix = reinterpret_cast<const xmlChar*>( sp_xml_ns_uri_prefix(reinterpret_cast<const gchar*>(ns->href), |
4057 | reinterpret_cast<const char*>(ns->prefix)) ); |
4058 | - void* p0 = reinterpret_cast<gpointer>(const_cast<xmlChar *>(prefix)); |
4059 | - void* p1 = reinterpret_cast<gpointer>(const_cast<xmlChar *>(ns->href)); |
4060 | - g_hash_table_insert( prefix_map, p0, p1 ); |
4061 | + prefix_map[reinterpret_cast<const char*>(prefix)] = reinterpret_cast<const char*>(ns->href); |
4062 | } |
4063 | else { |
4064 | prefix = NULL; |
4065 | @@ -567,7 +563,7 @@ |
4066 | } |
4067 | } |
4068 | |
4069 | -static Node *sp_repr_svg_read_node (Document *xml_doc, xmlNodePtr node, const gchar *default_ns, GHashTable *prefix_map) |
4070 | +static Node *sp_repr_svg_read_node (Document *xml_doc, xmlNodePtr node, const gchar *default_ns, std::map<std::string, std::string> &prefix_map) |
4071 | { |
4072 | xmlAttrPtr prop; |
4073 | xmlNodePtr child; |
I've scanned the code changes and I don't see any obvious problems. The more GLists and GSLists that disappear, the better. This code is crying out for the use of C++11 range-based 'for' loops and 'auto' variable declarations.
I've also compiled and briefly tested the code (creating/ removing/ dragging gradient knots, 3D boxes, guides). I see one crash that doesn't exist in trunk:
1. Create a guide by dragging from ruler.
2. Undo action: (Ctrl-Z) -> Crash
This is with revision 14520.
Once that is fixed, I would go ahead and merge the code with trunk. If there are any other bugs, they will be quickly found, I am sure.