[PATCH v2] client: don't call drag_offer_handler if it not hooked

wucan canbaby at 21cn.com
Sat Nov 13 20:32:21 PST 2010


On 11/13/2010 11:20 PM, Tiago Vignatti wrote:
> On Sat, Nov 13, 2010 at 12:57:21PM +0800, ext wucan wrote:
>> When play with dnd and terminal, if you drag any item in dnd to
>> terminal,terminal segvment fault. It's because terminal not setup
>> drag_offer_handler, but when a item dragged on it's window,
>> display_handle_global() trigger the handler.
>> ---
>>   clients/window.c |    6 ++++--
>>   1 files changed, 4 insertions(+), 2 deletions(-)
>>
>> Don't create "offer" too, sorry.
>>
>> diff --git a/clients/window.c b/clients/window.c
>> index 9dfd355..9ee4212 100644
>> --- a/clients/window.c
>> +++ b/clients/window.c
>> @@ -1328,8 +1328,10 @@ display_handle_global(struct wl_display
>> *display, uint32_t id,
>>   	} else if (strcmp(interface, "shm") == 0) {
>>   		d->shm = wl_shm_create(display, id);
>>   	} else if (strcmp(interface, "drag_offer") == 0) {
>> -		offer = wl_drag_offer_create(display, id);
>> -		d->drag_offer_handler(offer, d);
>> +		if (d->drag_offer_handler) {
>> +			offer = wl_drag_offer_create(display, id);
>> +			d->drag_offer_handler(offer, d);
>> +		}
>>   	}
>>   }
>
> The other way to fix it would be creating a stub function for the drag handler
> and initiate it with display_set_drag_offer_handler. But we should protect
> anyway those clients not initialize it, so:
>
yes, stub function seems a better solution for all these handler stuff.
> Reviewed-by: Tiago Vignatti<tiago.vignatti at nokia.com>
thanks
>
>               Tiago
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
>


-- 
wucan


More information about the wayland-devel mailing list