[libgda] Fix memory leak regarding GdaDataHandler associated to connections
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Fix memory leak regarding GdaDataHandler associated to connections
- Date: Sun, 29 Sep 2013 16:41:07 +0000 (UTC)
commit e883061dd9e019130aef1a45f64f7bee57baed71
Author: Vivien Malerba <malerba gnome-db org>
Date: Sun Sep 29 18:34:36 2013 +0200
Fix memory leak regarding GdaDataHandler associated to connections
libgda/gda-connection.c | 2 ++
libgda/gda-server-provider-extra.c | 18 +++++++++++++++++-
libgda/gda-server-provider-extra.h | 1 +
3 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index 6c54969..70f124b 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -48,6 +48,7 @@
#include <glib/gi18n-lib.h>
#include <libgda/gda-log.h>
#include <libgda/gda-server-provider.h>
+#include <libgda/gda-server-provider-extra.h>
#include "gda-marshal.h"
#include <libgda/gda-transaction-status-private.h>
#include <string.h>
@@ -541,6 +542,7 @@ gda_connection_dispose (GObject *object)
}
if (cnc->priv->provider_obj) {
+ _gda_server_provider_handlers_clear_for_cnc (cnc->priv->provider_obj, cnc);
g_object_unref (G_OBJECT (cnc->priv->provider_obj));
cnc->priv->provider_obj = NULL;
}
diff --git a/libgda/gda-server-provider-extra.c b/libgda/gda-server-provider-extra.c
index 943e97a..bdfccd1 100644
--- a/libgda/gda-server-provider-extra.c
+++ b/libgda/gda-server-provider-extra.c
@@ -334,11 +334,27 @@ gda_server_provider_handler_declare (GdaServerProvider *prov, GdaDataHandler *dh
info->cnc = cnc;
info->g_type = g_type;
info->dbms_type = dbms_type ? g_strdup (dbms_type) : NULL;
-
+
g_hash_table_insert (prov->priv->data_handlers, info, dh);
g_object_ref (dh);
}
+static gboolean
+handlers_clear_for_cnc_fh (GdaServerProviderHandlerInfo *key, GdaDataHandler *value, GdaConnection *cnc)
+{
+ return (key->cnc == cnc) ? TRUE : FALSE;
+}
+
+/*
+ * Removes any #GdaServerProviderHandlerInfo associated to @cnc */
+void
+_gda_server_provider_handlers_clear_for_cnc (GdaServerProvider *prov, GdaConnection *cnc)
+{
+ g_return_if_fail (GDA_IS_SERVER_PROVIDER (prov));
+ g_return_if_fail (GDA_IS_CONNECTION (cnc));
+ g_hash_table_foreach_remove (prov->priv->data_handlers, (GHRFunc) handlers_clear_for_cnc_fh, cnc);
+}
+
/**
* gda_server_provider_find_file:
* @prov: a #GdaServerProvider
diff --git a/libgda/gda-server-provider-extra.h b/libgda/gda-server-provider-extra.h
index 4879f7e..e400b10 100644
--- a/libgda/gda-server-provider-extra.h
+++ b/libgda/gda-server-provider-extra.h
@@ -76,6 +76,7 @@ GdaDataHandler *gda_server_provider_handler_find (GdaServerProvider *
void gda_server_provider_handler_declare (GdaServerProvider *prov, GdaDataHandler *dh,
GdaConnection *cnc,
GType g_type, const gchar *dbms_type);
+void _gda_server_provider_handlers_clear_for_cnc (GdaServerProvider *prov, GdaConnection *cnc);
/*
* misc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]