summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2013-08-03 19:19:41 +0000
committerJohan B. C. Engelen <j.b.c.engelen@alumnus.utwente.nl>2013-08-03 19:19:41 +0000
commit4870480be25edac321a066a18d5e66f077c355db (patch)
tree504f53f25fe130c550ff6c2a1c60f485399a68f6 /src
parentcppcheck Common realloc mistake: 'qrsData' nulled but not freed upon failure (diff)
downloadinkscape-4870480be25edac321a066a18d5e66f077c355db.tar.gz
inkscape-4870480be25edac321a066a18d5e66f077c355db.zip
cppcheck fix: Memory leak: rows
(bzr r12449)
Diffstat (limited to 'src')
-rw-r--r--src/libgdl/gdl-switcher.c97
1 files changed, 50 insertions, 47 deletions
diff --git a/src/libgdl/gdl-switcher.c b/src/libgdl/gdl-switcher.c
index 60d53dd5f..daacebf20 100644
--- a/src/libgdl/gdl-switcher.c
+++ b/src/libgdl/gdl-switcher.c
@@ -370,62 +370,65 @@ layout_buttons (GdlSwitcher *switcher)
if (last_buttons_height > switcher->priv->buttons_height_request)
{
gtk_widget_queue_resize (GTK_WIDGET (switcher));
- return -1;
+ y = -1; // set return value
}
-
- /* Layout the buttons. */
- for (i = row_last; i >= 0; i --) {
- int len, extra_width;
-
- y -= max_btn_height;
-
- /* Check for possible size over flow (taking into account client
- * requisition
- */
- if (y < (allocation.y + client_requisition.height)) {
- /* We have an overflow: Insufficient allocation */
- if (last_buttons_height < switcher->priv->buttons_height_request) {
- /* Request for a new resize */
- gtk_widget_queue_resize (GTK_WIDGET (switcher));
- return -1;
- }
- }
- x = H_PADDING + allocation.x;
- len = g_slist_length (rows[i]);
- if (switcher_style == GDL_SWITCHER_STYLE_TEXT ||
- switcher_style == GDL_SWITCHER_STYLE_BOTH)
- extra_width = (allocation.width - (len * max_btn_width )
- - (len * H_PADDING)) / len;
- else
- extra_width = 0;
- for (p = rows [i]; p != NULL; p = p->next) {
- GtkAllocation child_allocation;
+ else
+ {
+ /* Layout the buttons. */
+ for (i = row_last; i >= 0; i --) {
+ int len, extra_width;
- child_allocation.x = x;
- child_allocation.y = y;
- if (rows_count == 1 && row_number == 0)
- {
- GtkRequisition child_requisition;
- gtk_widget_size_request (GTK_WIDGET (p->data),
- &child_requisition);
- child_allocation.width = child_requisition.width;
+ y -= max_btn_height;
+
+ /* Check for possible size over flow (taking into account client
+ * requisition
+ */
+ if (y < (allocation.y + client_requisition.height)) {
+ /* We have an overflow: Insufficient allocation */
+ if (last_buttons_height < switcher->priv->buttons_height_request) {
+ /* Request for a new resize */
+ gtk_widget_queue_resize (GTK_WIDGET (switcher));
+ return -1;
+ }
}
+ x = H_PADDING + allocation.x;
+ len = g_slist_length (rows[i]);
+ if (switcher_style == GDL_SWITCHER_STYLE_TEXT ||
+ switcher_style == GDL_SWITCHER_STYLE_BOTH)
+ extra_width = (allocation.width - (len * max_btn_width )
+ - (len * H_PADDING)) / len;
else
- {
- child_allocation.width = max_btn_width + extra_width;
+ extra_width = 0;
+ for (p = rows [i]; p != NULL; p = p->next) {
+ GtkAllocation child_allocation;
+
+ child_allocation.x = x;
+ child_allocation.y = y;
+ if (rows_count == 1 && row_number == 0)
+ {
+ GtkRequisition child_requisition;
+ gtk_widget_size_request (GTK_WIDGET (p->data),
+ &child_requisition);
+ child_allocation.width = child_requisition.width;
+ }
+ else
+ {
+ child_allocation.width = max_btn_width + extra_width;
+ }
+ child_allocation.height = max_btn_height;
+
+ gtk_widget_size_allocate (GTK_WIDGET (p->data), &child_allocation);
+
+ x += child_allocation.width + H_PADDING;
}
- child_allocation.height = max_btn_height;
-
- gtk_widget_size_allocate (GTK_WIDGET (p->data), &child_allocation);
- x += child_allocation.width + H_PADDING;
+ y -= V_PADDING;
}
-
- y -= V_PADDING;
}
-
- for (i = 0; i <= row_last; i ++)
+
+ for (i = 0; i <= row_last; i ++) {
g_slist_free (rows [i]);
+ }
g_free (rows);
return y;