From 8530b7946a862abdbcd4890ba8a444799b75986d Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Tue, 27 Apr 2010 16:38:07 +0100 Subject: [PATCH] cogl-material: Fix the check to prevent using too many layers There was a check at the bottom of the loop which sets up the state for each of the layers so that it would break from the loop when the maximum number of layers is reached. However after doing this it would not increment 'i'. 'i' is later used to disable the remaining layers so it would end up disabling the last layer it just set up. This patch moves the check to be part of the loop condition so that the check is performed after incrementing 'i'. http://bugzilla.openedhand.com/show_bug.cgi?id=2064 --- clutter/cogl/cogl/cogl-material.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/clutter/cogl/cogl/cogl-material.c b/clutter/cogl/cogl/cogl-material.c index a73831e45..462c64411 100644 --- a/clutter/cogl/cogl/cogl-material.c +++ b/clutter/cogl/cogl/cogl-material.c @@ -1469,8 +1469,10 @@ _cogl_material_flush_layers_gl_state (CoglMaterial *material, _COGL_GET_CONTEXT (ctx, NO_RETVAL); - for (tmp = material->layers, i = 0; tmp != NULL; tmp = tmp->next, i++) - { + for (tmp = material->layers, i = 0; + tmp != NULL && i < _cogl_get_max_texture_image_units (); + tmp = tmp->next, i++) + { CoglHandle layer_handle = (CoglHandle)tmp->data; CoglMaterialLayer *layer = _cogl_material_layer_pointer_from_handle (layer_handle); @@ -1621,9 +1623,6 @@ _cogl_material_flush_layers_gl_state (CoglMaterial *material, g_array_append_val (ctx->current_layers, new_gl_layer_info); layer->flags &= ~COGL_MATERIAL_LAYER_FLAG_DIRTY; - - if ((i+1) >= _cogl_get_max_texture_image_units ()) - break; } /* Disable additional texture units that may have previously been in use.. */