[mutter] prefs: Do not leave junk values in unused button_layout fields



commit 5a8473e226a84dfa41e4dcc3be6d60472bccff02
Author: Florian MÃllner <fmuellner gnome org>
Date:   Wed Nov 28 23:04:17 2012 +0100

    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

 src/core/prefs.c |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)
---
diff --git a/src/core/prefs.c b/src/core/prefs.c
index 7e7c250..1a79414 100644
--- a/src/core/prefs.c
+++ b/src/core/prefs.c
@@ -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;
   }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]