GtkStyleContext: ensure class lookup return the correct insertion position if not found.

This commit is contained in:
Carlos Garnacho 2010-08-02 13:50:17 +02:00
parent 0813a2283e
commit 7748b1d2de

View File

@ -646,7 +646,7 @@ style_class_find (GArray *array,
GQuark class_quark,
guint *position)
{
guint min, max, mid;
gint min, max, mid;
gboolean found = FALSE;
if (position)
@ -668,11 +668,14 @@ style_class_find (GArray *array,
if (class_quark == item)
found = TRUE;
else if (class_quark > item)
min = mid + 1;
min = mid = mid + 1;
else
max = mid - 1;
max = mid = mid - 1;
}
while (!found && min < max);
while (!found && min <= max);
if (mid < 0)
mid = 0;
if (position)
*position = mid;
@ -685,7 +688,7 @@ child_style_class_find (GArray *array,
GQuark class_quark,
guint *position)
{
guint min, max, mid;
gint min, max, mid;
gboolean found = FALSE;
if (position)
@ -707,11 +710,14 @@ child_style_class_find (GArray *array,
if (child_class->class_quark == class_quark)
found = TRUE;
else if (child_class->class_quark > class_quark)
min = mid + 1;
min = mid = mid + 1;
else
max = mid - 1;
max = mid = mid - 1;
}
while (!found && min < max);
while (!found && min <= max);
if (mid < 0)
mid = 0;
if (position)
*position = mid;