[gnumeric] Introspection: fix problems with boxed type.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] Introspection: fix problems with boxed type.
- Date: Fri, 13 Apr 2018 16:56:57 +0000 (UTC)
commit 96abc9d4721c0a9a09d8f513b8d5ecf177ef7d58
Author: Morten Welinder <terra gnome org>
Date: Fri Apr 13 12:55:40 2018 -0400
Introspection: fix problems with boxed type.
GBoxedCopyFunc needs a result, do _ref functions must not be void.
ChangeLog | 17 +++++++++++++++++
NEWS | 1 +
plugins/fn-math/functions.c | 4 ++--
src/application.c | 10 +++++++++-
src/clipboard.c | 5 +++--
src/clipboard.h | 2 +-
src/colrow.c | 6 +++---
src/criteria.c | 6 +++---
src/criteria.h | 2 +-
src/expr-name.c | 6 +++---
src/expr-name.h | 2 +-
src/expr.c | 4 ++--
src/expr.h | 2 +-
src/parse-util.c | 4 ++--
src/style-font.h | 2 +-
src/style.c | 6 ++++--
src/validation.c | 3 ++-
src/validation.h | 2 +-
18 files changed, 57 insertions(+), 27 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 738c36f..021452d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
2018-04-13 Morten Welinder <terra gnome org>
+ * src/validation.c (gnm_validation_ref): Must return a value to be
+ used as a boxed copy function.
+
+ * src/expr.c (gnm_expr_top_ref): Must return a value to be used
+ as a boxed copy function.
+
+ * src/expr-name.c (expr_name_ref): Must return a value to be used
+ as a boxed copy function.
+
+ * src/mstyle.c (gnm_style_ref): Must return a value to be used
+ as a boxed copy function.
+
+ * src/clipboard.c (cellregion_ref): Must return a value to be used
+ as a boxed copy function.
+
+ * src/criteria.c (gnm_criteria_unref): Rename from free_criteria.
+
* src/mstyle.c: Hide internals.
src/gnm-style-impl.h: Remove.
diff --git a/NEWS b/NEWS
index 4c15577..66b9c44 100644
--- a/NEWS
+++ b/NEWS
@@ -10,6 +10,7 @@ Morten:
* Introspection fixes.
* Clean up workbook view construction.
* Test suite improvements.
+ * Fix problems with boxed types.
--------------------------------------------------------------------------
Gnumeric 1.12.39
diff --git a/plugins/fn-math/functions.c b/plugins/fn-math/functions.c
index 5c2cde3..3c5e220 100644
--- a/plugins/fn-math/functions.c
+++ b/plugins/fn-math/functions.c
@@ -62,7 +62,7 @@ oldstyle_if_func (GnmFuncEvalInfo *ei, GnmValue const * const *argv,
float_range_function_t fun, GnmStdError err,
CollectFlags flags)
{
- GPtrArray *crits = g_ptr_array_new_with_free_func ((GDestroyNotify)free_criteria);
+ GPtrArray *crits = g_ptr_array_new_with_free_func ((GDestroyNotify)gnm_criteria_unref);
GPtrArray *data = g_ptr_array_new ();
GODateConventions const *date_conv =
workbook_date_conv (ei->pos->sheet->workbook);
@@ -109,7 +109,7 @@ newstyle_if_func (GnmFuncEvalInfo *ei, int argc, GnmExprConstPtr const *argv,
float_range_function_t fun, GnmStdError err,
gboolean no_data)
{
- GPtrArray *crits = g_ptr_array_new_with_free_func ((GDestroyNotify)free_criteria);
+ GPtrArray *crits = g_ptr_array_new_with_free_func ((GDestroyNotify)gnm_criteria_unref);
GPtrArray *data = g_ptr_array_new_with_free_func ((GDestroyNotify)value_release);
GODateConventions const *date_conv =
workbook_date_conv (ei->pos->sheet->workbook);
diff --git a/src/application.c b/src/application.c
index ee6cb22..a912340 100644
--- a/src/application.c
+++ b/src/application.c
@@ -909,6 +909,14 @@ gnm_action_get_type (void)
static GnmAppExtraUI *
gnm_app_extra_ui_ref (GnmAppExtraUI *ui)
{
+ // Nothing
+ return ui;
+}
+
+static GnmAppExtraUI *
+gnm_app_extra_ui_unref (GnmAppExtraUI *ui)
+{
+ // Nothing
return ui;
}
@@ -920,7 +928,7 @@ gnm_app_extra_ui_get_type (void)
if (t == 0) {
t = g_boxed_type_register_static ("GnmAppExtraUI",
(GBoxedCopyFunc)gnm_app_extra_ui_ref,
- (GBoxedFreeFunc)gnm_app_extra_ui_ref);
+ (GBoxedFreeFunc)gnm_app_extra_ui_unref);
}
return t;
}
diff --git a/src/clipboard.c b/src/clipboard.c
index 5505d7d..0f04d35 100644
--- a/src/clipboard.c
+++ b/src/clipboard.c
@@ -883,11 +883,12 @@ gnm_cell_region_new (Sheet *origin_sheet)
return cr;
}
-void
+GnmCellRegion *
cellregion_ref (GnmCellRegion *cr)
{
- g_return_if_fail (cr != NULL);
+ g_return_val_if_fail (cr != NULL, NULL);
cr->ref_count++;
+ return cr;
}
void
diff --git a/src/clipboard.h b/src/clipboard.h
index 75b9ef6..8cd1158 100644
--- a/src/clipboard.h
+++ b/src/clipboard.h
@@ -99,7 +99,7 @@ GnmPasteTarget *paste_target_init (GnmPasteTarget *pt,
GType gnm_cell_region_get_type (void);
GnmCellRegion *gnm_cell_region_new (Sheet *origin_sheet);
-void cellregion_ref (GnmCellRegion *cr);
+GnmCellRegion *cellregion_ref (GnmCellRegion *cr);
void cellregion_unref (GnmCellRegion *cr);
GString *cellregion_to_string (GnmCellRegion const *cr,
gboolean only_visible,
diff --git a/src/colrow.c b/src/colrow.c
index 50ab5ea..0952168 100644
--- a/src/colrow.c
+++ b/src/colrow.c
@@ -40,7 +40,7 @@
* functions for copy and free, and crossing fingers.
*/
static ColRowInfo *
-col_row_info_copy (ColRowInfo *cri)
+col_row_info_fake_copy (ColRowInfo *cri)
{
return cri;
}
@@ -52,8 +52,8 @@ col_row_info_get_type (void)
if (t == 0) {
t = g_boxed_type_register_static ("ColRowInfo",
- (GBoxedCopyFunc)col_row_info_copy,
- (GBoxedFreeFunc)col_row_info_copy);
+ (GBoxedCopyFunc)col_row_info_fake_copy,
+ (GBoxedFreeFunc)col_row_info_fake_copy);
}
return t;
}
diff --git a/src/criteria.c b/src/criteria.c
index 002ae2d..3ecad1a 100644
--- a/src/criteria.c
+++ b/src/criteria.c
@@ -268,7 +268,7 @@ find_column_of_field (GnmEvalPos const *ep,
}
void
-free_criteria (GnmCriteria *criteria)
+gnm_criteria_unref (GnmCriteria *criteria)
{
if (!criteria || criteria->ref_count-- > 1)
return;
@@ -293,7 +293,7 @@ gnm_criteria_get_type (void)
if (t == 0) {
t = g_boxed_type_register_static ("GnmCriteria",
(GBoxedCopyFunc)gnm_criteria_ref,
- (GBoxedFreeFunc)free_criteria);
+ (GBoxedFreeFunc)gnm_criteria_unref);
}
return t;
}
@@ -312,7 +312,7 @@ free_criterias (GSList *criterias)
while (criterias != NULL) {
GnmDBCriteria *criteria = criterias->data;
g_slist_free_full (criteria->conditions,
- (GFreeFunc)free_criteria);
+ (GFreeFunc)gnm_criteria_unref);
g_free (criteria);
criterias = criterias->next;
}
diff --git a/src/criteria.h b/src/criteria.h
index 9589158..f6492e0 100644
--- a/src/criteria.h
+++ b/src/criteria.h
@@ -39,7 +39,7 @@ typedef struct {
GnmCriteria *parse_criteria (GnmValue const *crit_val,
GODateConventions const *date_conv,
gboolean anchor_end);
-void free_criteria (GnmCriteria *criteria);
+void gnm_criteria_unref (GnmCriteria *criteria);
void free_criterias (GSList *criterias);
GSList *find_rows_that_match (Sheet *sheet, int first_col,
int first_row, int last_col, int last_row,
diff --git a/src/expr-name.c b/src/expr-name.c
index b6fd080..593ed42 100644
--- a/src/expr-name.c
+++ b/src/expr-name.c
@@ -786,12 +786,12 @@ expr_name_add (GnmParsePos const *pp, char const *name,
return nexpr;
}
-void
+GnmNamedExpr *
expr_name_ref (GnmNamedExpr *nexpr)
{
- g_return_if_fail (nexpr != NULL);
-
+ g_return_val_if_fail (nexpr != NULL, NULL);
nexpr->ref_count++;
+ return nexpr;
}
void
diff --git a/src/expr-name.h b/src/expr-name.h
index 7bd2eab..ffb765f 100644
--- a/src/expr-name.h
+++ b/src/expr-name.h
@@ -34,7 +34,7 @@ void expr_name_perm_add (Sheet *sheet,
char const *name,
GnmExprTop const *texpr,
gboolean is_editable);
-void expr_name_ref (GnmNamedExpr *nexpr);
+GnmNamedExpr *expr_name_ref (GnmNamedExpr *nexpr);
void expr_name_unref (GnmNamedExpr *nexpr);
void expr_name_remove (GnmNamedExpr *nexpr);
GnmValue*expr_name_eval (GnmNamedExpr const *ne, GnmEvalPos const *ep,
diff --git a/src/expr.c b/src/expr.c
index 30d3ca1..8017bd5 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -2827,12 +2827,12 @@ gnm_expr_top_new_constant (GnmValue *v)
return gnm_expr_top_new (gnm_expr_new_constant (v));
}
-void
+GnmExprTop const *
gnm_expr_top_ref (GnmExprTop const *texpr)
{
g_return_if_fail (GNM_IS_EXPR_TOP (texpr));
-
((GnmExprTop *)texpr)->refcount++;
+ return texpr;
}
void
diff --git a/src/expr.h b/src/expr.h
index 2ec4ff9..aa90c75 100644
--- a/src/expr.h
+++ b/src/expr.h
@@ -153,7 +153,7 @@ GnmExprTop const *gnm_expr_top_new_array_corner (int cols, int rows, GnmExpr con
GnmExprTop const *gnm_expr_top_new_array_elem (int x, int y);
GType gnm_expr_top_get_type (void);
-void gnm_expr_top_ref (GnmExprTop const *texpr);
+GnmExprTop const *gnm_expr_top_ref (GnmExprTop const *texpr);
void gnm_expr_top_unref (GnmExprTop const *texpr);
gboolean gnm_expr_top_equal (GnmExprTop const *te1, GnmExprTop const *te2);
guint gnm_expr_top_hash (GnmExprTop const *texpr);
diff --git a/src/parse-util.c b/src/parse-util.c
index 6f118d0..8bd9469 100644
--- a/src/parse-util.c
+++ b/src/parse-util.c
@@ -1581,9 +1581,9 @@ gnm_conventions_unref (GnmConventions *c)
/**
* gnm_conventions_ref: (skip)
- * @c: (transfer none): #GnmConventions
+ * @c: (transfer none) (nullable): #GnmConventions
*
- * Returns: (transfer full): a new reference to @c
+ * Returns: (transfer full) (nullable): a new reference to @c
**/
GnmConventions *
gnm_conventions_ref (GnmConventions *c)
diff --git a/src/style-font.h b/src/style-font.h
index 8172432..f998f11 100644
--- a/src/style-font.h
+++ b/src/style-font.h
@@ -26,7 +26,7 @@ GType gnm_font_get_type (void);
GnmFont *gnm_font_new (PangoContext *context,
char const *font_name,
double size_pts, gboolean bold, gboolean italic);
-void gnm_font_ref (GnmFont *gfont);
+GnmFont *gnm_font_ref (GnmFont *gfont);
void gnm_font_unref (GnmFont *gfont);
guint gnm_font_hash (gconstpointer v);
gint gnm_font_equal (gconstpointer v, gconstpointer v2);
diff --git a/src/style.c b/src/style.c
index 255cbb8..47071bc 100644
--- a/src/style.c
+++ b/src/style.c
@@ -248,10 +248,10 @@ gnm_font_new (PangoContext *context,
abort ();
}
-void
+GnmFont *
gnm_font_ref (GnmFont *sf)
{
- g_return_if_fail (sf != NULL);
+ g_return_val_if_fail (sf != NULL, NULL);
sf->ref_count++;
#ifdef DEBUG_REF_COUNT
@@ -261,6 +261,8 @@ gnm_font_ref (GnmFont *sf)
sf->is_italic ? " italic" : "",
sf->ref_count);
#endif
+
+ return sf;
}
void
diff --git a/src/validation.c b/src/validation.c
index e3373f3..0ea4da7 100644
--- a/src/validation.c
+++ b/src/validation.c
@@ -360,11 +360,12 @@ gnm_validation_equal (GnmValidation const *a, GnmValidation const *b,
}
-void
+GnmValidation *
gnm_validation_ref (GnmValidation const *v)
{
g_return_if_fail (v != NULL);
((GnmValidation *)v)->ref_count++;
+ return ((GnmValidation *)v);
}
void
diff --git a/src/validation.h b/src/validation.h
index 4ca58f5..c57dff6 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -79,7 +79,7 @@ gboolean gnm_validation_equal (GnmValidation const *a,
GnmValidation const *b,
gboolean relax_sheet);
-void gnm_validation_ref (GnmValidation const *v);
+GnmValidation *gnm_validation_ref (GnmValidation const *v);
void gnm_validation_unref (GnmValidation const *v);
void gnm_validation_set_expr (GnmValidation *v,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]