[libgda] GdaPstm: gda_pstmt_get_gda_statement returns a reference
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] GdaPstm: gda_pstmt_get_gda_statement returns a reference
- Date: Fri, 26 Oct 2018 00:00:38 +0000 (UTC)
commit 2c9957ab97e7b454cb096b0f80fd3f189e3ea9c8
Author: Daniel Espinosa <esodan gmail com>
Date: Thu Oct 25 18:50:42 2018 -0500
GdaPstm: gda_pstmt_get_gda_statement returns a reference
Because internaly GdaPstm have weak reference to a GdaStatement,
this method return a strong reference to be used while is used
to copy it.
libgda/gda-data-select.c | 5 ++++-
libgda/providers-support/gda-pstmt.c | 4 +---
libgda/sqlite/gda-sqlite-provider.c | 1 +
3 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/libgda/gda-data-select.c b/libgda/gda-data-select.c
index 0a8162c15..53f3dff4b 100644
--- a/libgda/gda-data-select.c
+++ b/libgda/gda-data-select.c
@@ -778,8 +778,10 @@ gda_data_select_set_property (GObject *object,
g_object_ref (model->prep_stmt);
sel_stmt = gda_pstmt_get_gda_statement (model->prep_stmt);
if (sel_stmt &&
- gda_statement_get_statement_type (sel_stmt) == GDA_SQL_STATEMENT_SELECT)
+ gda_statement_get_statement_type (sel_stmt) == GDA_SQL_STATEMENT_SELECT) {
model->priv->sh->sel_stmt = gda_statement_copy (sel_stmt);
+ g_object_unref (sel_stmt);
+ }
}
create_columns (model);
break;
@@ -1187,6 +1189,7 @@ check_acceptable_statement (GdaDataSelect *model, GError **error)
}
model->priv->sh->sel_stmt = gda_statement_copy (sel_stmt);
+ g_object_unref (sel_stmt);
return model->priv->sh->sel_stmt;
}
diff --git a/libgda/providers-support/gda-pstmt.c b/libgda/providers-support/gda-pstmt.c
index 2b7b23364..f6135da46 100644
--- a/libgda/providers-support/gda-pstmt.c
+++ b/libgda/providers-support/gda-pstmt.c
@@ -259,7 +259,7 @@ gda_pstmt_copy_contents (GdaPStmt *src, GdaPStmt *dest)
* Note: if that statement has been modified since the creation of @pstmt, then this method
* will return %NULL
*
- * Returns: (transfer none): the #GdaStatement
+ * Returns: (transfer full): the #GdaStatement
*/
GdaStatement *
gda_pstmt_get_gda_statement (GdaPStmt *pstmt)
@@ -268,8 +268,6 @@ gda_pstmt_get_gda_statement (GdaPStmt *pstmt)
g_rec_mutex_lock (& pstmt->priv->mutex);
GdaStatement *stmt;
stmt = g_weak_ref_get (& pstmt->priv->gda_stmt_ref);
- if (stmt)
- g_object_unref (stmt);
g_rec_mutex_unlock (& pstmt->priv->mutex);
return stmt;
}
diff --git a/libgda/sqlite/gda-sqlite-provider.c b/libgda/sqlite/gda-sqlite-provider.c
index ca774c475..4ccd55995 100644
--- a/libgda/sqlite/gda-sqlite-provider.c
+++ b/libgda/sqlite/gda-sqlite-provider.c
@@ -3226,6 +3226,7 @@ fill_blob_data (GdaConnection *cnc, GdaSet *params,
}
g_object_unref (select);
}
+ g_object_unref (stmt);
/* actual blob filling */
GSList *list;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]