fix crash after moving gadget between two zones

Summary:
add check new_gcc into the gadman's gadget add handler to prevent invalid ref_count increase
while moving between two zones. and also add object clean code for new_gcc and drag_gcc
when gadget is dropped.

Fixes T722

Test Plan:
1. create clock module on gadcon desktop (settings->gadgets, select "background" under layers, click "configure layer" and add a clock gadget).
2. drag clock gadget from one screen to the other. drop it there.
3. drag clock back to first screen
4. right click on clock and select "clock->remove".

Reviewers: raster, devilhorns, zmike

Subscribers: cedric

Maniphest Tasks: T722

Differential Revision: https://phab.enlightenment.org/D1256
This commit is contained in:
Gwanglim Lee 2014-08-11 19:35:36 -04:00 committed by Mike Blumenkrantz
parent d5cbe23bd2
commit ec8a6b829e
2 changed files with 9 additions and 3 deletions

View File

@ -3081,8 +3081,7 @@ _e_gadcon_cb_dnd_drop(void *data, const char *type __UNUSED__, void *event __UNU
if (gc->dnd_drop_cb) gc->dnd_drop_cb(gc, gc->drag_gcc);
return;
}
/* still has refcount from drag */
e_object_del(E_OBJECT(gc->drag_gcc));
gcc = gc->new_gcc;
if (!gc->o_container)
@ -3099,12 +3098,17 @@ _e_gadcon_cb_dnd_drop(void *data, const char *type __UNUSED__, void *event __UNU
e_gadcon_custom_populate_request(gc);
e_config_save_queue();
if (gc->dnd_drop_cb) gc->dnd_drop_cb(gc, gc->drag_gcc);
return;
goto cleanup;
}
if (gc->editing) e_gadcon_client_edit_begin(gc->new_gcc);
gc->new_gcc = NULL;
e_config_save_queue();
if (gc->dnd_drop_cb) gc->dnd_drop_cb(gc, gc->drag_gcc);
cleanup:
/* still has refcount from drag */
e_object_del(E_OBJECT(gc->drag_gcc));
gc->drag_gcc = NULL;
}
static int

View File

@ -220,6 +220,8 @@ gadman_gadget_add_handler(void *d __UNUSED__, int type __UNUSED__, E_Event_Gadco
if (!l) return ECORE_CALLBACK_RENEW;
if (ev->gcc->cf->geom.pos_x || ev->gcc->cf->geom.pos_y || ev->gcc->cf->geom.size_w || ev->gcc->cf->geom.size_h)
return ECORE_CALLBACK_RENEW;
if ((ev->gcc->gadcon->new_gcc) && (ev->gcc->gadcon->new_gcc == ev->gcc))
return ECORE_CALLBACK_RENEW;
ev->gcc->cf->style = eina_stringshare_add(ev->gcc->client_class->default_style ?: E_GADCON_CLIENT_STYLE_INSET);
ev->gcc->style = eina_stringshare_ref(ev->gcc->cf->style);
ev->gcc->cf->geom.pos_x = DEFAULT_POS_X;