Fix data source resource destruction in qt-compositor.
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>
Tue, 6 Dec 2011 10:21:05 +0000 (12:21 +0200)
committerJørgen Lind <jorgen.lind@nokia.com>
Tue, 6 Dec 2011 15:17:00 +0000 (16:17 +0100)
Change-Id: Ieb7551c6d85979b5e6bb07927abeaabcf2466c20
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
src/qt-compositor/wayland_wrapper/wldatasource.cpp
src/qt-compositor/wayland_wrapper/wldatasource.h

index 57e4b17..a3c75ec 100644 (file)
@@ -55,6 +55,7 @@ DataSource::DataSource(struct wl_client *client, uint32_t id, uint32_t time)
     : m_time(time)
 {
     m_data_source_resource = wl_client_add_object(client, &wl_data_source_interface, &DataSource::data_source_interface,id,this);
+    m_data_source_resource->destroy = resource_destroy;
     m_data_offer = new DataOffer(this);
 }
 
@@ -64,6 +65,14 @@ DataSource::~DataSource()
     wl_resource_destroy(m_data_source_resource,Compositor::currentTimeMsecs());
 }
 
+void DataSource::resource_destroy(wl_resource *resource)
+{
+    DataSource *source = static_cast<DataSource *>(resource->data);
+    if (source && source->m_data_source_resource == resource)
+        source->m_data_source_resource = 0;
+    free(resource);
+}
+
 uint32_t DataSource::time() const
 {
     return m_time;
index a848fc4..59385ec 100644 (file)
@@ -76,7 +76,7 @@ private:
                   const char *type);
     static void destroy(struct wl_client *client,
                     struct wl_resource *resource);
-
+    static void resource_destroy(struct wl_resource *resource);
 
 };