diff --git a/cogl/cogl-attribute.c b/cogl/cogl-attribute.c index 348071da6..853d98934 100644 --- a/cogl/cogl-attribute.c +++ b/cogl/cogl-attribute.c @@ -428,13 +428,13 @@ validated: return status; } -static void +static gboolean toggle_enabled_cb (int bit_num, void *user_data) { const CoglBitmask *new_values = user_data; gboolean enabled = _cogl_bitmask_get (new_values, bit_num); - _COGL_GET_CONTEXT (ctx, NO_RETVAL); + _COGL_GET_CONTEXT (ctx, FALSE); if (ctx->driver == COGL_DRIVER_GLES2) { @@ -454,6 +454,8 @@ toggle_enabled_cb (int bit_num, void *user_data) GE( ctx, glDisableClientState (GL_TEXTURE_COORD_ARRAY) ); } #endif + + return TRUE; } static void diff --git a/cogl/cogl-bitmask.c b/cogl/cogl-bitmask.c index bdd7b0575..1fe21983b 100644 --- a/cogl/cogl-bitmask.c +++ b/cogl/cogl-bitmask.c @@ -231,7 +231,7 @@ _cogl_bitmask_clear_all_in_array (CoglBitmask *bitmask) void _cogl_bitmask_foreach (const CoglBitmask *bitmask, CoglBitmaskForeachFunc func, - gpointer user_data) + void *user_data) { if (_cogl_bitmask_has_array (bitmask)) { @@ -251,8 +251,9 @@ _cogl_bitmask_foreach (const CoglBitmask *bitmask, bit += next_bit; mask >>= next_bit; - func (array_index * sizeof (unsigned long) * 8 + bit - 1, - user_data); + if (!func (array_index * sizeof (unsigned long) * 8 + bit - 1, + user_data)) + return; } } } @@ -268,7 +269,8 @@ _cogl_bitmask_foreach (const CoglBitmask *bitmask, bit += next_bit; mask >>= next_bit; - func (bit - 1, user_data); + if (!func (bit - 1, user_data)) + return; } } } diff --git a/cogl/cogl-bitmask.h b/cogl/cogl-bitmask.h index 42ba35661..e36a55112 100644 --- a/cogl/cogl-bitmask.h +++ b/cogl/cogl-bitmask.h @@ -125,7 +125,8 @@ void _cogl_bitmask_xor_bits (CoglBitmask *dst, const CoglBitmask *src); -typedef void (* CoglBitmaskForeachFunc) (int bit_num, gpointer user_data); +/* The foreach function can return FALSE to stop iteration */ +typedef gboolean (* CoglBitmaskForeachFunc) (int bit_num, void *user_data); /* * cogl_bitmask_foreach: @@ -138,7 +139,7 @@ typedef void (* CoglBitmaskForeachFunc) (int bit_num, gpointer user_data); void _cogl_bitmask_foreach (const CoglBitmask *bitmask, CoglBitmaskForeachFunc func, - gpointer user_data); + void *user_data); /* * _cogl_bitmask_get: diff --git a/tests/conform/test-bitmask.c b/tests/conform/test-bitmask.c index b02a9ba3e..613e5ee1c 100644 --- a/tests/conform/test-bitmask.c +++ b/tests/conform/test-bitmask.c @@ -19,7 +19,7 @@ typedef struct int *bits; } CheckData; -static void +static gboolean check_bit (int bit_num, void *user_data) { CheckData *data = user_data; @@ -29,12 +29,12 @@ check_bit (int bit_num, void *user_data) if (data->bits[i] == bit_num) { data->bits[i] = -1; - return; + return TRUE; } g_assert_not_reached (); - return; + return TRUE; } static void