Skip to content
Snippets Groups Projects
Commit 39aacb4d authored by Laszlo Agocs's avatar Laszlo Agocs Committed by Jørgen Lind
Browse files

Fix data device handling.


Clearing the device list on resource destroy is wrong: it cleans away
data devices for all clients. Calling free when removing stale devices
for a client is also wrong.

Change-Id: I7bfcc928762dc4ca7dbf5abeebcd2489956e6828
Reviewed-by: default avatarJørgen Lind <jorgen.lind@nokia.com>
parent 083ece74
No related branches found
No related tags found
No related merge requests found
...@@ -220,17 +220,21 @@ void InputDevice::setMouseFocus(Surface *surface, const QPoint &globalPos, const ...@@ -220,17 +220,21 @@ void InputDevice::setMouseFocus(Surface *surface, const QPoint &globalPos, const
localPos.x(), localPos.y()); localPos.x(), localPos.y());
} }
void InputDevice::clientRequestedDataDevice(DataDeviceManager *data_device_manager, struct wl_client *client, uint32_t id) void InputDevice::cleanupDataDeviceForClient(struct wl_client *client)
{ {
for (int i = 0; i < m_data_devices.size(); i++) { for (int i = 0; i < m_data_devices.size(); i++) {
struct wl_resource *data_device_resource = struct wl_resource *data_device_resource =
m_data_devices.at(i)->dataDeviceResource(); m_data_devices.at(i)->dataDeviceResource();
if (data_device_resource->client == client) { if (data_device_resource->client == client) {
m_data_devices.removeAt(i); m_data_devices.removeAt(i);
free(data_device_resource);
break; break;
} }
} }
}
void InputDevice::clientRequestedDataDevice(DataDeviceManager *data_device_manager, struct wl_client *client, uint32_t id)
{
cleanupDataDeviceForClient(client);
DataDevice *dataDevice = new DataDevice(data_device_manager,client,id); DataDevice *dataDevice = new DataDevice(data_device_manager,client,id);
m_data_devices.append(dataDevice); m_data_devices.append(dataDevice);
} }
...@@ -328,7 +332,7 @@ void InputDevice::destroy_resource(wl_resource *resource) ...@@ -328,7 +332,7 @@ void InputDevice::destroy_resource(wl_resource *resource)
input_device->base()->pointer_focus_resource = 0; input_device->base()->pointer_focus_resource = 0;
} }
input_device->m_data_devices.clear(); input_device->cleanupDataDeviceForClient(resource->client);
wl_list_remove(&resource->link); wl_list_remove(&resource->link);
......
...@@ -89,7 +89,10 @@ public: ...@@ -89,7 +89,10 @@ public:
Compositor *compositor() const; Compositor *compositor() const;
WaylandInputDevice *handle() const; WaylandInputDevice *handle() const;
private: private:
void cleanupDataDeviceForClient(struct wl_client *client);
WaylandInputDevice *m_handle; WaylandInputDevice *m_handle;
Compositor *m_compositor; Compositor *m_compositor;
QList<DataDevice *>m_data_devices; QList<DataDevice *>m_data_devices;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment