e:tiling: fix some overflows and add a bunch of asserts

SVN revision: 80892
This commit is contained in:
Boris Faure 2012-12-13 20:55:54 +00:00
parent 0d579688ae
commit 4e35962cb1
1 changed files with 23 additions and 9 deletions

View File

@ -1267,6 +1267,7 @@ _add_border(E_Border *bd)
DBG("add stack"); DBG("add stack");
assert((0 <= nb_stacks) && (nb_stacks < TILING_MAX_STACKS));
e_zone_useful_geometry_get(bd->zone, &x, &y, &w, &h); e_zone_useful_geometry_get(bd->zone, &x, &y, &w, &h);
if (_G.tinfo->conf->use_rows) { if (_G.tinfo->conf->use_rows) {
@ -1379,6 +1380,8 @@ _remove_border(E_Border *bd)
nb_stacks--; nb_stacks--;
assert((0 <= nb_stacks) && (nb_stacks < TILING_MAX_STACKS - 1));
for (i = stack; i < nb_stacks; i++) { for (i = stack; i < nb_stacks; i++) {
_G.tinfo->stacks[i] = _G.tinfo->stacks[i+1]; _G.tinfo->stacks[i] = _G.tinfo->stacks[i+1];
} }
@ -2110,7 +2113,9 @@ _move_left_cols(E_Border *bd, Eina_Bool check_moving_anims)
int nb_stacks; int nb_stacks;
stack = get_stack(bd); stack = get_stack(bd);
assert(stack >= 0); if (stack < 0)
return;
nb_stacks = get_stack_count(); nb_stacks = get_stack_count();
extra = eina_hash_find(_G.border_extras, &bd); extra = eina_hash_find(_G.border_extras, &bd);
@ -2129,8 +2134,8 @@ _move_left_cols(E_Border *bd, Eina_Bool check_moving_anims)
return; return;
EINA_LIST_REMOVE(_G.tinfo->stacks[0], bd); EINA_LIST_REMOVE(_G.tinfo->stacks[0], bd);
for (i = TILING_MAX_STACKS; i -- > 0;) { for (i = TILING_MAX_STACKS - 1; i > 0; i--) {
_G.tinfo->stacks[i] = _G.tinfo->stacks[i-1]; _G.tinfo->stacks[i] = _G.tinfo->stacks[i - 1];
} }
_G.tinfo->stacks[0] = NULL; _G.tinfo->stacks[0] = NULL;
EINA_LIST_APPEND(_G.tinfo->stacks[0], bd); EINA_LIST_APPEND(_G.tinfo->stacks[0], bd);
@ -2224,10 +2229,12 @@ _move_right_cols(E_Border *bd, Eina_Bool check_moving_anims)
int i; int i;
stack = get_stack(bd); stack = get_stack(bd);
assert(stack >= 0);
if (stack == TILING_MAX_STACKS - 1) if (stack == TILING_MAX_STACKS - 1)
return; return;
nb_stacks = get_stack_count(); nb_stacks = get_stack_count();
assert((0 < nb_stacks) && (nb_stacks < TILING_MAX_STACKS));
if (stack == nb_stacks - 1 && !_G.tinfo->stacks[stack]->next) if (stack == nb_stacks - 1 && !_G.tinfo->stacks[stack]->next)
return; return;
@ -2251,6 +2258,8 @@ _move_right_cols(E_Border *bd, Eina_Bool check_moving_anims)
int x, y, w, h; int x, y, w, h;
int width = 0; int width = 0;
assert(nb_stacks < TILING_MAX_STACKS);
_reorganize_stack(stack); _reorganize_stack(stack);
e_zone_useful_geometry_get(bd->zone, &x, &y, &w, &h); e_zone_useful_geometry_get(bd->zone, &x, &y, &w, &h);
@ -2326,8 +2335,7 @@ _move_left_rows(E_Border *bd, Eina_Bool check_moving_anims)
int stack; int stack;
stack = get_stack(bd); stack = get_stack(bd);
if (stack < 0) assert(stack >= 0);
return;
if (_G.tinfo->stacks[stack]->data == bd) if (_G.tinfo->stacks[stack]->data == bd)
return; return;
@ -2382,8 +2390,7 @@ _move_right_rows(E_Border *bd, Eina_Bool check_moving_anims)
int stack; int stack;
stack = get_stack(bd); stack = get_stack(bd);
if (stack < 0) assert(stack >= 0);
return;
l_1 = eina_list_data_find_list(_G.tinfo->stacks[stack], bd_1); l_1 = eina_list_data_find_list(_G.tinfo->stacks[stack], bd_1);
if (!l_1 || !l_1->next) if (!l_1 || !l_1->next)
@ -2433,6 +2440,7 @@ _move_up_rows(E_Border *bd, Eina_Bool check_moving_anims)
stack = get_stack(bd); stack = get_stack(bd);
assert(stack >= 0); assert(stack >= 0);
nb_stacks = get_stack_count(); nb_stacks = get_stack_count();
extra = eina_hash_find(_G.border_extras, &bd); extra = eina_hash_find(_G.border_extras, &bd);
@ -2451,7 +2459,7 @@ _move_up_rows(E_Border *bd, Eina_Bool check_moving_anims)
return; return;
EINA_LIST_REMOVE(_G.tinfo->stacks[0], bd); EINA_LIST_REMOVE(_G.tinfo->stacks[0], bd);
for (i = TILING_MAX_STACKS; i -- > 0;) { for (i = TILING_MAX_STACKS - 1; i > 0; i--) {
_G.tinfo->stacks[i] = _G.tinfo->stacks[i-1]; _G.tinfo->stacks[i] = _G.tinfo->stacks[i-1];
} }
_G.tinfo->stacks[0] = NULL; _G.tinfo->stacks[0] = NULL;
@ -2546,10 +2554,12 @@ _move_down_rows(E_Border *bd, Eina_Bool check_moving_anims)
int i; int i;
stack = get_stack(bd); stack = get_stack(bd);
assert(stack >= 0);
if (stack == TILING_MAX_STACKS - 1) if (stack == TILING_MAX_STACKS - 1)
return; return;
nb_stacks = get_stack_count(); nb_stacks = get_stack_count();
assert(nb_stacks >= 1);
if (stack == nb_stacks - 1 && !_G.tinfo->stacks[stack]->next) if (stack == nb_stacks - 1 && !_G.tinfo->stacks[stack]->next)
return; return;
@ -2573,6 +2583,8 @@ _move_down_rows(E_Border *bd, Eina_Bool check_moving_anims)
int x, y, w, h; int x, y, w, h;
int height = 0; int height = 0;
assert(nb_stacks < TILING_MAX_STACKS);
_reorganize_stack(stack); _reorganize_stack(stack);
e_zone_useful_geometry_get(bd->zone, &x, &y, &w, &h); e_zone_useful_geometry_get(bd->zone, &x, &y, &w, &h);
@ -3284,7 +3296,9 @@ _do_transition_overlay(void)
e_popup_show(trov->overlay.popup); e_popup_show(trov->overlay.popup);
} }
} }
if (i != TILING_MAX_STACKS && _G.tinfo->stacks[i+1] && n < nmax) { if (i != (TILING_MAX_STACKS - 1) &&
_G.tinfo->stacks[i+1] && n < nmax)
{
Evas_Coord ew, eh; Evas_Coord ew, eh;
transition_overlay_t *trov; transition_overlay_t *trov;