data-device: Fix a few bugs in the commit to drop ref-counting

Did not test that change.
This commit is contained in:
Kristian Høgsberg 2012-01-03 22:43:36 -05:00
parent 9724b51750
commit db9bf1e818
2 changed files with 7 additions and 3 deletions

View File

@ -106,15 +106,16 @@ weston_data_source_send_offer(struct weston_data_source *source,
offer->resource.object.id = 0; offer->resource.object.id = 0;
offer->resource.object.interface = &wl_data_offer_interface; offer->resource.object.interface = &wl_data_offer_interface;
offer->resource.object.implementation = offer->resource.object.implementation =
(void (**)(void)) &source->offer_interface; (void (**)(void)) source->offer_interface;
offer->resource.data = offer; offer->resource.data = offer;
wl_list_init(&offer->resource.destroy_listener_list);
offer->source = source; offer->source = source;
offer->source_destroy_listener.func = destroy_offer_data_source; offer->source_destroy_listener.func = destroy_offer_data_source;
wl_list_insert(&source->resource.destroy_listener_list, wl_list_insert(&source->resource.destroy_listener_list,
&offer->source_destroy_listener.link); &offer->source_destroy_listener.link);
wl_client_add_resource(source->resource.client, &offer->resource); wl_client_add_resource(target->client, &offer->resource);
wl_resource_post_event(target, wl_resource_post_event(target,
WL_DATA_DEVICE_DATA_OFFER, &offer->resource); WL_DATA_DEVICE_DATA_OFFER, &offer->resource);
@ -398,6 +399,8 @@ create_data_source(struct wl_client *client,
source->resource.object.implementation = source->resource.object.implementation =
(void (**)(void)) &data_source_interface; (void (**)(void)) &data_source_interface;
source->resource.data = source; source->resource.data = source;
wl_list_init(&source->resource.destroy_listener_list);
source->offer_interface = &data_offer_interface; source->offer_interface = &data_offer_interface;
source->cancel = data_source_cancel; source->cancel = data_source_cancel;

View File

@ -243,7 +243,8 @@ static void
data_offer_receive(struct wl_client *client, struct wl_resource *resource, data_offer_receive(struct wl_client *client, struct wl_resource *resource,
const char *mime_type, int32_t fd) const char *mime_type, int32_t fd)
{ {
struct weston_wm *wm = resource->data; struct weston_data_offer *offer = resource->data;
struct weston_wm *wm = offer->source->resource.data;
if (strcmp(mime_type, "text/plain;charset=utf-8") == 0) { if (strcmp(mime_type, "text/plain;charset=utf-8") == 0) {
/* Get data for the utf8_string target */ /* Get data for the utf8_string target */