*spank spank* null checks.

-Add null checks before using an Evas_Object, avoiding potential segfault(s).

-Check returns from evas_object_data_get() as it has potential to return
NULL, and previously if it did, E would segfault.


SVN revision: 24074
This commit is contained in:
Christopher Michael 2006-07-20 15:39:27 +00:00
parent 08e46655a9
commit 9acfbd1810
1 changed files with 71 additions and 0 deletions

View File

@ -1727,6 +1727,8 @@ e_gadcon_layout_orientation_set(Evas_Object *obj, int horizontal)
{
E_Smart_Data *sd;
if (!obj) return;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if (((sd->horizontal) && (horizontal)) ||
@ -1740,6 +1742,8 @@ e_gadcon_layout_orientation_get(Evas_Object *obj)
{
E_Smart_Data *sd;
if (!obj) return;
sd = evas_object_smart_data_get(obj);
if (!sd) return 0;
return sd->horizontal;
@ -1750,6 +1754,8 @@ e_gadcon_layout_freeze(Evas_Object *obj)
{
E_Smart_Data *sd;
if (!obj) return;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
sd->frozen++;
@ -1760,6 +1766,8 @@ e_gadcon_layout_thaw(Evas_Object *obj)
{
E_Smart_Data *sd;
if (!obj) return;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
sd->frozen--;
@ -1774,6 +1782,7 @@ e_gadcon_layout_min_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
Evas_List *l;
Evas_Coord tw = 0, th = 0;
*/
if (!obj) return;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
@ -1810,6 +1819,8 @@ e_gadcon_layout_asked_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h)
E_Smart_Data *sd;
Evas_Coord tw = 0, th = 0;
if (!obj) return;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if (sd->horizontal)
@ -1843,6 +1854,8 @@ e_gadcon_layout_pack(Evas_Object *obj, Evas_Object *child)
{
E_Smart_Data *sd;
if (!obj) return 0;
sd = evas_object_smart_data_get(obj);
if (!sd) return 0;
_e_gadcon_layout_smart_adopt(sd, child);
@ -1857,6 +1870,8 @@ e_gadcon_layout_pack_size_set(Evas_Object *obj, int size)
E_Gadcon_Layout_Item *bi;
int xx;
if (!obj) return;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) return;
xx = bi->ask.pos + (bi->ask.size / 2);
@ -1907,6 +1922,8 @@ e_gadcon_layout_pack_request_set(Evas_Object *obj, int pos, int size)
{
E_Gadcon_Layout_Item *bi;
if (!obj) return;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) return;
if (bi->sd->horizontal)
@ -1926,6 +1943,8 @@ e_gadcon_layout_pack_options_set(Evas_Object *obj, int pos, int size, int res)
{
E_Gadcon_Layout_Item *bi;
if (!obj) return;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) return;
bi->ask.res = res;
@ -1939,6 +1958,8 @@ e_gadcon_layout_pack_min_size_set(Evas_Object *obj, int w, int h)
{
E_Gadcon_Layout_Item *bi;
if (!obj) return;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) return;
bi->min.w = w;
@ -1951,6 +1972,8 @@ e_gadcon_layout_pack_aspect_set(Evas_Object *obj, int w, int h)
{
E_Gadcon_Layout_Item *bi;
if (!obj) return;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) return;
bi->aspect.w = w;
@ -1963,6 +1986,8 @@ e_gadcon_layout_pack_aspect_pad_set(Evas_Object *obj, int w, int h)
{
E_Gadcon_Layout_Item *bi;
if (!obj) return;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) return;
bi->aspect_pad.w = w;
@ -1975,6 +2000,8 @@ e_gadcon_layout_unpack(Evas_Object *obj)
E_Gadcon_Layout_Item *bi;
E_Smart_Data *sd;
if (!obj) return;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) return;
sd = bi->sd;
@ -1990,6 +2017,8 @@ _e_gadcon_layout_smart_adopt(E_Smart_Data *sd, Evas_Object *obj)
{
E_Gadcon_Layout_Item *bi;
if (!obj) return NULL;
bi = calloc(1, sizeof(E_Gadcon_Layout_Item));
if (!bi) return NULL;
bi->sd = sd;
@ -2011,6 +2040,8 @@ _e_gadcon_layout_smart_disown(Evas_Object *obj)
{
E_Gadcon_Layout_Item *bi;
if (!obj) return;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) return;
if (!bi->sd->items)
@ -2030,6 +2061,8 @@ _e_gadcon_layout_smart_disown(Evas_Object *obj)
static void
_e_gadcon_layout_smart_item_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
if (!obj) return;
e_gadcon_layout_unpack(obj);
}
@ -2088,6 +2121,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l->data;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) continue;
bi->ask.size2 = bi->ask.size;
if ((bi->aspect.w > 0) && (bi->aspect.h > 0))
{
@ -2165,6 +2199,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l->data;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) continue;
give = bi->ask.size - bi->min.w; // how much give does this have?
if (give < sub) give = sub;
bi->ask.size2 = bi->ask.size - give;
@ -2185,6 +2220,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l->data;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) continue;
bi->ask.size2 = bi->min.w;
if (!l->next)
{
@ -2220,6 +2256,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l->data;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) continue;
give = bi->ask.size - bi->min.h; // how much give does this have?
if (give < sub) give = sub;
bi->ask.size2 = bi->ask.size - give;
@ -2240,6 +2277,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l->data;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) continue;
bi->ask.size2 = bi->min.h;
if (!l->next)
{
@ -2263,6 +2301,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l->data;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) continue;
list = evas_list_append(list, obj);
if (sd->horizontal)
{
@ -2362,6 +2401,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l->data;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) continue;
again1:
for (l2 = l->prev; l2; l2 = l2->prev)
{
@ -2369,6 +2409,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l2->data;
bi2 = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi2) continue;
if (sd->horizontal)
{
if (E_SPANS_COMMON(bi->x, bi->w, bi2->x, bi2->w))
@ -2394,6 +2435,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l->data;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) continue;
again2:
for (l2 = l->prev; l2; l2 = l2->prev)
{
@ -2401,6 +2443,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l2->data;
bi2 = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi2) continue;
if (sd->horizontal)
{
if (E_SPANS_COMMON(bi->x, bi->w, bi2->x, bi2->w))
@ -2432,6 +2475,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l->data;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) continue;
again3:
for (l2 = l->prev; l2; l2 = l2->prev)
{
@ -2439,6 +2483,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l2->data;
bi2 = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi2) continue;
if (sd->horizontal)
{
if (E_SPANS_COMMON(bi->x, bi->w, bi2->x, bi2->w))
@ -2464,6 +2509,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l->data;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) continue;
bi->can_move = 1;
if (sd->horizontal)
{
@ -2521,6 +2567,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l->data;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) continue;
if (bi->can_move)
{
for (l2 = l->next; l2; l2 = l2->next)
@ -2529,6 +2576,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l2->data;
bi2 = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi2) continue;
if (E_SPANS_COMMON(bi->x, bi->w, bi2->x, bi2->w))
{
bi->x = bi2->x - bi->w;
@ -2544,6 +2592,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l2->data;
bi2 = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi2) continue;
if (E_SPANS_COMMON(bi->x, bi->w, bi2->x, bi2->w))
{
bi->x = bi2->x + bi2->w;
@ -2579,6 +2628,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l->data;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) continue;
if (bi->can_move)
{
for (l2 = l->next; l2; l2 = l2->next)
@ -2587,6 +2637,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l2->data;
bi2 = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi2) continue;
if (E_SPANS_COMMON(bi->y, bi->h, bi2->y, bi2->h))
{
bi->y = bi2->y - bi->h;
@ -2602,6 +2653,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l2->data;
bi2 = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi2) continue;
if (E_SPANS_COMMON(bi->y, bi->h, bi2->y, bi2->h))
{
bi->y = bi2->y + bi2->h;
@ -2630,6 +2682,7 @@ _e_gadcon_layout_smart_reconfigure(E_Smart_Data *sd)
obj = l->data;
bi = evas_object_data_get(obj, "e_gadcon_layout_data");
if (!bi) continue;
if (sd->horizontal)
{
bi->h = h;
@ -2703,6 +2756,8 @@ _e_gadcon_layout_smart_add(Evas_Object *obj)
{
E_Smart_Data *sd;
if (!obj) return;
sd = calloc(1, sizeof(E_Smart_Data));
if (!sd) return;
sd->obj = obj;
@ -2724,6 +2779,8 @@ _e_gadcon_layout_smart_del(Evas_Object *obj)
{
E_Smart_Data *sd;
if (!obj) return;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
while (sd->items)
@ -2742,6 +2799,8 @@ _e_gadcon_layout_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
{
E_Smart_Data *sd;
if (!obj) return;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if ((x == sd->x) && (y == sd->y)) return;
@ -2768,6 +2827,8 @@ _e_gadcon_layout_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
{
E_Smart_Data *sd;
if (!obj) return;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if ((w == sd->w) && (h == sd->h)) return;
@ -2781,6 +2842,8 @@ _e_gadcon_layout_smart_show(Evas_Object *obj)
{
E_Smart_Data *sd;
if (!obj) return;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
if (sd->items) evas_object_show(sd->clip);
@ -2791,6 +2854,8 @@ _e_gadcon_layout_smart_hide(Evas_Object *obj)
{
E_Smart_Data *sd;
if (!obj) return;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
evas_object_hide(sd->clip);
@ -2801,6 +2866,8 @@ _e_gadcon_layout_smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
{
E_Smart_Data *sd;
if (!obj) return;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
evas_object_color_set(sd->clip, r, g, b, a);
@ -2811,6 +2878,8 @@ _e_gadcon_layout_smart_clip_set(Evas_Object *obj, Evas_Object *clip)
{
E_Smart_Data *sd;
if (!obj) return;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
evas_object_clip_set(sd->clip, clip);
@ -2821,6 +2890,8 @@ _e_gadcon_layout_smart_clip_unset(Evas_Object *obj)
{
E_Smart_Data *sd;
if (!obj) return;
sd = evas_object_smart_data_get(obj);
if (!sd) return;
evas_object_clip_unset(sd->clip);