[libchamplain] Check for existing factory in registered_sources
- From: Jiří Techet <jiritechet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libchamplain] Check for existing factory in registered_sources
- Date: Wed, 20 Apr 2016 12:06:32 +0000 (UTC)
commit 7cc3ec9d532cfc0d1c187a4c050c1f358cd638fd
Author: Nayan Deshmukh <nayan26deshmukh gmail com>
Date: Fri Apr 15 15:36:10 2016 +0530
Check for existing factory in registered_sources
check for existing factory with that name before appending
in registered_sources
https://bugzilla.gnome.org/show_bug.cgi?id=765032
champlain/champlain-map-source-factory.c | 21 ++++++++++++++++++---
1 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/champlain/champlain-map-source-factory.c b/champlain/champlain-map-source-factory.c
index 6f9a089..c86aa11 100644
--- a/champlain/champlain-map-source-factory.c
+++ b/champlain/champlain-map-source-factory.c
@@ -542,6 +542,18 @@ champlain_map_source_factory_create_error_source (ChamplainMapSourceFactory *fac
}
+static gint
+compare_id (ChamplainMapSourceDesc *a, ChamplainMapSourceDesc *b)
+{
+ const gchar *id_a, *id_b;
+
+ id_a = champlain_map_source_desc_get_id (a);
+ id_b = champlain_map_source_desc_get_id (b);
+
+ return g_strcmp0 (id_a, id_b);
+}
+
+
/**
* champlain_map_source_factory_register:
* @factory: A #ChamplainMapSourceFactory
@@ -560,9 +572,12 @@ gboolean
champlain_map_source_factory_register (ChamplainMapSourceFactory *factory,
ChamplainMapSourceDesc *desc)
{
- /* FIXME: check for existing factory with that name? */
- factory->priv->registered_sources = g_slist_append (factory->priv->registered_sources, desc);
- return TRUE;
+ if(!g_slist_find_custom (factory->priv->registered_sources, desc, (GCompareFunc) compare_id))
+ {
+ factory->priv->registered_sources = g_slist_append (factory->priv->registered_sources, desc);
+ return TRUE;
+ }
+ return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]