[libgda/LIBGDA_5.2] VConnection: fix free VContext free



commit 1c2c118144053a4a4e1ac8b6e0a9ebbe0b5861a6
Author: Daniel Espinosa <esodan gmail com>
Date:   Sun Sep 23 22:43:44 2018 -0500

    VConnection: fix free VContext free

 libgda/sqlite/virtual/gda-vconnection-data-model.c | 8 ++------
 libgda/sqlite/virtual/gda-vprovider-data-model.c   | 4 ++++
 2 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/libgda/sqlite/virtual/gda-vconnection-data-model.c 
b/libgda/sqlite/virtual/gda-vconnection-data-model.c
index 8fb3bc9ee..fd2eb1aac 100644
--- a/libgda/sqlite/virtual/gda-vconnection-data-model.c
+++ b/libgda/sqlite/virtual/gda-vconnection-data-model.c
@@ -612,13 +612,8 @@ vcontext_free (VContext *context)
                g_object_weak_unref (context->context_object,
                                     (GWeakNotify) vcontext_object_weak_notify_cb, context);
        if (context->context_data) {
-               guint i;
-               for (i = 0; i < context->context_data->len; i++) {
-                       VirtualFilteredData *data;
-                       data = g_array_index (context->context_data, VirtualFilteredData*, i);
-                       _gda_vconnection_virtual_filtered_data_unref (data);
-               }
                g_array_free (context->context_data, TRUE);
+               context->context_data = NULL;
        }
        g_free (context);
 #ifdef DEBUG_VCONTEXT
@@ -649,6 +644,7 @@ _gda_vconnection_set_working_obj (GdaVconnectionDataModel *cnc, GObject *obj)
                                vc->context_object = obj;
                                vc->context_data = g_array_new (FALSE, FALSE,
                                                                sizeof (VirtualFilteredData*));
+                               g_array_set_clear_func (vc->context_data, (GDestroyNotify) 
_gda_vconnection_virtual_filtered_data_unref);
                                vc->vtable = td;
                                g_object_weak_ref (obj, (GWeakNotify) vcontext_object_weak_notify_cb, vc);
                                g_hash_table_insert (td->context.hash, obj, vc);
diff --git a/libgda/sqlite/virtual/gda-vprovider-data-model.c 
b/libgda/sqlite/virtual/gda-vprovider-data-model.c
index 2598cc543..d6674de5c 100644
--- a/libgda/sqlite/virtual/gda-vprovider-data-model.c
+++ b/libgda/sqlite/virtual/gda-vprovider-data-model.c
@@ -249,6 +249,7 @@ virtual_filtered_data_new (VirtualTable *vtable, GdaDataModel *model,
 static void
 virtual_filtered_data_free (VirtualFilteredData *data)
 {
+       g_return_if_fail (data != NULL);
        if (data->argv) {
                int i;
                for (i = 0; i < data->argc; i++)
@@ -279,6 +280,7 @@ virtual_filtered_data_free (VirtualFilteredData *data)
 static VirtualFilteredData *
 virtual_filtered_data_ref (VirtualFilteredData *data)
 {
+       g_return_if_fail (data != NULL);
        data->refcount ++;
        return data;
 }
@@ -286,6 +288,7 @@ virtual_filtered_data_ref (VirtualFilteredData *data)
 void
 _gda_vconnection_virtual_filtered_data_unref (VirtualFilteredData *data)
 {
+       g_return_if_fail (data != NULL);
        data->refcount --;
        if (data->refcount == 0)
                virtual_filtered_data_free (data);
@@ -298,6 +301,7 @@ virtual_cursor_free (VirtualCursor *cursor)
                return;
 
        _gda_vconnection_virtual_filtered_data_unref (cursor->data);
+       cursor->data = NULL;
        g_free (cursor);
 }
 


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