aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy
diff options
context:
space:
mode:
authorEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-08-15 18:06:51 +0800
committerEmilio Pozuelo Monfort <emilio.pozuelo@collabora.co.uk>2011-08-15 20:03:28 +0800
commit64b8693b800d880aee7f16e5b353f239a24e02fa (patch)
treec15ce6847e1654d03dca27c15a21b274956f1989 /libempathy
parent0e00979f11c465a755b9dd29b2247a8f3ec1c51d (diff)
downloadgsoc2013-empathy-64b8693b800d880aee7f16e5b353f239a24e02fa.tar
gsoc2013-empathy-64b8693b800d880aee7f16e5b353f239a24e02fa.tar.gz
gsoc2013-empathy-64b8693b800d880aee7f16e5b353f239a24e02fa.tar.bz2
gsoc2013-empathy-64b8693b800d880aee7f16e5b353f239a24e02fa.tar.lz
gsoc2013-empathy-64b8693b800d880aee7f16e5b353f239a24e02fa.tar.xz
gsoc2013-empathy-64b8693b800d880aee7f16e5b353f239a24e02fa.tar.zst
gsoc2013-empathy-64b8693b800d880aee7f16e5b353f239a24e02fa.zip
CameraMonitor: dynamically-allocate the queue
Diffstat (limited to 'libempathy')
-rw-r--r--libempathy/empathy-camera-monitor.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/libempathy/empathy-camera-monitor.c b/libempathy/empathy-camera-monitor.c
index d3d8beb80..da6b23492 100644
--- a/libempathy/empathy-camera-monitor.c
+++ b/libempathy/empathy-camera-monitor.c
@@ -34,7 +34,7 @@
struct _EmpathyCameraMonitorPrivate
{
CheeseCameraDeviceMonitor *cheese_monitor;
- GQueue cameras;
+ GQueue *cameras;
gint num_cameras;
};
@@ -117,7 +117,10 @@ on_camera_added (CheeseCameraDeviceMonitor *device,
{
EmpathyCamera *camera = empathy_camera_new (id, filename, product_name);
- g_queue_push_tail (&self->priv->cameras, camera);
+ if (self->priv->cameras == NULL)
+ return;
+
+ g_queue_push_tail (self->priv->cameras, camera);
self->priv->num_cameras++;
@@ -135,13 +138,16 @@ on_camera_removed (CheeseCameraDeviceMonitor *device,
EmpathyCamera *camera;
GList *l;
- l = g_queue_find_custom (&self->priv->cameras, id, empathy_camera_find);
+ if (self->priv->cameras == NULL)
+ return;
+
+ l = g_queue_find_custom (self->priv->cameras, id, empathy_camera_find);
g_return_if_fail (l != NULL);
camera = l->data;
- g_queue_delete_link (&self->priv->cameras, l);
+ g_queue_delete_link (self->priv->cameras, l);
self->priv->num_cameras--;
@@ -156,7 +162,10 @@ on_camera_removed (CheeseCameraDeviceMonitor *device,
const GList *
empathy_camera_monitor_get_cameras (EmpathyCameraMonitor *self)
{
- return self->priv->cameras.head;
+ if (self->priv->cameras != NULL)
+ return self->priv->cameras->head;
+ else
+ return NULL;
}
static void
@@ -185,9 +194,9 @@ empathy_camera_monitor_dispose (GObject *object)
tp_clear_object (&self->priv->cheese_monitor);
- g_queue_foreach (&self->priv->cameras,
+ g_queue_foreach (self->priv->cameras,
empathy_camera_monitor_free_camera_foreach, NULL);
- g_queue_clear (&self->priv->cameras);
+ tp_clear_pointer (&self->priv->cameras, g_queue_free);
G_OBJECT_CLASS (empathy_camera_monitor_parent_class)->dispose (object);
}
@@ -264,7 +273,7 @@ empathy_camera_monitor_init (EmpathyCameraMonitor *self)
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
EMPATHY_TYPE_CAMERA_MONITOR, EmpathyCameraMonitorPrivate);
- g_queue_init (&self->priv->cameras);
+ self->priv->cameras = g_queue_new ();
self->priv->cheese_monitor = cheese_camera_device_monitor_new ();