[libgda] Added checks in GdaDataModelIter and improved doc.
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Added checks in GdaDataModelIter and improved doc.
- Date: Sat, 9 Apr 2011 13:22:56 +0000 (UTC)
commit 1e85e358b1ff4625056aad82b3cde864e4b55d39
Author: Vivien Malerba <malerba gnome-db org>
Date: Sat Apr 9 15:05:39 2011 +0200
Added checks in GdaDataModelIter and improved doc.
libgda/gda-data-model-iter.c | 11 +++++++----
libgda/gda-data-model-iter.h | 4 ++++
libgda/gda-data-model.c | 7 ++++---
3 files changed, 15 insertions(+), 7 deletions(-)
---
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-iter.h b/libgda/gda-data-model-iter.h
index dfae94d..a12ec98 100644
--- a/libgda/gda-data-model-iter.h
+++ b/libgda/gda-data-model-iter.h
@@ -107,6 +107,10 @@ struct _GdaDataModelIterClass
* <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).
*/
GType gda_data_model_iter_get_type (void) G_GNUC_CONST;
diff --git a/libgda/gda-data-model.c b/libgda/gda-data-model.c
index 976013b..a4a8731 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]