[gnumeric] AutoFilter: fix blanks and non-blanks filters.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] AutoFilter: fix blanks and non-blanks filters.
- Date: Thu, 25 Sep 2014 17:53:26 +0000 (UTC)
commit fd744387ae377d03cb0191d90367dcb26e142d10
Author: Morten Welinder <terra gnome org>
Date: Thu Sep 25 13:55:38 2014 -0400
AutoFilter: fix blanks and non-blanks filters.
ChangeLog | 6 ++++++
src/sheet-filter.c | 24 +++++++++++++++++++++---
2 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d78cdcc..01e41b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-09-25 Morten Welinder <terra gnome org>
+
+ * src/sheet-filter.c (gnm_filter_condition_new_single)
+ (gnm_filter_condition_new_double): Fix preconditions. See
+ #735249.
+
2014-09-23 Morten Welinder <terra gnome org>
* src/libgnumeric.c (gnm_pre_parse_init): Mess with gobject so it
diff --git a/src/sheet-filter.c b/src/sheet-filter.c
index e77a7aa..3b56e70 100644
--- a/src/sheet-filter.c
+++ b/src/sheet-filter.c
@@ -44,6 +44,24 @@
#include <stdlib.h>
#include <string.h>
+static gboolean
+gnm_filter_op_needs_value (GnmFilterOp op)
+{
+ switch (op & GNM_FILTER_OP_TYPE_MASK) {
+ case GNM_FILTER_OP_TYPE_OP:
+ case GNM_FILTER_OP_TYPE_BUCKETS:
+ case GNM_FILTER_OP_TYPE_MATCH:
+ return TRUE;
+ default:
+ g_assert_not_reached ();
+ case GNM_FILTER_OP_TYPE_BLANKS:
+ case GNM_FILTER_OP_TYPE_AVERAGE:
+ case GNM_FILTER_OP_TYPE_STDDEV:
+ return FALSE;
+ }
+}
+
+
/**
* gnm_filter_condition_new_single :
* @op: #GnmFilterOp
@@ -57,7 +75,7 @@ gnm_filter_condition_new_single (GnmFilterOp op, GnmValue *v)
{
GnmFilterCondition *res;
- g_return_val_if_fail (v != NULL, NULL);
+ g_return_val_if_fail ((v != NULL) == gnm_filter_op_needs_value (op), NULL);
res = g_new0 (GnmFilterCondition, 1);
res->op[0] = op; res->op[1] = GNM_FILTER_UNUSED;
@@ -83,8 +101,8 @@ gnm_filter_condition_new_double (GnmFilterOp op0, GnmValue *v0,
{
GnmFilterCondition *res;
- g_return_val_if_fail (v0 != NULL, NULL);
- g_return_val_if_fail (v1 != NULL, NULL);
+ g_return_val_if_fail ((v0 != NULL) == gnm_filter_op_needs_value (op0), NULL);
+ g_return_val_if_fail ((v1 != NULL) == gnm_filter_op_needs_value (op1), NULL);
res = g_new0 (GnmFilterCondition, 1);
res->op[0] = op0; res->op[1] = op1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]