[libgis] Add locking when modifying for viewer object lists
- From: Andy Spencer <andys src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgis] Add locking when modifying for viewer object lists
- Date: Fri, 10 Sep 2010 03:16:28 +0000 (UTC)
commit 5e97f4c0721a5481afbb2d005538e896ac8baf5a
Author: Andy Spencer <andy753421 gmail com>
Date: Mon Apr 19 06:28:18 2010 +0000
Add locking when modifying for viewer object lists
src/gis-opengl.c | 6 ++++++
src/gis-opengl.h | 1 +
2 files changed, 7 insertions(+), 0 deletions(-)
---
diff --git a/src/gis-opengl.c b/src/gis-opengl.c
index 57cfb47..9501781 100644
--- a/src/gis-opengl.c
+++ b/src/gis-opengl.c
@@ -611,6 +611,7 @@ static gpointer gis_opengl_add(GisViewer *_opengl, GisObject *object,
g_assert(GIS_IS_OPENGL(_opengl));
GisOpenGL *opengl = GIS_OPENGL(_opengl);
_load_object(opengl, object);
+ g_mutex_lock(opengl->objects_lock);
struct RenderLevel *level = g_tree_lookup(opengl->objects, (gpointer)key);
if (!level) {
level = g_new0(struct RenderLevel, 1);
@@ -623,6 +624,7 @@ static gpointer gis_opengl_add(GisViewer *_opengl, GisObject *object,
next->prev = list;
next->next = list->next;
list->next = next;
+ g_mutex_unlock(opengl->objects_lock);
return next;
}
@@ -633,12 +635,14 @@ static GisObject *gis_opengl_remove(GisViewer *_opengl, gpointer _link)
GList *link = _link;
GisObject *object = link->data;
_unload_object(opengl, object);
+ g_mutex_lock(opengl->objects_lock);
/* Just unlink and free it, link->prev is assured */
link->prev->next = link->next;
if (link->next)
link->next->prev = link->prev;
g_free(link);
g_object_unref(object);
+ g_mutex_unlock(opengl->objects_lock);
return object;
}
@@ -677,6 +681,7 @@ static void gis_opengl_init(GisOpenGL *opengl)
g_object_unref(glconfig);
opengl->objects = g_tree_new_full(_objects_cmp, NULL, NULL, _objects_free);
+ opengl->objects_lock = g_mutex_new();
opengl->sphere = roam_sphere_new(opengl);
opengl->sphere_lock = g_mutex_new();
@@ -719,6 +724,7 @@ static void gis_opengl_finalize(GObject *_opengl)
GisOpenGL *opengl = GIS_OPENGL(_opengl);
roam_sphere_free(opengl->sphere);
g_tree_destroy(opengl->objects);
+ g_mutex_free(opengl->objects_lock);
g_mutex_free(opengl->sphere_lock);
G_OBJECT_CLASS(gis_opengl_parent_class)->finalize(_opengl);
}
diff --git a/src/gis-opengl.h b/src/gis-opengl.h
index 80e866e..72d7b13 100644
--- a/src/gis-opengl.h
+++ b/src/gis-opengl.h
@@ -39,6 +39,7 @@ struct _GisOpenGL {
/* instance members */
GTree *objects;
+ GMutex *objects_lock;
RoamSphere *sphere;
GMutex *sphere_lock;
guint sm_source[2];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]