[Recolor] Fetching number of objects selected
Hi, I need to get the number of selected objects on the canvas. I was using the following code:
GSList const *items = selection->itemList(); int selObj = g_slist_length (const_cast<GSList*>(items));
the const_cast was required because:
guint http://www.gtk.org/api/2.6/glib/glib-Basic-Types.html#guint g_slist_length http://www.gtk.org/api/2.6/glib/glib-Singly-Linked-Lists.html#g-slist-length (GSList http://www.gtk.org/api/2.6/glib/glib-Singly-Linked-Lists.html#GSList *list);
If I comment out the g_slist_length command, there is no runtime error. And Inkscape run's perfect. In this scenario, what can I do to get the length of the GSList ?
2013/7/26 Arshdeep Singh <moduli16@...400...>:
Hi, I need to get the number of selected objects on the canvas. I was using the following code:
GSList const *items = selection->itemList(); int selObj = g_slist_length (const_cast<GSList*>(items));
the const_cast was required because:
guint g_slist_length (GSList *list);
If I comment out the g_slist_length command, there is no runtime error. And Inkscape run's perfect. In this scenario, what can I do to get the length of the GSList ?
The g_slist_length() and the const_cast call is correct. The problem must be in surrounding code. In particular, the selection pointer might be invalid. Please provide some more context.
Regards, Krzysztof
participants (2)
-
Arshdeep Singh
-
Krzysztof Kosiński