[libgda/gtk3] Corrected gda_holder_get_value() in case holder has been marked as invalid
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda/gtk3] Corrected gda_holder_get_value() in case holder has been marked as invalid
- Date: Sat, 27 Nov 2010 16:52:50 +0000 (UTC)
commit bbf7f1fd9c5b5558c1757f0fe743867a9bff2820
Author: Vivien Malerba <malerba gnome-db org>
Date: Thu Oct 28 15:44:15 2010 +0200
Corrected gda_holder_get_value() in case holder has been marked as invalid
in this case make sure the returned value is NULL and not
a value of type GDA_TYPE_NULL
libgda/gda-holder.c | 35 ++++++++++++++++++++---------------
tests/value-holders/check_holder.c | 2 +-
2 files changed, 21 insertions(+), 16 deletions(-)
---
diff --git a/libgda/gda-holder.c b/libgda/gda-holder.c
index 7d1eeb9..e594d06 100644
--- a/libgda/gda-holder.c
+++ b/libgda/gda-holder.c
@@ -721,6 +721,8 @@ gda_holder_get_id (GdaHolder *holder)
*
* If @holder is set to NULL, then the returned value is a #GDA_TYPE_NULL GValue.
*
+ * If @holder is invalid, then the returned value is %NULL.
+ *
* Returns: the value, or %NULL
*/
const GValue *
@@ -729,22 +731,26 @@ gda_holder_get_value (GdaHolder *holder)
g_return_val_if_fail (GDA_IS_HOLDER (holder), NULL);
g_return_val_if_fail (holder->priv, NULL);
- if (!holder->priv->full_bind) {
- /* return default value if possible */
- if (holder->priv->default_forced) {
- g_assert (holder->priv->default_value);
- if (G_VALUE_TYPE (holder->priv->default_value) == holder->priv->g_type)
- return holder->priv->default_value;
- else
- return NULL;
+ if (holder->priv->full_bind)
+ return gda_holder_get_value (holder->priv->full_bind);
+ else {
+ if (holder->priv->valid) {
+ /* return default value if possible */
+ if (holder->priv->default_forced) {
+ g_assert (holder->priv->default_value);
+ if (G_VALUE_TYPE (holder->priv->default_value) == holder->priv->g_type)
+ return holder->priv->default_value;
+ else
+ return NULL;
+ }
+
+ if (!holder->priv->value)
+ holder->priv->value = gda_value_new_null ();
+ return holder->priv->value;
}
-
- if (!holder->priv->value)
- holder->priv->value = gda_value_new_null ();
- return holder->priv->value;
+ else
+ return NULL;
}
- else
- return gda_holder_get_value (holder->priv->full_bind);
}
/**
@@ -1230,7 +1236,6 @@ gda_holder_force_invalid (GdaHolder *holder)
holder->priv->invalid_forced = TRUE;
holder->priv->valid = FALSE;
-
if (holder->priv->value) {
if (holder->priv->is_freeable)
gda_value_free (holder->priv->value);
diff --git a/tests/value-holders/check_holder.c b/tests/value-holders/check_holder.c
index efe6dad..d014131 100644
--- a/tests/value-holders/check_holder.c
+++ b/tests/value-holders/check_holder.c
@@ -227,7 +227,7 @@ test3 (GError **error)
return FALSE;
}
cvalue = gda_holder_get_value (h);
- if (!gda_value_is_null (cvalue)) {
+ if (cvalue) {
g_set_error (error, 0, 0, "%s",
"GdaHolder's value is incorrect");
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]