[PATCH v2] client: don't call drag_offer_handler if it not hooked
Tiago Vignatti
tiago.vignatti at nokia.com
Sat Nov 13 07:20:21 PST 2010
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:
Reviewed-by: Tiago Vignatti <tiago.vignatti at nokia.com>
Tiago
More information about the wayland-devel
mailing list