[grits] Pass objects to grits_viewer_remove instead of refs



commit ff72b493deceef82d583d50c478857ebf3bd0a17
Author: Andy Spencer <andy753421 gmail com>
Date:   Thu Oct 27 05:12:34 2011 +0000

    Pass objects to grits_viewer_remove instead of refs
    
    (finally)

 src/grits-opengl.c |    7 ++++---
 src/grits-viewer.c |    7 ++-----
 src/grits-viewer.h |    4 ++--
 src/plugins/elev.c |    2 +-
 src/plugins/map.c  |    2 +-
 src/plugins/sat.c  |    2 +-
 src/plugins/test.c |    2 +-
 7 files changed, 12 insertions(+), 14 deletions(-)
---
diff --git a/src/grits-opengl.c b/src/grits-opengl.c
index 5e2590b..774c757 100644
--- a/src/grits-opengl.c
+++ b/src/grits-opengl.c
@@ -483,18 +483,19 @@ static gpointer grits_opengl_add(GritsViewer *_opengl, GritsObject *object,
 	return link;
 }
 
-static GritsObject *grits_opengl_remove(GritsViewer *_opengl, gpointer _link)
+static GritsObject *grits_opengl_remove(GritsViewer *_opengl, GritsObject *object)
 {
 	g_assert(GRITS_IS_OPENGL(_opengl));
 	GritsOpenGL *opengl = GRITS_OPENGL(_opengl);
-	GList *link = _link;
+	GList *link = object->ref;
 	g_mutex_lock(opengl->objects_lock);
-	GritsObject *object = link->data;
 	/* Just unlink and free it, link->prev is assured */
 	link->prev->next = link->next;
 	if (link->next)
 		link->next->prev = link->prev;
 	g_mutex_unlock(opengl->objects_lock);
+	object->ref    = NULL;
+	object->viewer = NULL;
 	g_free(link);
 	g_object_unref(object);
 	return object;
diff --git a/src/grits-viewer.c b/src/grits-viewer.c
index 7d857c4..065e6fc 100644
--- a/src/grits-viewer.c
+++ b/src/grits-viewer.c
@@ -542,15 +542,12 @@ gpointer grits_viewer_add(GritsViewer *viewer, GritsObject *object,
  *
  * Returns: the #GritsObject referenced by the handle
  */
-GritsObject *grits_viewer_remove(GritsViewer *viewer, gpointer _object)
+GritsObject *grits_viewer_remove(GritsViewer *viewer, GritsObject *object)
 {
-	GritsObject *object = _object;
 	GritsViewerClass *klass = GRITS_VIEWER_GET_CLASS(viewer);
 	if (!klass->remove)
 		g_warning("GritsViewer: remove - Unimplemented");
-	klass->remove(viewer, object->ref);
-	object->ref    = NULL;
-	object->viewer = NULL;
+	klass->remove(viewer, object);
 	return object;
 }
 
diff --git a/src/grits-viewer.h b/src/grits-viewer.h
index ee1d613..3d493e3 100644
--- a/src/grits-viewer.h
+++ b/src/grits-viewer.h
@@ -133,7 +133,7 @@ struct _GritsViewerClass {
 
 	gpointer (*add)          (GritsViewer *viewer, GritsObject *object,
 	                          gint level, gboolean sort);
-	GritsObject *(*remove)   (GritsViewer *viewer, gpointer ref);
+	GritsObject *(*remove)   (GritsViewer *viewer, GritsObject *object);
 };
 
 GType grits_viewer_get_type(void);
@@ -173,6 +173,6 @@ void grits_viewer_set_height_func(GritsViewer *viewer, GritsBounds *bounds,
 
 gpointer grits_viewer_add(GritsViewer *viewer, GritsObject *object,
 		gint level, gboolean sort);
-GritsObject *grits_viewer_remove(GritsViewer *viewer, gpointer ref);
+GritsObject *grits_viewer_remove(GritsViewer *viewer, GritsObject *object);
 
 #endif
diff --git a/src/plugins/elev.c b/src/plugins/elev.c
index 6f03e69..2d49551 100644
--- a/src/plugins/elev.c
+++ b/src/plugins/elev.c
@@ -340,7 +340,7 @@ static void grits_plugin_elev_dispose(GObject *gobject)
 		if (LOAD_BIL)
 			grits_viewer_clear_height_func(elev->viewer);
 		if (LOAD_OPENGL)
-			grits_viewer_remove(elev->viewer, elev->tiles);
+			grits_viewer_remove(elev->viewer, GRITS_OBJECT(elev->tiles));
 		g_signal_handler_disconnect(elev->viewer, elev->sigid);
 		g_object_unref(elev->viewer);
 		elev->viewer = NULL;
diff --git a/src/plugins/map.c b/src/plugins/map.c
index 7505d45..9f89890 100644
--- a/src/plugins/map.c
+++ b/src/plugins/map.c
@@ -233,7 +233,7 @@ static void grits_plugin_map_dispose(GObject *gobject)
 	/* Drop references */
 	if (map->viewer) {
 		g_signal_handler_disconnect(map->viewer, map->sigid);
-		grits_viewer_remove(map->viewer, map->tiles);
+		grits_viewer_remove(map->viewer, GRITS_OBJECT(map->tiles));
 		soup_session_abort(map->wms->http->soup);
 		g_thread_pool_free(map->threads, TRUE, TRUE);
 		while (gtk_events_pending())
diff --git a/src/plugins/sat.c b/src/plugins/sat.c
index f19df1c..e67fe89 100644
--- a/src/plugins/sat.c
+++ b/src/plugins/sat.c
@@ -221,7 +221,7 @@ static void grits_plugin_sat_dispose(GObject *gobject)
 	/* Drop references */
 	if (sat->viewer) {
 		g_signal_handler_disconnect(sat->viewer, sat->sigid);
-		grits_viewer_remove(sat->viewer, sat->tiles);
+		grits_viewer_remove(sat->viewer, GRITS_OBJECT(sat->tiles));
 		soup_session_abort(sat->wms->http->soup);
 		g_thread_pool_free(sat->threads, TRUE, TRUE);
 		while (gtk_events_pending())
diff --git a/src/plugins/test.c b/src/plugins/test.c
index 2e4cbf8..44e39d0 100644
--- a/src/plugins/test.c
+++ b/src/plugins/test.c
@@ -175,7 +175,7 @@ static void grits_plugin_test_dispose(GObject *_test)
 	g_debug("GritsPluginTest: dispose");
 	GritsPluginTest *test = GRITS_PLUGIN_TEST(_test);
 	if (test->viewer) {
-		grits_viewer_remove(test->viewer, test->marker);
+		grits_viewer_remove(test->viewer, GRITS_OBJECT(test->marker));
 		g_object_unref(test->viewer);
 		test->viewer = NULL;
 	}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]