Evas filters: Fix bad stringshare usage

Make sure the filter uses properly initialized state names and
don't call stringshare_del on a static string.
This commit is contained in:
Jean-Philippe Andre 2016-02-29 17:04:13 +09:00
parent 24f19dc770
commit b369989a79
3 changed files with 16 additions and 7 deletions

View File

@ -11,7 +11,7 @@
#define ENFN obj->layer->evas->engine.func
#define ENDT obj->layer->evas->engine.data.output
#define FCOW_BEGIN(_pd) eina_cow_write(evas_object_filter_cow, (const Eina_Cow_Data**)&(_pd->data))
#define FCOW_BEGIN(_pd) ({ Evas_Object_Filter_Data *_fcow = eina_cow_write(evas_object_filter_cow, (const Eina_Cow_Data**)&(_pd->data)); _state_check(_fcow); _fcow; })
#define FCOW_END(_fcow, _pd) eina_cow_done(evas_object_filter_cow, (const Eina_Cow_Data**)&(_pd->data), _fcow, EINA_TRUE)
typedef struct _Evas_Filter_Data Evas_Filter_Data;
@ -31,6 +31,15 @@ struct _Evas_Filter_Post_Render_Data
Eina_Bool success;
};
static inline void
_state_check(Evas_Object_Filter_Data *fcow)
{
if (!fcow->state.cur.name)
fcow->state.cur.name = eina_stringshare_add("default");
if (!fcow->state.next.name)
fcow->state.next.name = eina_stringshare_add("default");
}
static void
_filter_end_sync(Evas_Filter_Context *ctx, Evas_Object_Protected_Data *obj,
Evas_Filter_Data *pd, Eina_Bool success)

View File

@ -33,7 +33,7 @@ static const Evas_Object_Protected_State default_state = {
1.0, 0, EVAS_RENDER_BLEND, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE, EINA_FALSE
};
static const Evas_Object_Filter_Data default_filter = {
NULL, NULL, NULL, NULL, NULL, NULL, { { "default", 0.0 }, { "default", 0.0 }, 0.0 }, EINA_FALSE, EINA_FALSE, EINA_TRUE
NULL, NULL, NULL, NULL, NULL, NULL, { { NULL, 0.0 }, { NULL, 0.0 }, 0.0 }, EINA_FALSE, EINA_FALSE, EINA_TRUE
};
const void * const evas_object_filter_cow_default = &default_filter;
static const Evas_Object_Mask_Data default_mask = {

View File

@ -1191,14 +1191,14 @@ struct _Evas_Object_Filter_Data
void *output;
struct {
struct {
const char *name;
double value;
Eina_Stringshare *name;
double value;
} cur;
struct {
const char *name;
double value;
Eina_Stringshare *name;
double value;
} next;
double pos;
double pos;
} state;
Eina_Bool changed : 1;
Eina_Bool invalid : 1; // Code parse failed