[libgda/LIBGDA_4.2] Added checks in GdaDataModelIter and improved doc.
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda/LIBGDA_4.2] Added checks in GdaDataModelIter and improved doc.
- Date: Sat, 9 Apr 2011 14:03:21 +0000 (UTC)
commit 2faebd2bb64ad465e0bf897925c5ffa3ab04063e
Author: Vivien Malerba <malerba gnome-db org>
Date: Sat Apr 9 15:51:24 2011 +0200
Added checks in GdaDataModelIter and improved doc.
doc/C/tmpl/gda-data-model-iter.sgml | 7 ++++---
libgda/gda-data-model-iter.c | 11 +++++++----
libgda/gda-data-model.c | 7 ++++---
3 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/doc/C/tmpl/gda-data-model-iter.sgml b/doc/C/tmpl/gda-data-model-iter.sgml
index 748c66b..9e47dde 100644
--- a/doc/C/tmpl/gda-data-model-iter.sgml
+++ b/doc/C/tmpl/gda-data-model-iter.sgml
@@ -46,6 +46,10 @@ Data model iterator
<phrase>GdaDataModelIter's usage</phrase>
</textobject>
</mediaobject>
+
+Note: the new #GdaDataModelIter does not hold any reference to the data model it iterates through (ie.
+if this data model is destroyed at some point, the new iterator will become useless but in
+any case it will not prevent the data model from being destroyed).
</para>
<!-- ##### SECTION See_Also ##### -->
@@ -70,8 +74,6 @@ Data model iterator
</para>
-@:
-
@gdadatamodeliter: the object which received the signal.
<!-- ##### SIGNAL GdaDataModelIter::row-changed ##### -->
@@ -79,7 +81,6 @@ Data model iterator
</para>
-@:
@:
@gdadatamodeliter: the object which received the signal.
diff --git a/libgda/gda-data-model-iter.c b/libgda/gda-data-model-iter.c
index bf01102..9c420bc 100644
--- a/libgda/gda-data-model-iter.c
+++ b/libgda/gda-data-model-iter.c
@@ -1,6 +1,5 @@
-/* gda-data-model-iter.c
- *
- * Copyright (C) 2005 - 2010 Vivien Malerba
+/*
+ * Copyright (C) 2005 - 2011 Vivien Malerba
*
* This Library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License as
@@ -84,7 +83,7 @@ enum
/* private structure */
struct _GdaDataModelIterPrivate
{
- GdaDataModel *data_model;
+ GdaDataModel *data_model; /* may be %NULL because there is only a weak ref on it */
gulong model_changes_signals[3];
gboolean keep_param_changes;
gint row; /* -1 if row is unknown */
@@ -621,6 +620,8 @@ gda_data_model_iter_move_to_row (GdaDataModelIter *iter, gint row)
gboolean move_ok;
model = iter->priv->data_model;
+ g_return_val_if_fail (iter->priv->data_model, FALSE);
+
if (GDA_DATA_MODEL_GET_CLASS (model)->i_iter_at_row)
move_ok = (GDA_DATA_MODEL_GET_CLASS (model)->i_iter_at_row) (model, iter, row);
else {
@@ -726,6 +727,7 @@ gda_data_model_iter_move_next (GdaDataModelIter *iter)
GdaDataModel *model;
g_return_val_if_fail (GDA_IS_DATA_MODEL_ITER (iter), FALSE);
g_return_val_if_fail (iter->priv, FALSE);
+ g_return_val_if_fail (iter->priv->data_model, FALSE);
if ((gda_data_model_iter_get_row (iter) >= 0) &&
! _gda_set_validate ((GdaSet*) iter, NULL))
@@ -814,6 +816,7 @@ gda_data_model_iter_move_prev (GdaDataModelIter *iter)
g_return_val_if_fail (GDA_IS_DATA_MODEL_ITER (iter), FALSE);
g_return_val_if_fail (iter->priv, FALSE);
+ g_return_val_if_fail (iter->priv->data_model, FALSE);
if ((gda_data_model_iter_get_row (iter) >= 0) &&
! _gda_set_validate ((GdaSet*) iter, NULL))
diff --git a/libgda/gda-data-model.c b/libgda/gda-data-model.c
index 4d499c9..779bbd3 100644
--- a/libgda/gda-data-model.c
+++ b/libgda/gda-data-model.c
@@ -1,6 +1,5 @@
/*
- * GDA common library
- * Copyright (C) 1998 - 2010 The GNOME Foundation.
+ * Copyright (C) 1998 - 2011 The GNOME Foundation.
*
* AUTHORS:
* Rodrigo Moya <rodrigo gnome-db org>
@@ -772,7 +771,9 @@ gda_data_model_set_values (GdaDataModel *model, gint row, GList *values, GError
* @model: a #GdaDataModel object.
*
* Creates a new iterator object #GdaDataModelIter object which can be used to iterate through
- * rows in @model.
+ * rows in @model. The new #GdaDataModelIter does not hold any reference to @model (ie. if @model
+ * is destroyed at some point, the new iterator will become useless but in any case it will not prevent
+ * the data model from being destroyed).
*
* Depending on the data model's implementation, a new #GdaDataModelIter object may be created,
* or a reference to an already existing #GdaDataModelIter may be returned.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]