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

wucan canbaby at 21cn.com
Fri Nov 12 20:57:21 PST 2010


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);
+		}
  	}
  }

-- 
1.6.4.GIT
-- 
wucan


More information about the wayland-devel mailing list