Commit 96abc9d4 authored by Morten Welinder's avatar Morten Welinder

Introspection: fix problems with boxed type.

GBoxedCopyFunc needs a result, do _ref functions must not be void.
parent 4ed548f7
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.
......
......@@ -10,6 +10,7 @@ Morten:
* Introspection fixes.
* Clean up workbook view construction.
* Test suite improvements.
* Fix problems with boxed types.
--------------------------------------------------------------------------
Gnumeric 1.12.39
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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
......
......@@ -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,
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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,
......
......@@ -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
......
......@@ -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,
......
......@@ -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
......
......@@ -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);
......
......@@ -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)
......
......@@ -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);
......
......@@ -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
......
......@@ -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
......
......@@ -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,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment