Fix clipboard crash in clients with weston
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>
Sat, 19 May 2012 16:45:53 +0000 (19:45 +0300)
committerJørgen Lind <jorgen.lind@nokia.com>
Mon, 21 May 2012 06:38:55 +0000 (08:38 +0200)
The offer passed to selection() can be null. This case was not handled
before because it never happens with qt-compositor. Copy/paste is still
not ok with weston but at least the apps won't crash.

Change-Id: I91d529e9d8b179724637d05bb9b95ec5843bda2b
Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
src/plugins/platforms/wayland/qwaylanddatadevicemanager.cpp

index 81972e8..0975d24 100644 (file)
@@ -170,6 +170,7 @@ void QWaylandDataDeviceManager::selection(void *data,
                                             struct wl_data_offer *id)
 {
     Q_UNUSED(wl_data_device);
+
     QWaylandDataDeviceManager *handler = static_cast<QWaylandDataDeviceManager *>(data);
     QWaylandDataOffer *mime = handler->m_selection_data_offer;
     delete mime;
@@ -177,8 +178,12 @@ void QWaylandDataDeviceManager::selection(void *data,
     delete transfer_source;
     handler->m_selection_data_source = 0;
 
-    mime = static_cast<QWaylandDataOffer *>(wl_data_offer_get_user_data(id));
-    handler->m_selection_data_offer = mime;
+    if (id) {
+        mime = static_cast<QWaylandDataOffer *>(wl_data_offer_get_user_data(id));
+        handler->m_selection_data_offer = mime;
+    } else {
+        handler->m_selection_data_offer = 0;
+    }
 
     QGuiApplicationPrivate::platformIntegration()->clipboard()->emitChanged(QClipboard::Clipboard);
 }