prefs: Do not leave junk values in unused button_layout fields

MetaButtonLayout is extremely unfriendly for introspection: its fields
are arrays of a fixed length, but the actual length is determined by
a custom stop value (e.g. not NULL / 0).
Without API changes this will never work nicely in introspection, but
we can at least make it work; start by filling up unused fields with
the stop value rather than leaving it at random values.

https://bugzilla.gnome.org/show_bug.cgi?id=689263
This commit is contained in:
Florian Müllner 2012-11-28 23:04:17 +01:00
parent 5c33b0d768
commit 5a8473e226

View File

@ -1395,8 +1395,11 @@ button_layout_handler (GVariant *value,
g_strfreev (buttons);
}
new_layout.left_buttons[i] = META_BUTTON_FUNCTION_LAST;
new_layout.left_buttons_has_spacer[i] = FALSE;
for (; i < MAX_BUTTONS_PER_CORNER; i++)
{
new_layout.left_buttons[i] = META_BUTTON_FUNCTION_LAST;
new_layout.left_buttons_has_spacer[i] = FALSE;
}
i = 0;
if (sides != NULL && sides[0] != NULL && sides[1] != NULL)
@ -1454,8 +1457,11 @@ button_layout_handler (GVariant *value,
g_strfreev (buttons);
}
new_layout.right_buttons[i] = META_BUTTON_FUNCTION_LAST;
new_layout.right_buttons_has_spacer[i] = FALSE;
for (; i < MAX_BUTTONS_PER_CORNER; i++)
{
new_layout.right_buttons[i] = META_BUTTON_FUNCTION_LAST;
new_layout.right_buttons_has_spacer[i] = FALSE;
}
g_strfreev (sides);
@ -1474,8 +1480,11 @@ button_layout_handler (GVariant *value,
else
rtl_layout.right_buttons_has_spacer[j - 1] = new_layout.left_buttons_has_spacer[i - j - 1];
}
rtl_layout.right_buttons[j] = META_BUTTON_FUNCTION_LAST;
rtl_layout.right_buttons_has_spacer[j] = FALSE;
for (; j < MAX_BUTTONS_PER_CORNER; j++)
{
rtl_layout.right_buttons[j] = META_BUTTON_FUNCTION_LAST;
rtl_layout.right_buttons_has_spacer[j] = FALSE;
}
for (i = 0; new_layout.right_buttons[i] != META_BUTTON_FUNCTION_LAST; i++);
for (j = 0; j < i; j++)
@ -1486,8 +1495,11 @@ button_layout_handler (GVariant *value,
else
rtl_layout.left_buttons_has_spacer[j - 1] = new_layout.right_buttons_has_spacer[i - j - 1];
}
rtl_layout.left_buttons[j] = META_BUTTON_FUNCTION_LAST;
rtl_layout.left_buttons_has_spacer[j] = FALSE;
for (; j < MAX_BUTTONS_PER_CORNER; j++)
{
rtl_layout.left_buttons[j] = META_BUTTON_FUNCTION_LAST;
rtl_layout.left_buttons_has_spacer[j] = FALSE;
}
new_layout = rtl_layout;
}