evas: check evas class instead of using evas_find

Summary:
A object that is not evas class shouldn't use evas_find. it may occurs segfault.

ref c2e8b492b1

Test Plan:
Evas *evas = evas_new();
evas_free(evas);
evas_object_line_add(evas);

Check weather there is segfault.

Reviewers: Hermet, raster, zmike

Reviewed By: zmike

Subscribers: cedric, #reviewers, #committers, zmike

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D6816
This commit is contained in:
Yeongjong Lee 2018-08-16 13:01:26 -04:00 committed by Mike Blumenkrantz
parent 633d16aae7
commit 8bb11a172b
13 changed files with 19 additions and 31 deletions

View File

@ -13,6 +13,8 @@
#include "edje_private.h"
#include "canvas/evas_canvas.eo.h"
#define EDJE_EDIT_IS_UNSTABLE_AND_I_KNOW_ABOUT_IT
#include "Edje_Edit.h"
@ -289,6 +291,7 @@ _edje_edit_efl_file_mmap_set(Eo *obj, Edje_Edit *eed, const Eina_File *mmap, con
EAPI Evas_Object *
edje_edit_object_add(Evas *evas)
{
EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_isa(evas, EVAS_CANVAS_CLASS), NULL);
return efl_add(MY_CLASS, evas_find(evas), efl_canvas_object_legacy_ctor(efl_added));
}

View File

@ -4,6 +4,8 @@
#include "edje_private.h"
#include "canvas/evas_canvas.eo.h"
#ifdef MY_CLASS
# undef MY_CLASS
#endif
@ -20,7 +22,7 @@ Eina_Inlist *_edje_edjes = NULL;
EAPI Evas_Object *
edje_object_add(Evas *evas)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(evas, NULL);
EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_isa(evas, EVAS_CANVAS_CLASS), NULL);
return efl_add(MY_CLASS, evas_find(evas), efl_canvas_object_legacy_ctor(efl_added));
}

View File

@ -19,6 +19,8 @@
#include "Emotion.h"
#include "emotion_private.h"
#include "canvas/evas_canvas.eo.h"
#ifdef _WIN32
# define FMT_UCHAR "%c"
#else
@ -230,6 +232,7 @@ _clipper_position_size_update(Evas_Object *obj, int x, int y, int w, int h, int
EAPI Evas_Object *
emotion_object_add(Evas *evas)
{
EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_isa(evas, EVAS_CANVAS_CLASS), NULL);
return efl_add(MY_CLASS, evas_find(evas), efl_canvas_object_legacy_ctor(efl_added));
}

View File

@ -124,9 +124,7 @@ _evas_vg_resize(void *data, const Efl_Event *ev)
EAPI Evas_Object *
evas_object_vg_add(Evas *e)
{
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_isa(e, EVAS_CANVAS_CLASS), NULL);
// TODO: Ask backend to return the main Ector_Surface
return efl_add(MY_CLASS, evas_find(e), efl_canvas_object_legacy_ctor(efl_added));
}

View File

@ -475,9 +475,7 @@ _evas_box_efl_canvas_group_group_calculate(Eo *o, Evas_Object_Box_Data *priv)
EAPI Evas_Object *
evas_object_box_add(Evas *evas)
{
MAGIC_CHECK(evas, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_isa(evas, EVAS_CANVAS_CLASS), NULL);
return efl_add(MY_CLASS, evas_find(evas), efl_canvas_object_legacy_ctor(efl_added));
}

View File

@ -273,9 +273,7 @@ _evas_object_grid_smart_set_user(Evas_Smart_Class *sc)
EAPI Evas_Object *
evas_object_grid_add(Evas *evas)
{
MAGIC_CHECK(evas, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_isa(evas, EVAS_CANVAS_CLASS), NULL);
return efl_add(MY_CLASS, evas_find(evas), efl_canvas_object_legacy_ctor(efl_added));
}

View File

@ -94,9 +94,7 @@ static const Evas_Object_Func object_func =
EAPI Evas_Object *
evas_object_line_add(Evas *e)
{
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_isa(e, EVAS_CANVAS_CLASS), NULL);
return efl_add(EVAS_LINE_CLASS, evas_find(e), efl_canvas_object_legacy_ctor(efl_added));
}

View File

@ -84,9 +84,7 @@ static const Evas_Object_Func object_func =
EAPI Evas_Object *
evas_object_polygon_add(Evas *e)
{
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_isa(e, EVAS_CANVAS_CLASS), NULL);
return efl_add(MY_CLASS, evas_find(e), efl_canvas_object_legacy_ctor(efl_added));
}

View File

@ -92,9 +92,7 @@ static const Evas_Object_Func object_func =
EAPI Evas_Object *
evas_object_rectangle_add(Evas *e)
{
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_isa(e, EVAS_CANVAS_CLASS), NULL);
return efl_add(EFL_CANVAS_RECTANGLE_CLASS, evas_find(e), efl_canvas_object_legacy_ctor(efl_added));
}

View File

@ -675,9 +675,7 @@ evas_object_smart_add(Evas *eo_e, Evas_Smart *s)
{
Evas_Object *eo_obj;
MAGIC_CHECK(eo_e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_isa(eo_e, EVAS_CANVAS_CLASS), NULL);
eo_obj = efl_add(EFL_CANVAS_GROUP_CLASS, evas_find(eo_e), efl_canvas_object_legacy_ctor(efl_added));
evas_object_smart_attach(eo_obj, s);
return eo_obj;

View File

@ -979,9 +979,7 @@ _evas_table_efl_canvas_group_group_calculate(Eo *o, Evas_Table_Data *priv)
EAPI Evas_Object *
evas_object_table_add(Evas *evas)
{
MAGIC_CHECK(evas, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_isa(evas, EVAS_CANVAS_CLASS), NULL);
return efl_add(MY_CLASS, evas_find(evas), efl_canvas_object_legacy_ctor(efl_added));
}

View File

@ -376,9 +376,7 @@ _evas_object_text_vert_advance_get(const Evas_Object *obj EINA_UNUSED,
EAPI Evas_Object *
evas_object_text_add(Evas *e)
{
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_isa(e, EVAS_CANVAS_CLASS), NULL);
return efl_add(EVAS_TEXT_CLASS, evas_find(e), efl_canvas_object_legacy_ctor(efl_added));
}

View File

@ -899,9 +899,7 @@ _evas_textgrid_efl_gfx_entity_scale_set(Evas_Object *eo_obj, Evas_Textgrid_Data
EAPI Evas_Object *
evas_object_textgrid_add(Evas *e)
{
MAGIC_CHECK(e, Evas, MAGIC_EVAS);
return NULL;
MAGIC_CHECK_END();
EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_isa(e, EVAS_CANVAS_CLASS), NULL);
return efl_add(EVAS_TEXTGRID_CLASS, evas_find(e), efl_canvas_object_legacy_ctor(efl_added));
}