aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-11-23 23:07:54 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2013-11-23 23:07:54 +0900
commit53e27458f6d71a26291f896fbddc70f41d30478d (patch)
tree925f393986b4b2349922ddd91852d1f4655094ae
parentevas/examples: fix clipper colors in evas-object-manipulation (diff)
downloadefl-53e27458f6d71a26291f896fbddc70f41d30478d.tar.gz
evas - examples - fix broken evas stacking example
this fixes a broken example that assumes getting name always succeeds. this fixes https://phab.enlightenment.org/T559
-rw-r--r--src/examples/evas/evas-stacking.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/examples/evas/evas-stacking.c b/src/examples/evas/evas-stacking.c
index 67e85c1ca7..9763227f51 100644
--- a/src/examples/evas/evas-stacking.c
+++ b/src/examples/evas/evas-stacking.c
@@ -52,13 +52,21 @@ static const char *commands = \
"\tl - change background rectangle's layer\n"
"\th - print help\n";
+static const char *
+_name_get(Evas_Object *o)
+{
+ const char *s = evas_object_name_get(o);
+ if (!s) s = "(null)";
+ return s;
+}
+
static void
_on_mouse_down(void *data EINA_UNUSED,
Evas *evas EINA_UNUSED,
Evas_Object *o,
void *einfo EINA_UNUSED)
{
- fprintf(stdout, "Mouse down on rectangle %s!\n", evas_object_name_get(o));
+ fprintf(stdout, "Mouse down on rectangle %s!\n", _name_get(o));
}
/* here just to keep our example's window size and background image's
@@ -81,7 +89,7 @@ _on_keydown(void *data EINA_UNUSED,
void *einfo)
{
Evas_Event_Key_Down *ev = einfo;
- const char *name = evas_object_name_get(d.rects[d.cur_rect]);
+ const char *name = _name_get(d.rects[d.cur_rect]);
if (strcmp(ev->keyname, "h") == 0) /* print help */
{
@@ -98,19 +106,19 @@ _on_keydown(void *data EINA_UNUSED,
fprintf(stdout, "Order of stacking, from top to bottom, is: ");
rect = evas_object_top_get(evas);
- fprintf(stdout, "%s", evas_object_name_get(rect));
+ fprintf(stdout, "%s", _name_get(rect));
rect = evas_object_below_get(rect);
while (rect)
{
- fprintf(stdout, ", %s", evas_object_name_get(rect));
+ fprintf(stdout, ", %s", _name_get(rect));
rect = evas_object_below_get(rect);
}
fprintf(stdout, ".\n");
fprintf(stdout, "Current target rectangle is %s\n",
- evas_object_name_get(d.rects[d.cur_rect]));
+ _name_get(d.rects[d.cur_rect]));
fprintf(stdout, "Background rectangle's layer is %d\n",
evas_object_layer_get(d.bg));
@@ -133,7 +141,7 @@ _on_keydown(void *data EINA_UNUSED,
d.cur_rect = (d.cur_rect + 1) % 3;
fprintf(stdout, "Changing target rectangle to the %s one\n",
- evas_object_name_get(d.rects[d.cur_rect]));
+ _name_get(d.rects[d.cur_rect]));
return;
}
@@ -148,7 +156,7 @@ _on_keydown(void *data EINA_UNUSED,
neighbour = evas_object_below_get(d.rects[d.cur_rect]);
fprintf(stdout, "Below of %s rect is %s\n", name,
- neighbour ? evas_object_name_get(neighbour) : "no object");
+ neighbour ? _name_get(neighbour) : "no object");
return;
}
@@ -164,7 +172,7 @@ _on_keydown(void *data EINA_UNUSED,
neighbour = evas_object_below_get(d.rects[d.cur_rect]);
fprintf(stdout, "Below of %s rect is %s\n", name,
- neighbour ? evas_object_name_get(neighbour) : "no object");
+ neighbour ? _name_get(neighbour) : "no object");
return;
}
@@ -206,11 +214,11 @@ _on_keydown(void *data EINA_UNUSED,
neighbour = evas_object_above_get(d.rects[d.cur_rect]);
fprintf(stdout, "Above of %s rect is %s\n", name,
- neighbour ? evas_object_name_get(neighbour) : "no object");
+ neighbour ? _name_get(neighbour) : "no object");
neighbour = evas_object_below_get(d.rects[d.cur_rect]);
fprintf(stdout, "Below of %s rect is %s\n", name,
- neighbour ? evas_object_name_get(neighbour) : "no object");
+ neighbour ? _name_get(neighbour) : "no object");
return;
}
@@ -228,12 +236,12 @@ _on_keydown(void *data EINA_UNUSED,
neighbour = evas_object_above_get(d.rects[d.cur_rect]);
fprintf(stdout, "Above of %s rect is %s\n", name,
- neighbour ? evas_object_name_get(neighbour) : "no object");
+ neighbour ? _name_get(neighbour) : "no object");
neighbour = evas_object_below_get(d.rects[d.cur_rect]);
fprintf(stdout, "Below of %s rect is %s\n", name,
- neighbour ? evas_object_name_get(neighbour) : "no object");
+ neighbour ? _name_get(neighbour) : "no object");
return;
}
}