[dia] use ref/unref directly instead of wrappers
- From: Zander <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] use ref/unref directly instead of wrappers
- Date: Sat, 21 Sep 2019 11:09:23 +0000 (UTC)
commit 4c20ff9005131fdc1ff86b45345874a5be5df349
Author: Zander Brown <zbrown gnome org>
Date: Sat Sep 21 12:06:50 2019 +0100
use ref/unref directly instead of wrappers
app/layer_dialog.c | 30 ++---
app/load_save.c | 2 +-
lib/attributes.c | 44 +++----
lib/dia-layer.h | 1 -
lib/dia_svg.c | 10 +-
lib/diagramdata.c | 4 +-
lib/font.c | 15 +--
lib/font.h | 5 +-
lib/layer.c | 11 --
lib/libdia.def | 54 +++++----
lib/prop_attr.c | 49 ++++----
lib/prop_text.c | 9 +-
lib/renderer/diacairo-renderer.c | 7 +-
lib/text.c | 51 ++++----
lib/textline.c | 46 ++++---
objects/AADL/aadlbox.c | 204 ++++++++++++++++----------------
objects/Database/table.c | 44 ++++---
objects/ER/attribute.c | 4 +-
objects/ER/entity.c | 12 +-
objects/ER/relationship.c | 14 +--
objects/FS/flow-ortho.c | 8 +-
objects/FS/flow.c | 8 +-
objects/FS/function.c | 14 +--
objects/GRAFCET/action.c | 8 +-
objects/GRAFCET/boolequation.c | 16 +--
objects/GRAFCET/condition.c | 24 ++--
objects/GRAFCET/step.c | 8 +-
objects/GRAFCET/transition.c | 25 ++--
objects/Istar/actor.c | 6 +-
objects/Istar/goal.c | 10 +-
objects/Istar/other.c | 2 +-
objects/Jackson/domain.c | 14 +--
objects/Jackson/requirement.c | 6 +-
objects/KAOS/goal.c | 10 +-
objects/KAOS/other.c | 2 +-
objects/SADT/annotation.c | 2 +-
objects/SADT/box.c | 2 +-
objects/UML/activity.c | 2 +-
objects/UML/actor.c | 6 +-
objects/UML/association.c | 2 +-
objects/UML/class.c | 16 +--
objects/UML/classicon.c | 2 +-
objects/UML/component.c | 6 +-
objects/UML/component_feature.c | 10 +-
objects/UML/constraint.c | 10 +-
objects/UML/dependency.c | 12 +-
objects/UML/generalization.c | 12 +-
objects/UML/implements.c | 8 +-
objects/UML/large_package.c | 12 +-
objects/UML/node.c | 4 +-
objects/UML/note.c | 4 +-
objects/UML/object.c | 4 +-
objects/UML/realizes.c | 12 +-
objects/UML/small_package.c | 6 +-
objects/UML/state.c | 2 +-
objects/UML/usecase.c | 2 +-
objects/chronogram/chronoline.c | 14 +--
objects/chronogram/chronoref.c | 6 +-
objects/custom/custom_object.c | 2 +-
objects/custom/shape_info.c | 12 +-
objects/flowchart/box.c | 6 +-
objects/flowchart/diamond.c | 6 +-
objects/flowchart/ellipse.c | 6 +-
objects/flowchart/parallelogram.c | 6 +-
objects/network/basestation.c | 2 +-
objects/network/radiocell.c | 6 +-
objects/standard/textobj.c | 8 +-
plug-ins/cgm/cgm.c | 12 +-
plug-ins/drs/dia-render-script-import.c | 2 +-
plug-ins/pdf/pdf-import.cpp | 36 +++---
plug-ins/postscript/diapsrenderer.c | 11 +-
plug-ins/python/pydia-diagramdata.c | 2 +-
plug-ins/python/pydia-font.c | 21 ++--
plug-ins/python/pydia-layer.c | 5 +-
plug-ins/svg/svg-import.c | 29 ++---
plug-ins/wpg/wpg-import.c | 2 +-
76 files changed, 536 insertions(+), 571 deletions(-)
---
diff --git a/app/layer_dialog.c b/app/layer_dialog.c
index 5155e0b2..a105f9d2 100644
--- a/app/layer_dialog.c
+++ b/app/layer_dialog.c
@@ -1357,23 +1357,23 @@ layer_change_revert(struct LayerChange *change, Diagram *dia)
}
static void
-layer_change_free(struct LayerChange *change)
+layer_change_free (struct LayerChange *change)
{
switch (change->type) {
- case TYPE_DELETE_LAYER:
- if (change->applied) {
- dia_layer_destroy (change->layer);
- }
- break;
- case TYPE_ADD_LAYER:
- if (!change->applied) {
- dia_layer_destroy (change->layer);
- }
- break;
- case TYPE_RAISE_LAYER:
- break;
- case TYPE_LOWER_LAYER:
- break;
+ case TYPE_DELETE_LAYER:
+ if (change->applied) {
+ g_clear_object (&change->layer);
+ }
+ break;
+ case TYPE_ADD_LAYER:
+ if (!change->applied) {
+ g_clear_object (&change->layer);
+ }
+ break;
+ case TYPE_RAISE_LAYER:
+ break;
+ case TYPE_LOWER_LAYER:
+ break;
}
}
diff --git a/app/load_save.c b/app/load_save.c
index f7c4c4f5..a5d7a29c 100644
--- a/app/load_save.c
+++ b/app/load_save.c
@@ -442,7 +442,7 @@ diagram_data_load(const gchar *filename, DiagramData *data, DiaContext *ctx, voi
/* Destroy the default layer: */
if (dia_layer_object_count (data->active_layer) == 0) {
g_ptr_array_remove (data->layers, data->active_layer);
- dia_layer_destroy (data->active_layer);
+ g_clear_object (&data->active_layer);
}
diagramdata =
diff --git a/lib/attributes.c b/lib/attributes.c
index 7a44ae32..f697e350 100644
--- a/lib/attributes.c
+++ b/lib/attributes.c
@@ -26,10 +26,10 @@ static Color attributes_background = { 1.0f, 1.0f, 1.0f, 1.0f };
static real attributes_default_linewidth = 0.1;
-static Arrow attributes_start_arrow = { ARROW_NONE,
- DEFAULT_ARROW_SIZE,
+static Arrow attributes_start_arrow = { ARROW_NONE,
+ DEFAULT_ARROW_SIZE,
DEFAULT_ARROW_SIZE };
-static Arrow attributes_end_arrow = { ARROW_NONE,
+static Arrow attributes_end_arrow = { ARROW_NONE,
DEFAULT_ARROW_SIZE,
DEFAULT_ARROW_SIZE };
@@ -42,7 +42,7 @@ static real attributes_font_height = 0.8;
/** Get the foreground color attribute (lines and text)
* @returns The current foreground color as set in the toolbox.
*/
-Color
+Color
attributes_get_foreground(void)
{
return attributes_foreground;
@@ -51,7 +51,7 @@ attributes_get_foreground(void)
/** Get the background color attribute (for box background and such)
* @returns The current background color as set in the toolbox.
*/
-Color
+Color
attributes_get_background(void)
{
return attributes_background;
@@ -135,7 +135,7 @@ void
attributes_set_default_start_arrow(Arrow arrow)
{
attributes_start_arrow = arrow;
- persistence_set_string("start-arrow-type",
+ persistence_set_string("start-arrow-type",
arrow_get_name_from_type(arrow.type));
persistence_set_real("start-arrow-width", arrow.width);
persistence_set_real("start-arrow-length", arrow.length);
@@ -157,7 +157,7 @@ void
attributes_set_default_end_arrow(Arrow arrow)
{
attributes_end_arrow = arrow;
- persistence_set_string("end-arrow-type",
+ persistence_set_string("end-arrow-type",
arrow_get_name_from_type(arrow.type));
persistence_set_real("end-arrow-width", arrow.width);
persistence_set_real("end-arrow-length", arrow.length);
@@ -165,7 +165,7 @@ attributes_set_default_end_arrow(Arrow arrow)
/** Get the default line style (dashes, dots etc)
* @param style A place to return the style (number of dots and dashes)
- * @param dash_length A place to return how long a dash is
+ * @param dash_length A place to return how long a dash is
* (0.0 < dash_length < ???)
* @see dia-enums.h for possible values for style.
*/
@@ -198,16 +198,18 @@ attributes_set_default_line_style(LineStyle style, real dash_length)
* @param font_height A place to return the default font height set by the user
*/
void
-attributes_get_default_font(DiaFont **font, real *font_height)
+attributes_get_default_font (DiaFont **font, real *font_height)
{
- if (!attributes_font) {
- attributes_font = dia_font_new_from_style(DIA_FONT_SANS,
- attributes_font_height);
- }
- if (font)
- *font = dia_font_ref(attributes_font);
- if (font_height)
- *font_height = attributes_font_height;
+ if (!attributes_font) {
+ attributes_font = dia_font_new_from_style (DIA_FONT_SANS,
+ attributes_font_height);
+ }
+
+ if (font)
+ *font = g_object_ref (attributes_font);
+
+ if (font_height)
+ *font_height = attributes_font_height;
}
/** Set the default font.
@@ -217,10 +219,10 @@ attributes_get_default_font(DiaFont **font, real *font_height)
* @param font_height The font height to set as the new default.
*/
void
-attributes_set_default_font(DiaFont *font, real font_height)
+attributes_set_default_font (DiaFont *font, real font_height)
{
- if (attributes_font != NULL)
- dia_font_unref(attributes_font);
- attributes_font = dia_font_ref(font);
+ g_clear_object (&attributes_font);
+
+ attributes_font = g_object_ref (font);
attributes_font_height = font_height;
}
diff --git a/lib/dia-layer.h b/lib/dia-layer.h
index 9da5667d..f5bd8833 100644
--- a/lib/dia-layer.h
+++ b/lib/dia-layer.h
@@ -39,7 +39,6 @@ struct _DiaLayerClass
DiaLayer *dia_layer_new (const char *name,
DiagramData *parent);
DiaLayer *dia_layer_new_from_layer (DiaLayer *old);
-void dia_layer_destroy (DiaLayer *layer);
void dia_layer_render (DiaLayer *layer,
DiaRenderer *renderer,
Rectangle *update,
diff --git a/lib/dia_svg.c b/lib/dia_svg.c
index 82347f71..90412357 100644
--- a/lib/dia_svg.c
+++ b/lib/dia_svg.c
@@ -71,7 +71,7 @@ dia_svg_style_init(DiaSvgStyle *gs, DiaSvgStyle *parent_style)
gs->linecap = parent_style ? parent_style->linecap : LINECAPS_DEFAULT;
gs->linejoin = parent_style ? parent_style->linejoin : LINEJOIN_DEFAULT;
gs->linestyle = parent_style ? parent_style->linestyle : LINESTYLE_DEFAULT;
- gs->font = (parent_style && parent_style->font) ? dia_font_ref(parent_style->font) : NULL;
+ gs->font = (parent_style && parent_style->font) ? g_object_ref (parent_style->font) : NULL;
gs->font_height = parent_style ? parent_style->font_height : 0.8;
gs->alignment = parent_style ? parent_style->alignment : ALIGN_LEFT;
@@ -97,9 +97,8 @@ dia_svg_style_copy(DiaSvgStyle *dest, DiaSvgStyle *src)
dest->dashlength = src->dashlength;
dest->fill = src->fill;
dest->fill_opacity = src->fill_opacity;
- if (dest->font)
- dia_font_unref (dest->font);
- dest->font = src->font ? dia_font_ref(src->font) : NULL;
+ g_clear_object (&dest->font);
+ dest->font = src->font ? g_object_ref (src->font) : NULL;
dest->font_height = src->font_height;
dest->alignment = src->alignment;
dest->stop_color = src->stop_color;
@@ -506,8 +505,7 @@ _parse_linecap (DiaSvgStyle *s, const char *val)
static void
_style_adjust_font (DiaSvgStyle *s, const char *family, const char *style, const char *weight)
{
- if (s->font)
- dia_font_unref (s->font);
+ g_clear_object (&s->font);
/* given font_height is bogus, especially if not given at all
* or without unit ... see bug 665648 about invalid CSS
*/
diff --git a/lib/diagramdata.c b/lib/diagramdata.c
index d8425e23..1eac2520 100644
--- a/lib/diagramdata.c
+++ b/lib/diagramdata.c
@@ -155,7 +155,7 @@ diagram_data_finalize (GObject *object)
g_free (data->paper.name);
for (i=0;i<data->layers->len;i++) {
- dia_layer_destroy (g_ptr_array_index (data->layers, i));
+ g_object_unref (g_ptr_array_index (data->layers, i));
}
g_ptr_array_free (data->layers, TRUE);
data->active_layer = NULL;
@@ -192,7 +192,7 @@ diagram_data_clone (DiagramData *data)
clone->paper.name = g_strdup (data->paper.name);
clone->is_compressed = data->is_compressed;
- dia_layer_destroy (g_ptr_array_index (clone->layers, 0));
+ g_object_unref (g_ptr_array_index (clone->layers, 0));
g_ptr_array_remove (clone->layers, clone->active_layer);
for (i=0; i < data->layers->len; ++i) {
diff --git a/lib/font.c b/lib/font.c
index 9c7b76f7..ff93048c 100644
--- a/lib/font.c
+++ b/lib/font.c
@@ -85,7 +85,7 @@ dia_font_check_for_font(int font)
} else {
g_object_unref(loaded);
}
- dia_font_unref(check);
+ g_clear_object (&check);
}
void
@@ -376,19 +376,6 @@ dia_font_finalize(GObject* object)
G_OBJECT_CLASS(parent_class)->finalize(object);
}
-DiaFont *
-dia_font_ref(DiaFont* font)
-{
- g_object_ref(G_OBJECT(font));
- return font;
-}
-
-void
-dia_font_unref(DiaFont* font)
-{
- g_object_unref(G_OBJECT(font));
-}
-
DiaFontStyle
dia_font_get_style(const DiaFont* font)
{
diff --git a/lib/font.h b/lib/font.h
index ee9c8c7a..2000629d 100644
--- a/lib/font.h
+++ b/lib/font.h
@@ -124,7 +124,7 @@ PangoContext *dia_font_get_context(void);
/*!
* \brief Font creation for object implementation
* \ingroup ObjectFonts
- * Get a font matching family,style,height. MUST be freed with dia_font_unref().
+ * Get a font matching family,style,height.
*/
DiaFont* dia_font_new(const char *family, DiaFontStyle style,
real height);
@@ -155,9 +155,6 @@ const char* dia_font_get_legacy_name(const DiaFont* font);
/* Same attributes */
DiaFont *dia_font_copy(const DiaFont* font);
-DiaFont* dia_font_ref(DiaFont* font);
-void dia_font_unref(DiaFont* font);
-
/* Retrieves the style of the font */
DiaFontStyle dia_font_get_style(const DiaFont* font);
diff --git a/lib/layer.c b/lib/layer.c
index 32ff5514..34a72dde 100644
--- a/lib/layer.c
+++ b/lib/layer.c
@@ -375,17 +375,6 @@ dia_layer_new_from_layer (DiaLayer *old)
return layer;
}
-/**
- * dia_layer_destroy;
- * @layer: The layer object to deallocate entirely.
- *
- * Destroy a layer object.
- */
-void
-dia_layer_destroy (DiaLayer *layer)
-{
- g_object_unref (layer);
-}
/*!
* \brief Set the parent layer of an object.
diff --git a/lib/libdia.def b/lib/libdia.def
index 2ccd1250..4a9b9a3b 100644
--- a/lib/libdia.def
+++ b/lib/libdia.def
@@ -250,7 +250,6 @@ EXPORTS
dia_font_new
dia_font_new_from_legacy_name
dia_font_new_from_style
- dia_font_ref
dia_font_set_any_family
dia_font_set_height
dia_font_set_slant
@@ -260,7 +259,6 @@ EXPORTS
dia_font_copy
dia_font_string_width
- dia_font_unref
dia_font_selector_get_font
dia_font_selector_get_type
dia_font_selector_new
@@ -403,7 +401,7 @@ EXPORTS
dia_renderer_begin_render
dia_renderer_end_render
dia_renderer_is_capable_of
-
+
dia_interactive_renderer_get_type
dia_interactive_renderer_draw_pixel_line
dia_interactive_renderer_get_width_pixels
@@ -541,29 +539,33 @@ EXPORTS
intl_score_locale
- layer_add_object
- layer_add_object_at
- layer_add_objects
- layer_add_objects_first
- layer_destroy
- layer_find_closest_connectionpoint
- layer_find_closest_object
- layer_find_closest_object_except
- layer_find_objects_containing_rectangle
- layer_find_objects_in_rectangle
- layer_find_objects_intersecting_rectangle
- layer_get_parent_diagram
- layer_get_name
- layer_object_count
- layer_object_get_index
- layer_object_get_nth
- layer_remove_object
- layer_remove_objects
- layer_render
- layer_replace_object_with_list
- layer_set_object_list
- layer_update_extents
- new_layer
+ dia_layer_add_object
+ dia_layer_add_object_at
+ dia_layer_add_objects
+ dia_layer_add_objects_first
+ dia_layer_find_closest_connectionpoint
+ dia_layer_find_closest_object
+ dia_layer_find_closest_object_except
+ dia_layer_find_objects_containing_rectangle
+ dia_layer_find_objects_in_rectangle
+ dia_layer_find_objects_intersecting_rectangle
+ dia_layer_get_parent_diagram
+ dia_layer_get_name
+ dia_layer_object_count
+ dia_layer_object_get_index
+ dia_layer_object_get_nth
+ dia_layer_remove_object
+ dia_layer_remove_objects
+ dia_layer_render
+ dia_layer_replace_object_with_list
+ dia_layer_set_object_list
+ dia_layer_update_extents
+ dia_layer_new
+ dia_layer_new_from_layer
+ dia_layer_is_visible
+ dia_layer_set_visible
+ dia_layer_is_connectable
+ dia_layer_set_connectable
line_bbox
line_line_intersection
diff --git a/lib/prop_attr.c b/lib/prop_attr.c
index d9a4e60d..eae41adf 100644
--- a/lib/prop_attr.c
+++ b/lib/prop_attr.c
@@ -378,24 +378,22 @@ fontprop_new(const PropDescription *pdesc, PropDescToPropPredicate reason)
}
static void
-fontprop_free(FontProperty *prop)
+fontprop_free (FontProperty *prop)
{
- if (prop->font_data)
- dia_font_unref(prop->font_data);
- g_free(prop);
+ g_clear_object (&prop->font_data);
+ g_free (prop);
}
static FontProperty *
fontprop_copy(FontProperty *src)
{
FontProperty *prop =
- (FontProperty *)src->common.ops->new_prop(src->common.descr,
- src->common.reason);
- copy_init_property(&prop->common,&src->common);
+ (FontProperty *) src->common.ops->new_prop (src->common.descr,
+ src->common.reason);
+ copy_init_property (&prop->common, &src->common);
- if (prop->font_data)
- dia_font_unref(prop->font_data);
- prop->font_data = dia_font_ref(src->font_data);
+ g_clear_object (&prop->font_data);
+ prop->font_data = g_object_ref (src->font_data);
return prop;
}
@@ -424,8 +422,7 @@ fontprop_set_from_widget(FontProperty *prop, WIDGET *widget)
static void
fontprop_load(FontProperty *prop, AttributeNode attr, DataNode data, DiaContext *ctx)
{
- if (prop->font_data)
- dia_font_unref(prop->font_data);
+ g_clear_object (&prop->font_data);
prop->font_data = data_font(data, ctx);
}
@@ -442,36 +439,36 @@ fontprop_get_from_offset(FontProperty *prop,
/* if we get the same font dont unref before reuse */
DiaFont *old_font = prop->font_data;
if (offset2 == 0) {
- prop->font_data = dia_font_ref(struct_member(base,offset,DiaFont *));
+ prop->font_data = g_object_ref (struct_member (base, offset, DiaFont *));
} else {
void *base2 = struct_member(base,offset,void*);
g_return_if_fail (base2 != NULL);
- prop->font_data = dia_font_ref(struct_member(base2,offset2,DiaFont *));
+ prop->font_data = g_object_ref (struct_member (base2, offset2, DiaFont *));
}
- if (old_font)
- dia_font_unref(old_font);
+ g_clear_object (&old_font);
}
static void
-fontprop_set_from_offset(FontProperty *prop,
- void *base, guint offset, guint offset2)
+fontprop_set_from_offset (FontProperty *prop,
+ void *base,
+ guint offset,
+ guint offset2)
{
if (prop->font_data) {
DiaFont *old_font;
if (offset2 == 0) {
- old_font = struct_member(base,offset,DiaFont *);
- struct_member(base,offset,DiaFont *) = dia_font_ref(prop->font_data);
+ old_font = struct_member (base, offset, DiaFont *);
+ struct_member (base, offset, DiaFont *) = g_object_ref (prop->font_data);
} else {
- void *base2 = struct_member(base,offset,void*);
+ void *base2 = struct_member (base, offset, void*);
g_return_if_fail (base2 != NULL);
- old_font = struct_member(base2,offset2,DiaFont *);
- struct_member(base2,offset2,DiaFont *) = dia_font_ref(prop->font_data);
+ old_font = struct_member (base2, offset2, DiaFont *);
+ struct_member (base2, offset2, DiaFont *) = g_object_ref (prop->font_data);
g_return_if_fail (offset2 == offsetof(Text, font));
- text_set_font ((Text *)base2, prop->font_data);
+ text_set_font ((Text *) base2, prop->font_data);
}
- if (old_font)
- dia_font_unref(old_font);
+ g_clear_object (&old_font);
}
}
diff --git a/lib/prop_text.c b/lib/prop_text.c
index 5dad072b..358db12e 100644
--- a/lib/prop_text.c
+++ b/lib/prop_text.c
@@ -385,12 +385,11 @@ textprop_copy(TextProperty *src)
}
static void
-textprop_free(TextProperty *prop)
+textprop_free (TextProperty *prop)
{
- if (prop->attr.font)
- dia_font_unref(prop->attr.font);
- g_free(prop->text_data);
- g_free(prop);
+ g_clear_object (&prop->attr.font);
+ g_free (prop->text_data);
+ g_free (prop);
}
static void
diff --git a/lib/renderer/diacairo-renderer.c b/lib/renderer/diacairo-renderer.c
index 43deeed7..37e49ce3 100644
--- a/lib/renderer/diacairo-renderer.c
+++ b/lib/renderer/diacairo-renderer.c
@@ -569,10 +569,9 @@ dia_cairo_renderer_set_font (DiaRenderer *self, DiaFont *font, real height)
pango_layout_set_font_description (renderer->layout, pfd);
pango_font_description_free (pfd);
- dia_font_ref (font);
- if (renderer->font) {
- dia_font_unref (renderer->font);
- }
+ g_object_ref (font);
+ g_clear_object (&renderer->font);
+
renderer->font = font;
renderer->font_height = height;
}
diff --git a/lib/text.c b/lib/text.c
index e455cd1c..6f75d3c3 100644
--- a/lib/text.c
+++ b/lib/text.c
@@ -291,14 +291,18 @@ text_set_string(Text *text, const char *string)
}
Text *
-new_text(const char *string, DiaFont *font, real height,
- Point *pos, Color *color, Alignment align)
+new_text (const char *string,
+ DiaFont *font,
+ real height,
+ Point *pos,
+ Color *color,
+ Alignment align)
{
Text *text;
text = g_new(Text, 1);
- text->font = dia_font_ref(font);
+ text->font = g_object_ref (font);
text->height = height;
text->position = *pos;
@@ -313,9 +317,9 @@ new_text(const char *string, DiaFont *font, real height,
text->focus.key_event = text_key_event;
text->focus.text = text;
- set_string(text, string);
+ set_string (text, string);
- calc_ascent_descent(text);
+ calc_ascent_descent (text);
return text;
}
@@ -324,15 +328,16 @@ new_text(const char *string, DiaFont *font, real height,
* Fallback function returning a default initialized text object.
*/
Text *
-new_text_default(Point *pos, Color *color, Alignment align)
+new_text_default (Point *pos, Color *color, Alignment align)
{
Text *text;
DiaFont *font;
real font_height;
- attributes_get_default_font(&font, &font_height);
- text = new_text("", font, font_height, pos, color, align);
- dia_font_unref(font);
+ attributes_get_default_font (&font, &font_height);
+ text = new_text ("", font, font_height, pos, color, align);
+ g_clear_object (&font);
+
return text;
}
@@ -374,11 +379,11 @@ text_copy(Text *text)
}
void
-text_destroy(Text *text)
+text_destroy (Text *text)
{
- free_string(text);
- dia_font_unref(text->font);
- g_free(text);
+ free_string (text);
+ g_clear_object (&text->font);
+ g_free (text);
}
void
@@ -400,20 +405,20 @@ text_get_height(const Text *text)
}
void
-text_set_font(Text *text, DiaFont *font)
+text_set_font (Text *text, DiaFont *font)
{
DiaFont *old_font = text->font;
int i;
- text->font = dia_font_ref(font);
- dia_font_unref(old_font);
+ text->font = g_object_ref (font);
+ g_clear_object (&old_font);
for (i = 0; i < text->numlines; i++) {
- text_line_set_font(text->lines[i], font);
+ text_line_set_font (text->lines[i], font);
}
- calc_width(text);
- calc_ascent_descent(text);
+ calc_width (text);
+ calc_ascent_descent (text);
}
void
@@ -1142,8 +1147,8 @@ data_text(AttributeNode text_attr, DiaContext *ctx)
if (attr != NULL)
align = data_enum(attribute_first_data(attr), ctx);
- text = new_text(string ? string : "", font, height, &pos, &col, align);
- if (font) dia_font_unref(font);
+ text = new_text (string ? string : "", font, height, &pos, &col, align);
+ g_clear_object (&font);
if (string) g_free(string);
return text;
}
@@ -1153,8 +1158,8 @@ text_get_attributes(Text *text, TextAttributes *attr)
{
DiaFont *old_font;
old_font = attr->font;
- attr->font = dia_font_ref(text->font);
- if (old_font != NULL) dia_font_unref(old_font);
+ attr->font = g_object_ref (text->font);
+ g_clear_object (&old_font);
attr->height = text->height;
attr->position = text->position;
attr->color = text->color;
diff --git a/lib/textline.c b/lib/textline.c
index 65eb9a06..2b8e9d0c 100644
--- a/lib/textline.c
+++ b/lib/textline.c
@@ -46,9 +46,9 @@ text_line_set_string(TextLine *text_line, const gchar *string)
if (text_line->chars != NULL) {
g_free(text_line->chars);
}
-
+
text_line->chars = g_strdup(string);
-
+
text_line_dirty_cache(text_line);
}
}
@@ -60,23 +60,21 @@ text_line_set_string(TextLine *text_line, const gchar *string)
* \memberof TextLine
*/
void
-text_line_set_font(TextLine *text_line, DiaFont *font)
+text_line_set_font (TextLine *text_line, DiaFont *font)
{
if (text_line->font != font) {
DiaFont *old_font = text_line->font;
- dia_font_ref(font);
+ g_object_ref (font);
text_line->font = font;
- if (old_font != NULL) {
- dia_font_unref(old_font);
- }
- text_line_dirty_cache(text_line);
+ g_clear_object (&old_font);
+ text_line_dirty_cache (text_line);
}
}
/*!
* \brief Sets the font height used by this object.
* @param text_line The object to change.
- * @param height The font height to use for displaying this object
+ * @param height The font height to use for displaying this object
* (in cm, from baseline to baseline)
* \memberof TextLine
*/
@@ -125,24 +123,22 @@ text_line_copy(const TextLine *text_line)
* \memberof TextLine
*/
void
-text_line_destroy(TextLine *text_line)
+text_line_destroy (TextLine *text_line)
{
if (text_line->chars != NULL) {
- g_free(text_line->chars);
- }
- if (text_line->font != NULL) {
- dia_font_unref(text_line->font);
+ g_free (text_line->chars);
}
+ g_clear_object (&text_line->font);
clear_layout_offset (text_line);
g_free (text_line->offsets);
- g_free(text_line);
+ g_free (text_line);
}
/*!
* \brief TextLine bounding box caclulation
*
* Calculate the bounding box size of this object. Since a text object has no
- * position or alignment, this collapses to just a size.
+ * position or alignment, this collapses to just a size.
* @param text_line
* @param size A place to store the width and height of the text.
* \memberof TextLine
@@ -168,7 +164,7 @@ text_line_get_font(const TextLine *text_line)
return text_line->font;
}
-real
+real
text_line_get_height(const TextLine *text_line)
{
return text_line->height;
@@ -217,11 +213,11 @@ text_line_get_alignment_adjustment(TextLine *text_line, Alignment alignment)
return text_line->width;
default:
return 0.0;
- }
+ }
}
/* **** Private functions **** */
-/** Mark this object as needing update before usage.
+/** Mark this object as needing update before usage.
* @param text_line the object that has changed.
*/
static void
@@ -266,9 +262,9 @@ text_line_cache_values(TextLine *text_line)
if (text_line->chars == NULL ||
text_line->chars[0] == '\0') {
/* caclculate reasonable ascent/decent even for empty string */
- text_line->offsets =
+ text_line->offsets =
dia_font_get_sizes("XjgM149", text_line->font, text_line->height,
- &text_line->width, &text_line->ascent,
+ &text_line->width, &text_line->ascent,
&text_line->descent, &n_offsets,
&text_line->layout_offsets);
clear_layout_offset (text_line);
@@ -276,10 +272,10 @@ text_line_cache_values(TextLine *text_line)
text_line->offsets = g_new (real,0); /* another way to assign NULL;) */
text_line->width = 0;
} else {
- text_line->offsets =
+ text_line->offsets =
dia_font_get_sizes(text_line->chars, text_line->font, text_line->height,
- &text_line->width, &text_line->ascent,
- &text_line->descent, &n_offsets,
+ &text_line->width, &text_line->ascent,
+ &text_line->descent, &n_offsets,
&text_line->layout_offsets);
}
text_line->clean = TRUE;
@@ -356,7 +352,7 @@ text_line_adjust_layout_line(TextLine *line, PangoLayoutLine *layoutline,
(int)(glyphs->glyphs[i].geometry.y_offset * scale / 20.0);
}
if (glyphs->num_glyphs != layoutglyphs->num_glyphs) {
- printf("Glyph length error: %d != %d\n",
+ printf("Glyph length error: %d != %d\n",
glyphs->num_glyphs, layoutglyphs->num_glyphs);
}
}
diff --git a/objects/AADL/aadlbox.c b/objects/AADL/aadlbox.c
index 5fce7da4..d6492e68 100644
--- a/objects/AADL/aadlbox.c
+++ b/objects/AADL/aadlbox.c
@@ -39,24 +39,24 @@
#define PORT_HANDLE_AADLBOX (HANDLE_CUSTOM9)
static Aadlport *
-new_port(Aadl_type t, gchar *d)
+new_port(Aadl_type t, gchar *d)
{
Aadlport *p;
- p = g_new0(Aadlport,1);
- p->handle = g_new0(Handle,1);
- p->type = t;
+ p = g_new0(Aadlport,1);
+ p->handle = g_new0(Handle,1);
+ p->type = t;
p->declaration = g_strdup(d);
return p;
}
static void
-free_port(Aadlport *port)
+free_port(Aadlport *port)
{
- if (port) {
- g_free(port->handle);
+ if (port) {
+ g_free(port->handle);
g_free(port->declaration);
- g_free(port);
+ g_free(port);
}
}
@@ -78,7 +78,7 @@ struct PointChange {
owning ref when applied for REMOVE_POINT */
ConnectionPoint *connection;
-
+
};
static void aadlbox_update_data(Aadlbox *aadlbox);
@@ -90,9 +90,9 @@ static ObjectChange *aadlbox_delete_port_callback (DiaObject *obj,
Point *clicked, gpointer data);
int aadlbox_point_near_port(Aadlbox *aadlbox, Point *p);
-static void aadlbox_add_connection(Aadlbox *aadlbox, const Point *p,
+static void aadlbox_add_connection(Aadlbox *aadlbox, const Point *p,
ConnectionPoint *connection);
-static void aadlbox_remove_connection(Aadlbox *aadlbox,
+static void aadlbox_remove_connection(Aadlbox *aadlbox,
ConnectionPoint *connection);
static ObjectChange *aadlbox_add_connection_callback (DiaObject *obj,
Point *clicked, gpointer data);
@@ -105,21 +105,21 @@ static int aadlbox_point_near_connection(Aadlbox *aadlbox, Point *p);
ObjectTypeOps aadlbox_type_ops =
{
(CreateFunc) aadlbox_create,
- (LoadFunc ) aadlbox_load,
- (SaveFunc) aadlbox_save,
+ (LoadFunc ) aadlbox_load,
+ (SaveFunc) aadlbox_save,
(GetDefaultsFunc) NULL,
(ApplyDefaultsFunc) NULL
};
-
+
DiaObjectType aadlbox_type =
{
- "AADL - Box", // name
+ "AADL - Box", // name
0, // version
aadlbox_xpm, // pixmap
-
+
&aadlbox_type_ops // ops
};
-
+
DiaMenu *aadlbox_get_object_menu(Aadlbox *aadlbox, Point *clickedpoint);
static ObjectOps aadlbox_ops =
{
@@ -139,11 +139,11 @@ static int aadlbox_point_near_connection(Aadlbox *aadlbox, Point *p);
(TextEditFunc) 0,
(ApplyPropertiesListFunc) object_apply_props,
};
-*/
+*/
static PropDescription aadlbox_props[] = {
ELEMENT_COMMON_PROPERTIES,
- { "declaration", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
+ { "declaration", PROP_TYPE_STRING, PROP_FLAG_VISIBLE,
N_("Declaration"), NULL, NULL },
PROP_STD_LINE_COLOUR_OPTIONAL,
PROP_STD_FILL_COLOUR_OPTIONAL,
@@ -200,7 +200,7 @@ DiaObject *aadlbox_copy(DiaObject *obj)
Aadlbox *aadlbox = (Aadlbox *) obj;
void *user_data = ((Aadlbox *) obj)->specific;
-
+
DiaObject *newobj = obj->type->ops->create(&obj->position,
user_data,
&handle1,&handle2);
@@ -211,7 +211,7 @@ DiaObject *aadlbox_copy(DiaObject *obj)
Point p;
point_copy(&p, &aadlbox->ports[i]->handle->pos);
port = new_port(aadlbox->ports[i]->type, aadlbox->ports[i]->declaration);
-
+
aadlbox_add_port((Aadlbox *)newobj, &p, port);
}
@@ -220,7 +220,7 @@ DiaObject *aadlbox_copy(DiaObject *obj)
Point p;
point_copy(&p, &aadlbox->connections[i]->pos);
connection= g_new0(ConnectionPoint, 1);
-
+
aadlbox_add_connection((Aadlbox *)newobj, &p, connection);
}
@@ -242,13 +242,13 @@ aadlbox_change_free(struct PointChange *change)
free_port (change->port);
change->port = NULL;
-
+
} else if ( (change->type==TYPE_ADD_CONNECTION && !change->applied) ||
(change->type==TYPE_REMOVE_CONNECTION && change->applied) ) {
-
+
g_free (change->connection);
change->connection = NULL;
-
+
}
}
@@ -277,7 +277,7 @@ aadlbox_change_apply(struct PointChange *change, DiaObject *obj)
static void
aadlbox_change_revert(struct PointChange *change, DiaObject *obj)
{
-
+
switch (change->type) {
case TYPE_ADD_POINT:
aadlbox_remove_port((Aadlbox *)obj, change->port);
@@ -286,16 +286,16 @@ aadlbox_change_revert(struct PointChange *change, DiaObject *obj)
case TYPE_REMOVE_POINT:
aadlbox_add_port((Aadlbox *)obj, &change->point, change->port);
break;
-
+
case TYPE_ADD_CONNECTION:
aadlbox_remove_connection((Aadlbox *)obj, change->connection);
break;
-
+
case TYPE_REMOVE_CONNECTION: ;
aadlbox_add_connection((Aadlbox *)obj, &change->point, change->connection);
break;
}
-
+
aadlbox_update_data((Aadlbox *)obj);
change->applied = 0;
}
@@ -312,22 +312,22 @@ aadlbox_create_change(Aadlbox *aadlbox, enum change_type type,
change->obj_change.apply = (ObjectChangeApplyFunc) aadlbox_change_apply;
change->obj_change.revert = (ObjectChangeRevertFunc) aadlbox_change_revert;
change->obj_change.free = (ObjectChangeFreeFunc) aadlbox_change_free;
-
+
change->type = type;
change->applied = 1;
change->point = *point;
-
- switch (type) {
-
+
+ switch (type) {
+
case TYPE_ADD_POINT: case TYPE_REMOVE_POINT:
change->port = (Aadlport *) data;
break;
-
+
case TYPE_ADD_CONNECTION: case TYPE_REMOVE_CONNECTION:
change->connection = (ConnectionPoint *) data;
break;
}
-
+
return (ObjectChange *)change;
}
@@ -382,7 +382,7 @@ static DiaMenuItem aadlbox_menu_items[] = {
static DiaMenuItem aadlport_menu_items[] = {
{ N_("Delete Port"), aadlbox_delete_port_callback, NULL, 1 },
- { N_("Edit Port Declaration"), edit_port_declaration_callback, NULL, 1 }
+ { N_("Edit Port Declaration"), edit_port_declaration_callback, NULL, 1 }
};
static DiaMenuItem aadlconn_menu_items[] = {
@@ -417,26 +417,26 @@ DiaMenu *
aadlbox_get_object_menu(Aadlbox *aadlbox, Point *clickedpoint)
{
int n;
-
+
if ((n = aadlbox_point_near_port(aadlbox, clickedpoint)) >= 0) {
-
+
/* no port declaration with event ports */
-
+
if ( aadlbox->ports[n]->type == IN_EVENT_PORT ||
aadlbox->ports[n]->type == OUT_EVENT_PORT ||
aadlbox->ports[n]->type == IN_OUT_EVENT_PORT )
-
+
aadlport_menu_items[1].active = 0;
else
aadlport_menu_items[1].active = 1;
-
+
return &aadlport_menu;
}
-
- if (aadlbox_point_near_connection(aadlbox, clickedpoint) >= 0)
+
+ if (aadlbox_point_near_connection(aadlbox, clickedpoint) >= 0)
return &aadlconn_menu;
-
-
+
+
return &aadlbox_menu;
}
@@ -596,11 +596,11 @@ aadlbox_add_connection(Aadlbox *aadlbox, const Point *p, ConnectionPoint *connec
connection->object = (DiaObject *) aadlbox;
connection->connected = NULL; /* FIXME: could be avoided ?? */
-
+
aadlbox->num_connections++;
-
+
if (aadlbox->connections == NULL)
- aadlbox->connections =
+ aadlbox->connections =
g_malloc(sizeof(ConnectionPoint*)*aadlbox->num_connections);
else
@@ -612,7 +612,7 @@ aadlbox_add_connection(Aadlbox *aadlbox, const Point *p, ConnectionPoint *connec
aadlbox->connections[i] = connection;
aadlbox->connections[i]->pos = *p;
-
+
object_add_connectionpoint(&aadlbox->element.object, connection);
}
@@ -624,7 +624,7 @@ aadlbox_remove_connection(Aadlbox *aadlbox, ConnectionPoint *connection)
for (i=0;i<aadlbox->num_connections;i++) {
if (aadlbox->connections[i] == connection) {
-
+
for (j=i;j<aadlbox->num_connections-1;j++) {
aadlbox->connections[j] = aadlbox->connections[j+1];
}
@@ -650,13 +650,13 @@ aadlbox_add_connection_callback (DiaObject *obj, Point *clicked, gpointer data)
aadlbox_add_connection(aadlbox, clicked, connection);
aadlbox_update_data(aadlbox);
-
+
return aadlbox_create_change(aadlbox, TYPE_ADD_CONNECTION, clicked,connection);
}
ObjectChange *
-aadlbox_delete_connection_callback (DiaObject *obj, Point *clicked,
+aadlbox_delete_connection_callback (DiaObject *obj, Point *clicked,
gpointer data)
{
Aadlbox *aadlbox = (Aadlbox *) obj;
@@ -704,9 +704,9 @@ aadlbox_move_handle(Aadlbox *aadlbox, Handle *handle,
assert(aadlbox!=NULL);
assert(handle!=NULL);
assert(to!=NULL);
-
+
if (handle->id < 8) { /* box resizing */
-
+
Element *element = &aadlbox->element;
Point oldcorner, newcorner;
real oldw, neww, oldh, newh;
@@ -714,26 +714,26 @@ aadlbox_move_handle(Aadlbox *aadlbox, Handle *handle,
Aadlport *p;
ConnectionPoint *c;
int i;
-
+
point_copy(&oldcorner, &element->corner);
oldw = element->width;
oldh = element->height;
-
+
element_move_handle( &aadlbox->element, handle->id, to, cp,
reason, modifiers);
-
+
point_copy(&newcorner, &element->corner);
neww = element->width;
newh = element->height;
-
+
/* update ports positions proportionally */
for (i=0; i < aadlbox->num_ports; i++)
{
p = aadlbox->ports[i];
- w_factor = (p->handle->pos.x - oldcorner.x) / oldw;
+ w_factor = (p->handle->pos.x - oldcorner.x) / oldw;
h_factor = (p->handle->pos.y - oldcorner.y) / oldh;
-
+
p->handle->pos.x = newcorner.x + w_factor * neww;
p->handle->pos.y = newcorner.y + h_factor * newh;
}
@@ -742,14 +742,14 @@ aadlbox_move_handle(Aadlbox *aadlbox, Handle *handle,
for (i=0; i < aadlbox->num_connections; i++)
{
c = aadlbox->connections[i];
-
- w_factor = (c->pos.x - oldcorner.x) / oldw;
+
+ w_factor = (c->pos.x - oldcorner.x) / oldw;
h_factor = (c->pos.y - oldcorner.y) / oldh;
-
+
c->pos.x = newcorner.x + w_factor * neww;
c->pos.y = newcorner.y + h_factor * newh;
}
-
+
}
else { /* port handles */
@@ -757,9 +757,9 @@ aadlbox_move_handle(Aadlbox *aadlbox, Handle *handle,
handle->pos.x = to->x;
handle->pos.y = to->y;
}
-
+
aadlbox_update_data(aadlbox);
-
+
/* FIXME !! Should I free the given structures (to, ...) ? */
return NULL;
}
@@ -773,7 +773,7 @@ aadlbox_move(Aadlbox *aadlbox, Point *to)
delta = *to;
point_sub(&delta, &obj->position);
-
+
/* update ports position */
for (i=0;i<aadlbox->num_ports;i++) {
point_add(&aadlbox->ports[i]->handle->pos, &delta);
@@ -783,8 +783,8 @@ aadlbox_move(Aadlbox *aadlbox, Point *to)
for (i=0;i<aadlbox->num_connections;i++) {
point_add(&aadlbox->connections[i]->pos, &delta);
}
-
-
+
+
aadlbox->element.corner = *to;
p = *to;
@@ -808,11 +808,11 @@ void aadlbox_draw(Aadlbox *aadlbox, DiaRenderer *renderer)
}
-static void
+static void
aadlbox_update_text_position(Aadlbox *aadlbox)
{
Point p;
-
+
aadlbox->specific->text_position(aadlbox, &p);
text_set_position(aadlbox->name, &p);
}
@@ -825,7 +825,7 @@ aadlbox_update_data(Aadlbox *aadlbox)
Point min_size;
int i;
real tmp;
-
+
aadlbox->specific->min_size(aadlbox, &min_size);
elem->width = MAX(elem->width, min_size.x);
@@ -833,12 +833,12 @@ aadlbox_update_data(Aadlbox *aadlbox)
element_update_boundingbox(elem);
- /* extend bounding box because of ports */
+ /* extend bounding box because of ports */
/* FIXME: This cause the box to be selectionned when clicking out of it !! */
- obj->bounding_box.top -= AADL_PORT_MAX_OUT + 0.1;
- obj->bounding_box.right += AADL_PORT_MAX_OUT + 0.1;
- obj->bounding_box.bottom += AADL_PORT_MAX_OUT + 0.1;
- obj->bounding_box.left -= AADL_PORT_MAX_OUT + 0.1;
+ obj->bounding_box.top -= AADL_PORT_MAX_OUT + 0.1;
+ obj->bounding_box.right += AADL_PORT_MAX_OUT + 0.1;
+ obj->bounding_box.bottom += AADL_PORT_MAX_OUT + 0.1;
+ obj->bounding_box.left -= AADL_PORT_MAX_OUT + 0.1;
obj->position = elem->corner;
@@ -847,21 +847,21 @@ aadlbox_update_data(Aadlbox *aadlbox)
element_update_handles(elem);
aadlbox_update_ports(aadlbox);
-
+
for (i=0;i<aadlbox->num_connections;i++)
aadlbox->specific->project_point_on_nearest_border(aadlbox,
- &aadlbox->connections[i]->pos,
+ &aadlbox->connections[i]->pos,
&tmp);
}
-/** *NOT A CALLBACK*
+/** *NOT A CALLBACK*
Caller must set: - obj->type
--------------- - obj->ops
*/
-DiaObject *aadlbox_create(Point *startpoint, void *user_data,
+DiaObject *aadlbox_create(Point *startpoint, void *user_data,
Handle **handle1, Handle **handle2)
{
@@ -890,7 +890,7 @@ DiaObject *aadlbox_create(Point *startpoint, void *user_data,
p.x = 0.0;
p.y = 0.0;
aadlbox->name = new_text("", font, 0.8, &p, &color_black, ALIGN_LEFT);
- dia_font_unref(font);
+ g_clear_object (&font);
element_init(elem, 8, 0); /* 8 handles and 0 connection */
@@ -902,7 +902,7 @@ DiaObject *aadlbox_create(Point *startpoint, void *user_data,
return &aadlbox->element.object;
}
-void
+void
aadlbox_destroy(Aadlbox *aadlbox)
{
int i;
@@ -921,24 +921,24 @@ aadlbox_save(Aadlbox *aadlbox, ObjectNode obj_node, DiaContext *ctx)
int i;
AttributeNode attr;
DataNode composite;
-
+
element_save(&aadlbox->element, obj_node, ctx);
object_save_props(&aadlbox->element.object, obj_node, ctx);
attr = new_attribute(obj_node, "aadlbox_ports");
-
+
for (i=0;i<aadlbox->num_ports;i++) {
composite = data_add_composite(attr, "aadlport", ctx);
- data_add_point(composite_add_attribute(composite, "point"),
+ data_add_point(composite_add_attribute(composite, "point"),
&aadlbox->ports[i]->handle->pos, ctx);
- data_add_enum(composite_add_attribute(composite, "port_type"),
+ data_add_enum(composite_add_attribute(composite, "port_type"),
aadlbox->ports[i]->type, ctx);
- data_add_string(composite_add_attribute(composite, "port_declaration"),
+ data_add_string(composite_add_attribute(composite, "port_declaration"),
aadlbox->ports[i]->declaration, ctx);
}
-
+
attr = new_attribute(obj_node, "aadlbox_connections");
-
+
for (i=0;i<aadlbox->num_connections;i++) {
data_add_point(attr, &aadlbox->connections[i]->pos, ctx);
}
@@ -955,49 +955,49 @@ void aadlbox_load(ObjectNode obj_node, int version, DiaContext *ctx,
Aadlport *port;
ConnectionPoint *connection;
int i, num;
-
+
attr = object_find_attribute(obj_node, "aadlbox_ports");
composite = attribute_first_data(attr);
num = attribute_num_data(attr);
-
+
for (i=0; i<num; i++) {
-
+
Point p;
attr = composite_find_attribute(composite, "point");
data_point(attribute_first_data(attr), &p, ctx);
-
+
attr = composite_find_attribute(composite, "port_type");
type = data_enum(attribute_first_data(attr), ctx);
-
+
attr = composite_find_attribute(composite, "port_declaration");
declaration = data_string(attribute_first_data(attr), ctx);
-
+
port = g_new0(Aadlport,1);
port->handle = g_new0(Handle,1);
port->type = type;
port->declaration = declaration;
-
+
aadlbox_add_port(aadlbox, &p, port);
-
+
composite = data_next(composite);
}
-
+
attr = object_find_attribute(obj_node, "aadlbox_connections");
num = attribute_num_data(attr);
data = attribute_first_data(attr);
-
+
for (i=0; i<num; i++) {
Point p;
data_point(data, &p, ctx);
connection = g_new0(ConnectionPoint,1);
aadlbox_add_connection(aadlbox, &p, connection);
-
+
data = data_next(data);
}
-
+
object_load_props(&aadlbox->element.object,obj_node, ctx);
}
diff --git a/objects/Database/table.c b/objects/Database/table.c
index 3daf8c2c..f8b3cee5 100644
--- a/objects/Database/table.c
+++ b/objects/Database/table.c
@@ -503,19 +503,18 @@ table_destroy (Table * table)
g_free (table->comment);
list = table->attributes;
- while (list != NULL)
- {
- TableAttribute * attr = (TableAttribute *) list->data;
- table_attribute_free (attr);
+ while (list != NULL) {
+ TableAttribute * attr = (TableAttribute *) list->data;
+ table_attribute_free (attr);
- list = g_list_next (list);
- }
+ list = g_list_next (list);
+ }
g_list_free (table->attributes);
- dia_font_unref (table->normal_font);
- dia_font_unref (table->primary_key_font);
- dia_font_unref (table->name_font);
- dia_font_unref (table->comment_font);
+ g_clear_object (&table->normal_font);
+ g_clear_object (&table->primary_key_font);
+ g_clear_object (&table->name_font);
+ g_clear_object (&table->comment_font);
}
static void
@@ -840,11 +839,11 @@ table_copy(Table * orig)
list = g_list_next (list);
}
copy->normal_font_height = orig->normal_font_height;
- copy->normal_font = dia_font_ref (orig->normal_font);
+ copy->normal_font = g_object_ref (orig->normal_font);
copy->name_font_height = orig->name_font_height;
- copy->name_font = dia_font_ref (orig->name_font);
+ copy->name_font = g_object_ref (orig->name_font);
copy->comment_font_height = orig->comment_font_height;
- copy->comment_font = dia_font_ref (orig->comment_font);
+ copy->comment_font = g_object_ref (orig->comment_font);
copy->text_color = orig->text_color;
copy->line_color = orig->line_color;
copy->fill_color = orig->fill_color;
@@ -1356,19 +1355,16 @@ table_show_comments_cb(DiaObject *obj, Point *pos, gpointer data)
static void
table_update_primary_key_font (Table * table)
{
- if (table->primary_key_font)
- dia_font_unref (table->primary_key_font);
+ g_clear_object (&table->primary_key_font);
+
if (!table->bold_primary_key
|| (DIA_FONT_STYLE_GET_WEIGHT (dia_font_get_style (table->normal_font))
- == DIA_FONT_BOLD))
- {
- table->primary_key_font = dia_font_ref (table->normal_font);
- }
- else
- {
- table->primary_key_font = dia_font_copy (table->normal_font);
- dia_font_set_weight (table->primary_key_font, DIA_FONT_BOLD);
- }
+ == DIA_FONT_BOLD)) {
+ table->primary_key_font = g_object_ref (table->normal_font);
+ } else {
+ table->primary_key_font = dia_font_copy (table->normal_font);
+ dia_font_set_weight (table->primary_key_font, DIA_FONT_BOLD);
+ }
table->primary_key_font_height = table->normal_font_height;
}
diff --git a/objects/ER/attribute.c b/objects/ER/attribute.c
index 90c8b798..e86f828b 100644
--- a/objects/ER/attribute.c
+++ b/objects/ER/attribute.c
@@ -489,7 +489,7 @@ attribute_copy(Attribute *attribute)
newattribute->connections[i].flags = attribute->connections[i].flags;
}
- newattribute->font = dia_font_ref(attribute->font);
+ newattribute->font = g_object_ref (attribute->font);
newattribute->font_height = attribute->font_height;
newattribute->name = g_strdup(attribute->name);
newattribute->name_width = attribute->name_width;
@@ -587,7 +587,7 @@ attribute_load(ObjectNode obj_node, int version,DiaContext *ctx)
if (attribute->font != NULL) {
/* This shouldn't happen, but doesn't hurt */
- dia_font_unref(attribute->font);
+ g_clear_object (&attribute->font);
attribute->font = NULL;
}
attr = object_find_attribute (obj_node, "font");
diff --git a/objects/ER/entity.c b/objects/ER/entity.c
index e7de4660..7bdb024d 100644
--- a/objects/ER/entity.c
+++ b/objects/ER/entity.c
@@ -420,11 +420,11 @@ entity_create(Point *startpoint,
}
static void
-entity_destroy(Entity *entity)
+entity_destroy (Entity *entity)
{
- dia_font_unref(entity->font);
- element_destroy(&entity->element);
- g_free(entity->name);
+ g_clear_object (&entity->font);
+ element_destroy (&entity->element);
+ g_free (entity->name);
}
static DiaObject *
@@ -455,7 +455,7 @@ entity_copy(Entity *entity)
newentity->connections[i].flags = entity->connections[i].flags;
}
- newentity->font = dia_font_ref(entity->font);
+ newentity->font = g_object_ref (entity->font);
newentity->font_height = entity->font_height;
newentity->name = g_strdup(entity->name);
newentity->name_width = entity->name_width;
@@ -536,7 +536,7 @@ entity_load(ObjectNode obj_node, int version,DiaContext *ctx)
if (entity->font != NULL) {
/* This shouldn't happen, but doesn't hurt */
- dia_font_unref(entity->font);
+ g_clear_object (&entity->font);
entity->font = NULL;
}
attr = object_find_attribute (obj_node, "font");
diff --git a/objects/ER/relationship.c b/objects/ER/relationship.c
index d9f78593..d14d524b 100644
--- a/objects/ER/relationship.c
+++ b/objects/ER/relationship.c
@@ -477,13 +477,13 @@ relationship_create(Point *startpoint,
}
static void
-relationship_destroy(Relationship *relationship)
+relationship_destroy (Relationship *relationship)
{
- dia_font_unref(relationship->font);
- element_destroy(&relationship->element);
- g_free(relationship->name);
- g_free(relationship->left_cardinality);
- g_free(relationship->right_cardinality);
+ g_clear_object (&relationship->font);
+ element_destroy (&relationship->element);
+ g_free (relationship->name);
+ g_free (relationship->left_cardinality);
+ g_free (relationship->right_cardinality);
}
static DiaObject *
@@ -513,7 +513,7 @@ relationship_copy(Relationship *relationship)
newrelationship->connections[i].pos = relationship->connections[i].pos;
}
- newrelationship->font = dia_font_ref(relationship->font);
+ newrelationship->font = g_object_ref (relationship->font);
newrelationship->font_height = relationship->font_height;
newrelationship->name = g_strdup(relationship->name);
newrelationship->left_cardinality =
diff --git a/objects/FS/flow-ortho.c b/objects/FS/flow-ortho.c
index 653a746a..00203bdb 100644
--- a/objects/FS/flow-ortho.c
+++ b/objects/FS/flow-ortho.c
@@ -416,8 +416,8 @@ orthflow_create(Point *startpoint,
orthflow->textpos = p;
font = dia_font_new_from_style(DIA_FONT_SANS, ORTHFLOW_FONTHEIGHT);
- orthflow->text = new_text("", font, ORTHFLOW_FONTHEIGHT, &p, &color_black, ALIGN_CENTER);
- dia_font_unref(font);
+ orthflow->text = new_text ("", font, ORTHFLOW_FONTHEIGHT, &p, &color_black, ALIGN_CENTER);
+ g_clear_object (&font);
#if 0
if ( orthflow_default_label ) {
@@ -570,8 +570,8 @@ orthflow_load(ObjectNode obj_node, int version, DiaContext *ctx)
else { /* paranoid */
DiaFont *font = dia_font_new_from_style(DIA_FONT_SANS, ORTHFLOW_FONTHEIGHT);
- orthflow->text = new_text("", font, ORTHFLOW_FONTHEIGHT, &obj->position, &color_black, ALIGN_CENTER);
- dia_font_unref(font);
+ orthflow->text = new_text ("", font, ORTHFLOW_FONTHEIGHT, &obj->position, &color_black, ALIGN_CENTER);
+ g_clear_object (&font);
}
attr = object_find_attribute(obj_node, "type");
diff --git a/objects/FS/flow.c b/objects/FS/flow.c
index ccf405f4..0f217b20 100644
--- a/objects/FS/flow.c
+++ b/objects/FS/flow.c
@@ -401,8 +401,8 @@ flow_create(Point *startpoint,
font = dia_font_new_from_style(DIA_FONT_SANS, FLOW_FONTHEIGHT);
- flow->text = new_text("", font, FLOW_FONTHEIGHT, &p, &color_black, ALIGN_CENTER);
- dia_font_unref(font);
+ flow->text = new_text ("", font, FLOW_FONTHEIGHT, &p, &color_black, ALIGN_CENTER);
+ g_clear_object (&font);
flow->text_handle.id = HANDLE_MOVE_TEXT;
flow->text_handle.type = HANDLE_MINOR_CONTROL;
@@ -538,8 +538,8 @@ flow_load(ObjectNode obj_node, int version, DiaContext *ctx)
else { /* pathologic */
DiaFont *font = dia_font_new_from_style(DIA_FONT_SANS, FLOW_FONTHEIGHT);
- flow->text = new_text("", font, FLOW_FONTHEIGHT, &obj->position, &color_black, ALIGN_CENTER);
- dia_font_unref(font);
+ flow->text = new_text ("", font, FLOW_FONTHEIGHT, &obj->position, &color_black, ALIGN_CENTER);
+ g_clear_object (&font);
}
attr = object_find_attribute(obj_node, "type");
diff --git a/objects/FS/function.c b/objects/FS/function.c
index 5fdbfc25..b23d8f8c 100644
--- a/objects/FS/function.c
+++ b/objects/FS/function.c
@@ -444,13 +444,13 @@ function_create(Point *startpoint,
/* The text position is recalculated later */
p.x = 0.0;
p.y = 0.0;
- pkg->text = new_text("", font, FUNCTION_FONTHEIGHT, &p, &color_black,
- ALIGN_CENTER);
- dia_font_unref(font);
+ pkg->text = new_text ("", font, FUNCTION_FONTHEIGHT, &p, &color_black,
+ ALIGN_CENTER);
+ g_clear_object (&font);
- element_init(elem, 8, NUM_CONNECTIONS);
+ element_init (elem, 8, NUM_CONNECTIONS);
- for (i=0;i<NUM_CONNECTIONS;i++) {
+ for (i = 0; i < NUM_CONNECTIONS; i++) {
obj->connections[i] = &pkg->connections[i];
pkg->connections[i].object = obj;
pkg->connections[i].connected = NULL;
@@ -553,8 +553,8 @@ function_load(ObjectNode obj_node, int version, DiaContext *ctx)
pkg->text = data_text(attribute_first_data(attr), ctx);
else { /* paranoid */
DiaFont *font = dia_font_new_from_style (DIA_FONT_SANS,FUNCTION_FONTHEIGHT);
- pkg->text = new_text("", font, FUNCTION_FONTHEIGHT, &obj->position, &color_black, ALIGN_CENTER);
- dia_font_unref(font);
+ pkg->text = new_text ("", font, FUNCTION_FONTHEIGHT, &obj->position, &color_black, ALIGN_CENTER);
+ g_clear_object (&font);
}
attr = object_find_attribute(obj_node, "is_wish");
diff --git a/objects/GRAFCET/action.c b/objects/GRAFCET/action.c
index e3227c83..080db107 100644
--- a/objects/GRAFCET/action.c
+++ b/objects/GRAFCET/action.c
@@ -412,10 +412,10 @@ action_create(Point *startpoint,
pos = conn->endpoints[1];
action_font = dia_font_new_from_style(ACTION_FONT,ACTION_FONT_HEIGHT);
- action->text = new_text("",action_font, ACTION_FONT_HEIGHT,
- &pos, /* never used */
- &color_black, ALIGN_LEFT);
- dia_font_unref(action_font);
+ action->text = new_text ("", action_font, ACTION_FONT_HEIGHT,
+ &pos, /* never used */
+ &color_black, ALIGN_LEFT);
+ g_clear_object (&action_font);
action->macro_call = FALSE;
diff --git a/objects/GRAFCET/boolequation.c b/objects/GRAFCET/boolequation.c
index 476b6335..21689fb9 100644
--- a/objects/GRAFCET/boolequation.c
+++ b/objects/GRAFCET/boolequation.c
@@ -567,16 +567,18 @@ boolequation_set_value(Boolequation *booleq, const gchar *value)
Boolequation *
-boolequation_create(const gchar *value, DiaFont *font, real fontheight,
- Color *color)
+boolequation_create (const gchar *value,
+ DiaFont *font,
+ real fontheight,
+ Color *color)
{
Boolequation *booleq;
- booleq = g_new0(Boolequation,1);
- booleq->font = dia_font_ref(font);
+ booleq = g_new0 (Boolequation,1);
+ booleq->font = g_object_ref (font);
booleq->fontheight = fontheight;
booleq->color = *color;
- boolequation_set_value(booleq,value);
+ boolequation_set_value (booleq,value);
return booleq;
}
@@ -585,10 +587,10 @@ void
boolequation_destroy(Boolequation *booleq)
{
g_return_if_fail(booleq);
- dia_font_unref(booleq->font);
+ g_clear_object (&booleq->font);
if (booleq->value) g_free((gchar *)booleq->value);
if (booleq->rootblock) booleq->rootblock->ops->destroy(booleq->rootblock);
- g_free(booleq);
+ g_free (booleq);
}
void
diff --git a/objects/GRAFCET/condition.c b/objects/GRAFCET/condition.c
index 6787c43b..6777de17 100644
--- a/objects/GRAFCET/condition.c
+++ b/objects/GRAFCET/condition.c
@@ -163,15 +163,15 @@ condition_get_props(Condition *condition, GPtrArray *props)
static void
condition_set_props(Condition *condition, GPtrArray *props)
{
- object_set_props_from_offsets(&condition->connection.object,
- condition_offsets,props);
+ object_set_props_from_offsets (&condition->connection.object,
+ condition_offsets,props);
- boolequation_set_value(condition->cond,condition->cond_value);
- dia_font_unref(condition->cond->font);
- condition->cond->font = dia_font_ref(condition->cond_font);
+ boolequation_set_value (condition->cond,condition->cond_value);
+ g_clear_object (&condition->cond->font);
+ condition->cond->font = g_object_ref (condition->cond_font);
condition->cond->fontheight = condition->cond_fontheight;
condition->cond->color = condition->cond_color;
- condition_update_data(condition);
+ condition_update_data (condition);
}
static real
@@ -353,7 +353,7 @@ condition_create(Point *startpoint,
condition->cond = boolequation_create("",default_font,default_fontheight,
&fg_color);
condition->cond_value = g_strdup("");
- condition->cond_font = dia_font_ref(default_font);
+ condition->cond_font = g_object_ref (default_font);
condition->cond_fontheight = default_fontheight;
condition->cond_color = fg_color;
@@ -368,7 +368,7 @@ condition_create(Point *startpoint,
*handle1 = &conn->endpoint_handles[0];
*handle2 = &conn->endpoint_handles[1];
- dia_font_unref(default_font);
+ g_clear_object (&default_font);
return &condition->connection.object;
}
@@ -376,10 +376,10 @@ condition_create(Point *startpoint,
static void
condition_destroy(Condition *condition)
{
- dia_font_unref(condition->cond_font);
- boolequation_destroy(condition->cond);
- g_free(condition->cond_value);
- connection_destroy(&condition->connection);
+ g_clear_object (&condition->cond_font);
+ boolequation_destroy (condition->cond);
+ g_free (condition->cond_value);
+ connection_destroy (&condition->connection);
}
static DiaObject *
diff --git a/objects/GRAFCET/step.c b/objects/GRAFCET/step.c
index beb65347..61c57a42 100644
--- a/objects/GRAFCET/step.c
+++ b/objects/GRAFCET/step.c
@@ -554,11 +554,11 @@ step_create(Point *startpoint,
}
static void
-step_destroy(Step *step)
+step_destroy (Step *step)
{
- dia_font_unref(step->font);
- g_free(step->id);
- element_destroy(&step->element);
+ g_clear_object (&step->font);
+ g_free (step->id);
+ element_destroy (&step->element);
}
static DiaObject *
diff --git a/objects/GRAFCET/transition.c b/objects/GRAFCET/transition.c
index af295c5d..0fc9bd1f 100644
--- a/objects/GRAFCET/transition.c
+++ b/objects/GRAFCET/transition.c
@@ -177,12 +177,13 @@ transition_get_props(Transition *transition, GPtrArray *props)
static void
transition_set_props(Transition *transition, GPtrArray *props)
{
- object_set_props_from_offsets(&transition->element.object,
- transition_offsets,props);
+ object_set_props_from_offsets (&transition->element.object,
+ transition_offsets,
+ props);
- boolequation_set_value(transition->receptivity,transition->rcep_value);
- dia_font_unref(transition->receptivity->font);
- transition->receptivity->font = dia_font_ref(transition->rcep_font);
+ boolequation_set_value (transition->receptivity,transition->rcep_value);
+ g_clear_object (&transition->receptivity->font);
+ transition->receptivity->font = g_object_ref (transition->rcep_font);
transition->receptivity->fontheight = transition->rcep_fontheight;
transition->receptivity->color = transition->rcep_color;
@@ -399,11 +400,11 @@ transition_create(Point *startpoint,
&fg_color);
transition->rcep_value = g_strdup("");
- transition->rcep_font = dia_font_ref(default_font);
+ transition->rcep_font = g_object_ref (default_font);
transition->rcep_fontheight = default_fontheight;
transition->rcep_color = fg_color;
- dia_font_unref(default_font);
+ g_clear_object (&default_font);
for (i=0;i<8;i++) {
@@ -434,12 +435,12 @@ transition_create(Point *startpoint,
}
static void
-transition_destroy(Transition *transition)
+transition_destroy (Transition *transition)
{
- dia_font_unref(transition->rcep_font);
- boolequation_destroy(transition->receptivity);
- g_free(transition->rcep_value);
- element_destroy(&transition->element);
+ g_clear_object (&transition->rcep_font);
+ boolequation_destroy (transition->receptivity);
+ g_free (transition->rcep_value);
+ element_destroy (&transition->element);
}
static DiaObject *
diff --git a/objects/Istar/actor.c b/objects/Istar/actor.c
index c8f74c02..ab201781 100644
--- a/objects/Istar/actor.c
+++ b/objects/Istar/actor.c
@@ -430,10 +430,10 @@ actor_create(Point *startpoint,
p = *startpoint;
p.x += elem->width / 2.0;
p.y += elem->height / 2.0 + ACTOR_FONT / 2;
- actor->text = new_text("", font, ACTOR_FONT, &p, &ACTOR_FG_COLOR, ALIGN_CENTER);
- dia_font_unref(font);
+ actor->text = new_text ("", font, ACTOR_FONT, &p, &ACTOR_FG_COLOR, ALIGN_CENTER);
+ g_clear_object (&font);
- element_init(elem, 8, NUM_CONNECTIONS);
+ element_init (elem, 8, NUM_CONNECTIONS);
for (i=0;i<NUM_CONNECTIONS;i++) {
obj->connections[i] = &actor->connections[i];
diff --git a/objects/Istar/goal.c b/objects/Istar/goal.c
index 12d5c7d1..477620ba 100644
--- a/objects/Istar/goal.c
+++ b/objects/Istar/goal.c
@@ -512,11 +512,11 @@ goal_create(Point *startpoint,
font = dia_font_new_from_style( DIA_FONT_SANS , DEFAULT_FONT);
- goal->text = new_text("", font,
- DEFAULT_FONT, &p,
- &color_black,
- ALIGN_CENTER);
- dia_font_unref(font);
+ goal->text = new_text ("", font,
+ DEFAULT_FONT, &p,
+ &color_black,
+ ALIGN_CENTER);
+ g_clear_object (&font);
element_init(elem, 8, NUM_CONNECTIONS);
diff --git a/objects/Istar/other.c b/objects/Istar/other.c
index 54d1baf9..8ae0fa12 100644
--- a/objects/Istar/other.c
+++ b/objects/Istar/other.c
@@ -519,7 +519,7 @@ other_create(Point *startpoint,
DEFAULT_FONT, &p,
&color_black,
ALIGN_CENTER);
- dia_font_unref(font);
+ g_clear_object (&font);
element_init(elem, 8, 0);
diff --git a/objects/Jackson/domain.c b/objects/Jackson/domain.c
index bd0c62c7..4c2cc305 100644
--- a/objects/Jackson/domain.c
+++ b/objects/Jackson/domain.c
@@ -576,15 +576,15 @@ jackson_box_create(Point *startpoint,
p.x += (LEFT_SPACE +elem->width) / 2.0;
p.y += elem->height / 2.0 + DEFAULT_FONT / 2;
- font = dia_font_new_from_style( DIA_FONT_SANS, DEFAULT_FONT);
+ font = dia_font_new_from_style (DIA_FONT_SANS, DEFAULT_FONT);
- box->text = new_text("", font,
- DEFAULT_FONT, &p,
- &color_black,
- ALIGN_CENTER);
- dia_font_unref(font);
+ box->text = new_text ("", font,
+ DEFAULT_FONT, &p,
+ &color_black,
+ ALIGN_CENTER);
+ g_clear_object (&font);
- element_init(elem, 8, 0);
+ element_init (elem, 8, 0);
box->north = connpointline_create(obj,3);
box->west = connpointline_create(obj,1);
diff --git a/objects/Jackson/requirement.c b/objects/Jackson/requirement.c
index 372f0262..9cab55df 100644
--- a/objects/Jackson/requirement.c
+++ b/objects/Jackson/requirement.c
@@ -361,9 +361,9 @@ req_create(Point *startpoint,
p.x += REQ_WIDTH/2.0;
p.y += REQ_HEIGHT/2.0;
- req->text = new_text("", font, REQ_FONT, &p, &color_black, ALIGN_CENTER);
- dia_font_unref(font);
- element_init(elem, 8, NUM_CONNECTIONS);
+ req->text = new_text ("", font, REQ_FONT, &p, &color_black, ALIGN_CENTER);
+ g_clear_object (&font);
+ element_init (elem, 8, NUM_CONNECTIONS);
for (i=0;i<NUM_CONNECTIONS;i++) {
obj->connections[i] = &req->connections[i];
diff --git a/objects/KAOS/goal.c b/objects/KAOS/goal.c
index 67e78205..838860e7 100644
--- a/objects/KAOS/goal.c
+++ b/objects/KAOS/goal.c
@@ -620,11 +620,11 @@ goal_create(Point *startpoint,
font = dia_font_new_from_style( DIA_FONT_SANS , DEFAULT_FONT);
- goal->text = new_text("", font,
- DEFAULT_FONT, &p,
- &color_black,
- ALIGN_CENTER);
- dia_font_unref(font);
+ goal->text = new_text ("", font,
+ DEFAULT_FONT, &p,
+ &color_black,
+ ALIGN_CENTER);
+ g_clear_object (&font);
element_init(elem, 8, 0);
diff --git a/objects/KAOS/other.c b/objects/KAOS/other.c
index d8429066..190bb94e 100644
--- a/objects/KAOS/other.c
+++ b/objects/KAOS/other.c
@@ -570,7 +570,7 @@ other_create(Point *startpoint,
DEFAULT_FONT, &p,
&color_black,
ALIGN_CENTER);
- dia_font_unref(font);
+ g_clear_object (&font);
element_init(elem, 8, 1);
diff --git a/objects/SADT/annotation.c b/objects/SADT/annotation.c
index dfc8b0c7..e96abbd1 100644
--- a/objects/SADT/annotation.c
+++ b/objects/SADT/annotation.c
@@ -356,7 +356,7 @@ annotation_create(Point *startpoint,
&conn->endpoints[1],
&color_black,
ALIGN_CENTER);
- dia_font_unref(font);
+ g_clear_object (&font);
offs.x = .3 * ANNOTATION_FONTHEIGHT;
if (conn->endpoints[1].y < conn->endpoints[0].y)
diff --git a/objects/SADT/box.c b/objects/SADT/box.c
index e36eac96..7fdeac1c 100644
--- a/objects/SADT/box.c
+++ b/objects/SADT/box.c
@@ -500,7 +500,7 @@ sadtbox_create(Point *startpoint,
0.8, &p,
&color_black,
ALIGN_CENTER);
- dia_font_unref(font);
+ g_clear_object (&font);
box->id = g_strdup("A0"); /* should be made better.
Automatic counting ? */
diff --git a/objects/UML/activity.c b/objects/UML/activity.c
index 59f8554a..06191984 100644
--- a/objects/UML/activity.c
+++ b/objects/UML/activity.c
@@ -304,7 +304,7 @@ state_create_activity(Point *startpoint,
p.y += STATE_HEIGHT/2.0;
state->text = new_text("", font, 0.8, &p, &color_black, ALIGN_CENTER);
- dia_font_unref(font);
+ g_clear_object (&font);
element_init(elem, 8, NUM_CONNECTIONS);
for (i=0;i<NUM_CONNECTIONS;i++) {
diff --git a/objects/UML/actor.c b/objects/UML/actor.c
index 28829823..bb81d3d8 100644
--- a/objects/UML/actor.c
+++ b/objects/UML/actor.c
@@ -349,9 +349,9 @@ actor_create(Point *startpoint,
p.x += ACTOR_MARGIN_X;
p.y += ACTOR_HEIGHT - dia_font_descent(_("Actor"),font, 0.8);
- actor->text = new_text(_("Actor"),
- font, 0.8, &p, &color_black, ALIGN_CENTER);
- dia_font_unref(font);
+ actor->text = new_text (_("Actor"),
+ font, 0.8, &p, &color_black, ALIGN_CENTER);
+ g_clear_object (&font);
element_init(elem, 8, NUM_CONNECTIONS);
diff --git a/objects/UML/association.c b/objects/UML/association.c
index facbb5be..6ce949ff 100644
--- a/objects/UML/association.c
+++ b/objects/UML/association.c
@@ -899,7 +899,7 @@ association_destroy(Association *assoc)
int i;
orthconn_destroy(&assoc->orth);
- dia_font_unref(assoc->font);
+ g_clear_object (&assoc->font);
g_free(assoc->name);
for (i=0;i<2;i++) {
diff --git a/objects/UML/class.c b/objects/UML/class.c
index 4c1d2f69..7b06e828 100644
--- a/objects/UML/class.c
+++ b/objects/UML/class.c
@@ -1941,14 +1941,14 @@ umlclass_destroy(UMLClass *umlclass)
umlclass->destroyed = TRUE;
- dia_font_unref(umlclass->normal_font);
- dia_font_unref(umlclass->abstract_font);
- dia_font_unref(umlclass->polymorphic_font);
- dia_font_unref(umlclass->classname_font);
- dia_font_unref(umlclass->abstract_classname_font);
- dia_font_unref(umlclass->comment_font);
-
- element_destroy(¨class->element);
+ g_clear_object (¨class->normal_font);
+ g_clear_object (¨class->abstract_font);
+ g_clear_object (¨class->polymorphic_font);
+ g_clear_object (¨class->classname_font);
+ g_clear_object (¨class->abstract_classname_font);
+ g_clear_object (¨class->comment_font);
+
+ element_destroy (¨class->element);
g_free(umlclass->name);
g_free(umlclass->stereotype);
diff --git a/objects/UML/classicon.c b/objects/UML/classicon.c
index 1cc9b1b7..5ae0e812 100644
--- a/objects/UML/classicon.c
+++ b/objects/UML/classicon.c
@@ -451,7 +451,7 @@ classicon_create(Point *startpoint,
p.y = 0.0;
cicon->text = new_text("", font, 0.8, &p, &color_black, ALIGN_CENTER);
- dia_font_unref(font);
+ g_clear_object (&font);
element_init(elem, 8, NUM_CONNECTIONS);
diff --git a/objects/UML/component.c b/objects/UML/component.c
index 9c0a0f94..d4a6585f 100644
--- a/objects/UML/component.c
+++ b/objects/UML/component.c
@@ -409,11 +409,11 @@ component_create(Point *startpoint,
p.x += COMPONENT_CWIDTH + COMPONENT_MARGIN_X;
p.y += 2*COMPONENT_CHEIGHT;
- cmp->text = new_text("", font, 0.8, &p, &color_black, ALIGN_LEFT);
+ cmp->text = new_text ("", font, 0.8, &p, &color_black, ALIGN_LEFT);
- dia_font_unref(font);
+ g_clear_object (&font);
- element_init(elem, 8, NUM_CONNECTIONS);
+ element_init (elem, 8, NUM_CONNECTIONS);
for (i=0;i<NUM_CONNECTIONS;i++) {
obj->connections[i] = &cmp->connections[i];
diff --git a/objects/UML/component_feature.c b/objects/UML/component_feature.c
index b42c8fee..b50acf50 100644
--- a/objects/UML/component_feature.c
+++ b/objects/UML/component_feature.c
@@ -385,10 +385,12 @@ compfeat_create(Point *startpoint,
p.y -= COMPPROP_TEXTOFFSET;
compfeat->line_color = attributes_get_foreground();
- compfeat->text = new_text("", font,
- COMPPROP_FONTHEIGHT, &p, &compfeat->line_color,
- ALIGN_CENTER);
- dia_font_unref(font);
+ compfeat->text = new_text ("", font,
+ COMPPROP_FONTHEIGHT,
+ &p,
+ &compfeat->line_color,
+ ALIGN_CENTER);
+ g_clear_object (&font);
compfeat->text_handle.id = HANDLE_MOVE_TEXT;
compfeat->text_handle.type = HANDLE_MINOR_CONTROL;
diff --git a/objects/UML/constraint.c b/objects/UML/constraint.c
index b727044e..2d60fd97 100644
--- a/objects/UML/constraint.c
+++ b/objects/UML/constraint.c
@@ -335,12 +335,12 @@ constraint_create(Point *startpoint,
static void
-constraint_destroy(Constraint *constraint)
+constraint_destroy (Constraint *constraint)
{
- connection_destroy(&constraint->connection);
- dia_font_unref(constraint->font);
- g_free(constraint->brtext);
- g_free(constraint->text);
+ connection_destroy (&constraint->connection);
+ g_clear_object (&constraint->font);
+ g_free (constraint->brtext);
+ g_free (constraint->text);
}
static void
diff --git a/objects/UML/dependency.c b/objects/UML/dependency.c
index 3bc54e84..1849d409 100644
--- a/objects/UML/dependency.c
+++ b/objects/UML/dependency.c
@@ -443,13 +443,13 @@ dependency_create(Point *startpoint,
}
static void
-dependency_destroy(Dependency *dep)
+dependency_destroy (Dependency *dep)
{
- g_free(dep->name);
- g_free(dep->stereotype);
- g_free(dep->st_stereotype);
- dia_font_unref(dep->font);
- orthconn_destroy(&dep->orth);
+ g_free (dep->name);
+ g_free (dep->stereotype);
+ g_free (dep->st_stereotype);
+ g_clear_object (&dep->font);
+ orthconn_destroy (&dep->orth);
}
static DiaObject *
diff --git a/objects/UML/generalization.c b/objects/UML/generalization.c
index 76ff8800..62431a54 100644
--- a/objects/UML/generalization.c
+++ b/objects/UML/generalization.c
@@ -441,13 +441,13 @@ generalization_create(Point *startpoint,
}
static void
-generalization_destroy(Generalization *genlz)
+generalization_destroy (Generalization *genlz)
{
- g_free(genlz->name);
- g_free(genlz->stereotype);
- g_free(genlz->st_stereotype);
- dia_font_unref(genlz->font);
- orthconn_destroy(&genlz->orth);
+ g_free (genlz->name);
+ g_free (genlz->stereotype);
+ g_free (genlz->st_stereotype);
+ g_clear_object (&genlz->font);
+ orthconn_destroy (&genlz->orth);
}
static DiaObject *
diff --git a/objects/UML/implements.c b/objects/UML/implements.c
index 78676af4..d0601106 100644
--- a/objects/UML/implements.c
+++ b/objects/UML/implements.c
@@ -352,11 +352,11 @@ implements_create(Point *startpoint,
static void
-implements_destroy(Implements *implements)
+implements_destroy (Implements *implements)
{
- connection_destroy(&implements->connection);
- dia_font_unref(implements->font);
- g_free(implements->text);
+ connection_destroy (&implements->connection);
+ g_clear_object (&implements->font);
+ g_free (implements->text);
}
static void
diff --git a/objects/UML/large_package.c b/objects/UML/large_package.c
index f5d8d1e1..8a63f289 100644
--- a/objects/UML/large_package.c
+++ b/objects/UML/large_package.c
@@ -401,14 +401,14 @@ largepackage_create(Point *startpoint,
}
static void
-largepackage_destroy(LargePackage *pkg)
+largepackage_destroy (LargePackage *pkg)
{
- dia_font_unref(pkg->font);
- g_free(pkg->stereotype);
- g_free(pkg->st_stereotype);
- g_free(pkg->name);
+ g_clear_object (&pkg->font);
+ g_free (pkg->stereotype);
+ g_free (pkg->st_stereotype);
+ g_free (pkg->name);
- element_destroy(&pkg->element);
+ element_destroy (&pkg->element);
}
static DiaObject *
diff --git a/objects/UML/node.c b/objects/UML/node.c
index 0e42ed2a..a5475ab6 100644
--- a/objects/UML/node.c
+++ b/objects/UML/node.c
@@ -345,8 +345,8 @@ static DiaObject *node_create(Point *startpoint, void *user_data, Handle **handl
/* The text position is recalculated later */
p.x = 0.0;
p.y = 0.0;
- node->name = new_text("", font, NODE_FONTHEIGHT, &p, &color_black, ALIGN_LEFT);
- dia_font_unref(font);
+ node->name = new_text ("", font, NODE_FONTHEIGHT, &p, &color_black, ALIGN_LEFT);
+ g_clear_object (&font);
element_init(elem, 8, NUM_CONNECTIONS);
diff --git a/objects/UML/note.c b/objects/UML/note.c
index e29523d0..92e53090 100644
--- a/objects/UML/note.c
+++ b/objects/UML/note.c
@@ -319,8 +319,8 @@ note_create(Point *startpoint,
p.x += note->line_width/2.0 + NOTE_MARGIN_X;
p.y += note->line_width/2.0 + NOTE_CORNER + dia_font_ascent("A",font, 0.8);
- note->text = new_text("", font, 0.8, &p, &color_black, ALIGN_LEFT);
- dia_font_unref(font);
+ note->text = new_text ("", font, 0.8, &p, &color_black, ALIGN_LEFT);
+ g_clear_object (&font);
element_init(elem, 8, NUM_CONNECTIONS);
diff --git a/objects/UML/object.c b/objects/UML/object.c
index 7a656740..01efd9a4 100644
--- a/objects/UML/object.c
+++ b/objects/UML/object.c
@@ -493,9 +493,9 @@ objet_create(Point *startpoint,
ob->text = new_text("", font, 0.8, &p, &color_black, ALIGN_CENTER);
text_get_attributes(ob->text,&ob->text_attrs);
- dia_font_unref(font);
+ g_clear_object (&font);
- element_init(elem, 8, NUM_CONNECTIONS);
+ element_init (elem, 8, NUM_CONNECTIONS);
for (i=0;i<NUM_CONNECTIONS;i++) {
obj->connections[i] = &ob->connections[i];
diff --git a/objects/UML/realizes.c b/objects/UML/realizes.c
index 74b134ac..0ef45101 100644
--- a/objects/UML/realizes.c
+++ b/objects/UML/realizes.c
@@ -439,13 +439,13 @@ realizes_create(Point *startpoint,
}
static void
-realizes_destroy(Realizes *realize)
+realizes_destroy (Realizes *realize)
{
- g_free(realize->name);
- g_free(realize->stereotype);
- g_free(realize->st_stereotype);
- dia_font_unref(realize->font);
- orthconn_destroy(&realize->orth);
+ g_free (realize->name);
+ g_free (realize->stereotype);
+ g_free (realize->st_stereotype);
+ g_clear_object (&realize->font);
+ orthconn_destroy (&realize->orth);
}
static DiaObject *
diff --git a/objects/UML/small_package.c b/objects/UML/small_package.c
index 1a710142..c9ed63bf 100644
--- a/objects/UML/small_package.c
+++ b/objects/UML/small_package.c
@@ -359,10 +359,10 @@ smallpackage_create(Point *startpoint,
p.x += SMALLPACKAGE_MARGIN_X;
p.y += SMALLPACKAGE_MARGIN_Y+ dia_font_ascent("A",font, 0.8);
- pkg->text = new_text("", font, 0.8, &p, &color_black, ALIGN_LEFT);
- dia_font_unref(font);
+ pkg->text = new_text ("", font, 0.8, &p, &color_black, ALIGN_LEFT);
+ g_clear_object (&font);
- element_init(elem, 8, NUM_CONNECTIONS);
+ element_init (elem, 8, NUM_CONNECTIONS);
for (i=0;i<NUM_CONNECTIONS;i++) {
obj->connections[i] = &pkg->connections[i];
diff --git a/objects/UML/state.c b/objects/UML/state.c
index 6f09a3d1..7ca103fc 100644
--- a/objects/UML/state.c
+++ b/objects/UML/state.c
@@ -441,7 +441,7 @@ state_create(Point *startpoint,
state->text = new_text("", font, 0.8, &p, &color_black, ALIGN_CENTER);
- dia_font_unref(font);
+ g_clear_object (&font);
state->state_type = STATE_NORMAL;
element_init(elem, 8, NUM_CONNECTIONS);
diff --git a/objects/UML/usecase.c b/objects/UML/usecase.c
index fcad68f5..c71b5455 100644
--- a/objects/UML/usecase.c
+++ b/objects/UML/usecase.c
@@ -420,7 +420,7 @@ usecase_create(Point *startpoint,
p.y += USECASE_HEIGHT/2.0;
usecase->text = new_text("", font, 0.8, &p, &color_black, ALIGN_CENTER);
- dia_font_unref(font);
+ g_clear_object (&font);
usecase->text_outside = 0;
usecase->collaboration = 0;
diff --git a/objects/chronogram/chronoline.c b/objects/chronogram/chronoline.c
index 52e3c3c5..a9e8e2f0 100644
--- a/objects/chronogram/chronoline.c
+++ b/objects/chronogram/chronoline.c
@@ -668,14 +668,14 @@ chronoline_create(Point *startpoint,
}
static void
-chronoline_destroy(Chronoline *chronoline)
+chronoline_destroy (Chronoline *chronoline)
{
- g_free(chronoline->name);
- g_free(chronoline->events);
- dia_font_unref(chronoline->font);
- connpointline_destroy(chronoline->snap);
- destroy_clevent_list(chronoline->evtlist);
- element_destroy(&chronoline->element);
+ g_free (chronoline->name);
+ g_free (chronoline->events);
+ g_clear_object (&chronoline->font);
+ connpointline_destroy (chronoline->snap);
+ destroy_clevent_list (chronoline->evtlist);
+ element_destroy (&chronoline->element);
}
static DiaObject *
diff --git a/objects/chronogram/chronoref.c b/objects/chronogram/chronoref.c
index 4c474107..6d8be4fe 100644
--- a/objects/chronogram/chronoref.c
+++ b/objects/chronogram/chronoref.c
@@ -456,9 +456,9 @@ chronoref_create(Point *startpoint,
static void
chronoref_destroy(Chronoref *chronoref)
{
- dia_font_unref(chronoref->font);
- connpointline_destroy(chronoref->scale);
- element_destroy(&chronoref->element);
+ g_clear_object (&chronoref->font);
+ connpointline_destroy (chronoref->scale);
+ element_destroy (&chronoref->element);
}
static DiaObject *
diff --git a/objects/custom/custom_object.c b/objects/custom/custom_object.c
index 8d13e52a..bd9461d6 100644
--- a/objects/custom/custom_object.c
+++ b/objects/custom/custom_object.c
@@ -1621,7 +1621,7 @@ custom_create(Point *startpoint,
p.y += elem->height / 2.0 + font_height / 2;
custom->text = new_text("", font, font_height, &p, &custom->border_color,
info->text_align);
- dia_font_unref(font);
+ g_clear_object (&font);
/* _no_ new default: does not shrink with textbox automatically. */
custom->text_fitting = (info->resize_with_text ? TEXTFIT_WHEN_NEEDED : TEXTFIT_NEVER);
diff --git a/objects/custom/shape_info.c b/objects/custom/shape_info.c
index 9b28bedf..33993821 100644
--- a/objects/custom/shape_info.c
+++ b/objects/custom/shape_info.c
@@ -572,12 +572,14 @@ parse_svg_node(ShapeInfo *info, xmlNodePtr node, xmlNsPtr svg_ns,
}
if (el) {
el->any.s = s;
- if (el->any.s.font)
- el->any.s.font = g_object_ref(s.font);
- info->display_list = g_list_append(info->display_list, el);
+ if (el->any.s.font) {
+ el->any.s.font = g_object_ref (s.font);
+ }
+ info->display_list = g_list_append (info->display_list, el);
+ }
+ if (s.font) {
+ g_clear_object (&s.font);
}
- if (s.font)
- dia_font_unref (s.font);
}
}
diff --git a/objects/flowchart/box.c b/objects/flowchart/box.c
index b9071538..16a5b0b5 100644
--- a/objects/flowchart/box.c
+++ b/objects/flowchart/box.c
@@ -552,9 +552,9 @@ box_create(Point *startpoint,
p = *startpoint;
p.x += elem->width / 2.0;
p.y += elem->height / 2.0 + font_height / 2;
- box->text = new_text("", font, font_height, &p, &box->border_color,
- ALIGN_CENTER);
- dia_font_unref(font);
+ box->text = new_text ("", font, font_height, &p, &box->border_color,
+ ALIGN_CENTER);
+ g_clear_object (&font);
/* new default: let the user decide the size */
box->text_fitting = TEXTFIT_WHEN_NEEDED;
diff --git a/objects/flowchart/diamond.c b/objects/flowchart/diamond.c
index 65c89d88..778f7a89 100644
--- a/objects/flowchart/diamond.c
+++ b/objects/flowchart/diamond.c
@@ -520,9 +520,9 @@ diamond_create(Point *startpoint,
p = *startpoint;
p.x += elem->width / 2.0;
p.y += elem->height / 2.0 + font_height / 2;
- diamond->text = new_text("", font, font_height, &p, &diamond->border_color,
- ALIGN_CENTER);
- dia_font_unref(font);
+ diamond->text = new_text ("", font, font_height, &p, &diamond->border_color,
+ ALIGN_CENTER);
+ g_clear_object (&font);
/* new default: let the user decide the size */
diamond->text_fitting = TEXTFIT_WHEN_NEEDED;
diff --git a/objects/flowchart/ellipse.c b/objects/flowchart/ellipse.c
index c33ae9dd..46d790e9 100644
--- a/objects/flowchart/ellipse.c
+++ b/objects/flowchart/ellipse.c
@@ -494,9 +494,9 @@ ellipse_create(Point *startpoint,
p = *startpoint;
p.x += elem->width / 2.0;
p.y += elem->height / 2.0 + font_height / 2;
- ellipse->text = new_text("", font, font_height, &p, &ellipse->border_color,
- ALIGN_CENTER);
- dia_font_unref(font);
+ ellipse->text = new_text ("", font, font_height, &p, &ellipse->border_color,
+ ALIGN_CENTER);
+ g_clear_object (&font);
/* new default: let the user decide the size */
ellipse->text_fitting = TEXTFIT_WHEN_NEEDED;
diff --git a/objects/flowchart/parallelogram.c b/objects/flowchart/parallelogram.c
index 3e93bb36..e8b42e03 100644
--- a/objects/flowchart/parallelogram.c
+++ b/objects/flowchart/parallelogram.c
@@ -577,9 +577,9 @@ pgram_create(Point *startpoint,
p = *startpoint;
p.x += elem->width / 2.0;
p.y += elem->height / 2.0 + font_height / 2;
- pgram->text = new_text("", font, font_height, &p, &pgram->border_color,
- ALIGN_CENTER);
- dia_font_unref(font);
+ pgram->text = new_text ("", font, font_height, &p, &pgram->border_color,
+ ALIGN_CENTER);
+ g_clear_object (&font);
/* new default: let the user decide the size */
pgram->text_fitting = TEXTFIT_WHEN_NEEDED;
diff --git a/objects/network/basestation.c b/objects/network/basestation.c
index 9b120538..656434c8 100644
--- a/objects/network/basestation.c
+++ b/objects/network/basestation.c
@@ -388,7 +388,7 @@ basestation_create(Point *startpoint,
basestation->text = new_text(_("Base Station"),
font, 0.8, &p, &color_black, ALIGN_CENTER);
- dia_font_unref(font);
+ g_clear_object (&font);
basestation->line_colour = color_black;
basestation->fill_colour = color_white;
basestation->sectors = 3;
diff --git a/objects/network/radiocell.c b/objects/network/radiocell.c
index 98e4e231..82b44ebf 100644
--- a/objects/network/radiocell.c
+++ b/objects/network/radiocell.c
@@ -335,9 +335,9 @@ radiocell_create(Point *startpoint,
&radiocell->dashlength);
font = dia_font_new_from_style(DIA_FONT_MONOSPACE, RADIOCELL_FONTHEIGHT);
- radiocell->text = new_text("", font, RADIOCELL_FONTHEIGHT, startpoint,
- &color_black, ALIGN_CENTER);
- dia_font_unref(font);
+ radiocell->text = new_text ("", font, RADIOCELL_FONTHEIGHT, startpoint,
+ &color_black, ALIGN_CENTER);
+ g_clear_object (&font);
polyshape_init(poly, 6);
diff --git a/objects/standard/textobj.c b/objects/standard/textobj.c
index f7d5bff1..fc44f0b4 100644
--- a/objects/standard/textobj.c
+++ b/objects/standard/textobj.c
@@ -426,7 +426,7 @@ textobj_create(Point *startpoint,
/* need to initialize to object.position as well, it is used update data */
obj->position = *startpoint;
- dia_font_unref(font);
+ g_clear_object (&font);
textobj->vert_align = default_properties.vert_align;
/* default visibility must be off to keep compatibility */
@@ -510,9 +510,9 @@ textobj_load(ObjectNode obj_node, int version, DiaContext *ctx)
textobj->text = data_text(attribute_first_data(attr), ctx);
} else {
DiaFont* font = dia_font_new_from_style(DIA_FONT_MONOSPACE,1.0);
- textobj->text = new_text("", font, 1.0,
- &startpoint, &color_black, ALIGN_CENTER);
- dia_font_unref(font);
+ textobj->text = new_text ("", font, 1.0,
+ &startpoint, &color_black, ALIGN_CENTER);
+ g_clear_object (&font);
}
attr = object_find_attribute(obj_node, "valign");
diff --git a/plug-ins/cgm/cgm.c b/plug-ins/cgm/cgm.c
index 06be7a96..0a04b411 100644
--- a/plug-ins/cgm/cgm.c
+++ b/plug-ins/cgm/cgm.c
@@ -684,9 +684,8 @@ set_font (DiaRenderer *self, DiaFont *font, real height)
CgmRenderer *renderer = CGM_RENDERER(self);
DiaFont *oldfont = renderer->font;
- renderer->font = dia_font_ref(font);
- if (oldfont != NULL)
- dia_font_unref(oldfont);
+ renderer->font = g_object_ref (font);
+ g_clear_object (&oldfont);
renderer->tcurrent.font_num = FONT_NUM (font);
renderer->tcurrent.font_height = height;
}
@@ -1206,11 +1205,10 @@ export_cgm(DiagramData *data, DiaContext *ctx,
init_attributes(renderer);
- data_render(data, DIA_RENDERER(renderer), NULL, NULL, NULL);
+ data_render (data, DIA_RENDERER(renderer), NULL, NULL, NULL);
- if (renderer->font != NULL)
- dia_font_unref(renderer->font);
- g_object_unref(renderer);
+ g_clear_object (&renderer->font);
+ g_object_unref (renderer);
return TRUE;
}
diff --git a/plug-ins/drs/dia-render-script-import.c b/plug-ins/drs/dia-render-script-import.c
index d2235cc5..bd4aa2ab 100644
--- a/plug-ins/drs/dia-render-script-import.c
+++ b/plug-ins/drs/dia-render-script-import.c
@@ -282,7 +282,7 @@ _render_object (xmlNodePtr render, DiaContext *ctx)
} else if (xmlStrcmp (node->name, (const xmlChar *) "set-font") == 0) {
DiaFont *font = _parse_font (node);
dia_renderer_set_font (ir, font, _parse_real (node, "height"));
- dia_font_unref (font);
+ g_clear_object (&font);
} else {
Color *stroke = _parse_color (node, "stroke");
Color *fill = _parse_color (node, "fill");
diff --git a/plug-ins/pdf/pdf-import.cpp b/plug-ins/pdf/pdf-import.cpp
index 8e784d1b..9abb8d10 100644
--- a/plug-ins/pdf/pdf-import.cpp
+++ b/plug-ins/pdf/pdf-import.cpp
@@ -48,7 +48,7 @@
*
* The PDF import plug-in is built on http://poppler.freedesktop.org/ library.
* It is currently considered experimental because it has no means of
- * limiting the input to something Dia can really cope with.
+ * limiting the input to something Dia can really cope with.
*/
/*!
@@ -79,7 +79,7 @@ public :
GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data),
void *annotDisplayDecideCbkData)
{
- PDFRectangle *mediaBox = page->getMediaBox();
+ PDFRectangle *mediaBox = page->getMediaBox();
PDFRectangle *clipBox = page->getCropBox ();
if (page->isOk()) {
@@ -144,13 +144,13 @@ public :
updateLineWidth(state);
}
- //!
+ //!
void updateLineWidth(GfxState *state)
{
this->line_width = state->getLineWidth() * scale;
}
void updateLineDash(GfxState * state)
- {
+ {
double *dashPattern;
int dashLength;
double dashStart;
@@ -198,9 +198,9 @@ public :
this->stroke_color.blue = colToDbl(color.b);
}
void updateStrokeOpacity(GfxState *state)
- {
+ {
this->stroke_color.alpha = state->getStrokeOpacity();
- }
+ }
void updateFillColor(GfxState *state)
{
GfxRGB color;
@@ -216,7 +216,7 @@ public :
this->fill_color.blue = colToDbl(color.b);
}
void updateFillOpacity(GfxState *state)
- {
+ {
this->fill_color.alpha = state->getFillOpacity();
}
//! gradients are just emulated - but not if returning false here
@@ -260,7 +260,7 @@ public :
x0 + tMin * dx, y0 + tMin * dy);
dia_pattern_set_point (this->pattern, x0 + tMax * dx, y0 + tMax * dy);
// continue with updateFillColorStop calls
- // although wasteful, because Poppler samples these to 256 entries
+ // although wasteful, because Poppler samples these to 256 entries
return gFalse;
}
GBool radialShadedSupportExtend(GfxState *state, GfxRadialShading *shading)
@@ -290,7 +290,7 @@ public :
dia_pattern_set_radius (this->pattern, r0 + sMax * dr);
dia_pattern_set_point (this->pattern, x0 + sMin * dx, y0 + sMin * dy);
// continue with updateFillColorStop calls
- // although wasteful, because Poppler samples these to 256 entries
+ // although wasteful, because Poppler samples these to 256 entries
return gFalse;
}
void updateBlendMode(GfxState *state)
@@ -302,7 +302,7 @@ public :
void updateFont(GfxState * state)
{
DiaFont *font;
-
+
// without a font it wont make sense
if (!state->getFont())
return;
@@ -391,7 +391,7 @@ public :
void drawImage(GfxState *state, Object *ref, Stream *str,
int width, int height, GfxImageColorMap *colorMap,
GBool interpolate, int *maskColors, GBool inlineImg);
-
+
//! everything on a single page it put into a Dia Group
void startPage(int pageNum, GfxState *state)
{
@@ -492,7 +492,7 @@ DiaOutputDev::DiaOutputDev (DiagramData *_dia, int _n) :
pattern(NULL)
{
font_map = g_hash_table_new_full(g_direct_hash, g_direct_equal,
- NULL, (GDestroyNotify)dia_font_unref);
+ NULL, (GDestroyNotify) g_object_unref);
matrix.xx = matrix.yy = 1.0;
matrix.yx = matrix.xy = 0.0;
matrix.x0 = matrix.y0 = 0.0;
@@ -525,7 +525,7 @@ _path_lineto (GArray *path, const Point *pt)
g_array_append_val (path, bp);
}
-bool
+bool
DiaOutputDev::doPath (GArray *points, GfxState *state, GfxPath *path, bool &haveClose)
{
int i, j;
@@ -661,7 +661,7 @@ DiaOutputDev::_fill (GfxState *state, bool winding)
}
g_array_free (points, TRUE);
if (obj) {
- // Useful for debugging but high performance penalty
+ // Useful for debugging but high performance penalty
// dia_object_set_meta (obj, "fill-rule", winding ? "winding" : "even-odd");
addObject (obj);
}
@@ -696,7 +696,7 @@ DiaOutputDev::eoFill (GfxState *state)
*
* \todo Check alignment options - it's just guessed yet.
*/
-void
+void
DiaOutputDev::drawString(GfxState *state, GooString *s)
{
Color text_color = this->fill_color;
@@ -722,7 +722,7 @@ DiaOutputDev::drawString(GfxState *state, GooString *s)
CharCode code;
int j = 0, m, n;
utf8 = g_new (gchar, len * 6 + 1);
- Unicode *u;
+ Unicode *u;
int uLen;
double dx, dy, ox, oy;
@@ -752,7 +752,7 @@ DiaOutputDev::drawString(GfxState *state, GooString *s)
obj = create_standard_text (ty * scale, tx * scale);
//not applyStyle (obj, TEXT);
GPtrArray *plist = g_ptr_array_new ();
- // the "text" property is special, it must be initialized with text
+ // the "text" property is special, it must be initialized with text
// attributes, too. So here it comes first to avoid overwriting
// the other values with defaults.
prop_list_add_text (plist, "text", utf8);
@@ -839,7 +839,7 @@ DiaOutputDev::drawImage(GfxState *state, Object *ref, Stream *str,
g_hash_table_insert (this->image_cache, str, g_object_ref (pixbuf));
}
#endif
- obj = create_standard_image (pos.x, pos.y,
+ obj = create_standard_image (pos.x, pos.y,
ctm[0] * scale,
ctm[3] * scale, NULL);
if ((change = dia_object_set_pixbuf (obj, pixbuf)) != NULL) {
diff --git a/plug-ins/postscript/diapsrenderer.c b/plug-ins/postscript/diapsrenderer.c
index 8d7d0073..6e0ea9d0 100644
--- a/plug-ins/postscript/diapsrenderer.c
+++ b/plug-ins/postscript/diapsrenderer.c
@@ -142,10 +142,7 @@ end_render (DiaRenderer *self)
fprintf (renderer->file, "showpage\n");
}
- if (renderer->font != NULL) {
- dia_font_unref (renderer->font);
- renderer->font = NULL;
- }
+ g_clear_object (&renderer->font);
}
static void
@@ -292,10 +289,8 @@ set_font (DiaRenderer *self, DiaFont *font, real height)
psrenderer_dtostr (h_buf, (gdouble) height*0.7));
old_font = renderer->font;
renderer->font = font;
- dia_font_ref (renderer->font);
- if (old_font != NULL) {
- dia_font_unref (old_font);
- }
+ g_object_ref (renderer->font);
+ g_clear_object (&old_font);
renderer->font_height = height;
}
}
diff --git a/plug-ins/python/pydia-diagramdata.c b/plug-ins/python/pydia-diagramdata.c
index 2ce388e2..cbb25748 100644
--- a/plug-ins/python/pydia-diagramdata.c
+++ b/plug-ins/python/pydia-diagramdata.c
@@ -180,7 +180,7 @@ PyDiaDiagramData_DeleteLayer(PyDiaDiagramData *self, PyObject *args)
return NULL;
data_remove_layer (self->data, layer->layer);
- dia_layer_destroy (layer->layer);
+ g_clear_object (&layer->layer);
layer->layer = NULL;
Py_INCREF (Py_None);
return Py_None;
diff --git a/plug-ins/python/pydia-font.c b/plug-ins/python/pydia-font.c
index ce33f648..23e5e08e 100644
--- a/plug-ins/python/pydia-font.c
+++ b/plug-ins/python/pydia-font.c
@@ -30,27 +30,28 @@
PyObject* PyDiaFont_New (DiaFont* font)
{
PyDiaFont *self;
-
+
self = PyObject_NEW(PyDiaFont, &PyDiaFont_Type);
if (!self) return NULL;
- if (font)
- self->font = dia_font_ref (font);
- else
+ if (font) {
+ self->font = g_object_ref (font);
+ } else {
self->font = NULL;
+ }
- return (PyObject *)self;
+ return (PyObject *) self;
}
/*
* Dealloc
*/
static void
-PyDiaFont_Dealloc(PyDiaFont *self)
+PyDiaFont_Dealloc (PyDiaFont *self)
{
- if (self->font)
- dia_font_unref (self->font);
- PyObject_DEL(self);
+ g_clear_object (&self->font);
+
+ PyObject_DEL (self);
}
/*
@@ -69,7 +70,7 @@ PyDiaFont_Compare(PyDiaFont *self,
else if (!other->font)
return -1;
- ret = strcmp (dia_font_get_family (self->font),
+ ret = strcmp (dia_font_get_family (self->font),
dia_font_get_family (other->font));
if (ret != 0)
return ret;
diff --git a/plug-ins/python/pydia-layer.c b/plug-ins/python/pydia-layer.c
index b0c1f75b..025f0f38 100644
--- a/plug-ins/python/pydia-layer.c
+++ b/plug-ins/python/pydia-layer.c
@@ -70,9 +70,10 @@ PyDiaLayer_Str(PyDiaLayer *self)
static PyObject *
PyDiaLayer_Destroy (PyDiaLayer *self, PyObject *args)
{
- if (!PyArg_ParseTuple(args, ":Layer.destroy"))
+ if (!PyArg_ParseTuple (args, ":Layer.destroy"))
return NULL;
- dia_layer_destroy (self->layer);
+
+ g_clear_object (&self->layer);
self->layer = NULL; /* we need some error checking elsewhere */
Py_INCREF (Py_None);
return Py_None;
diff --git a/plug-ins/svg/svg-import.c b/plug-ins/svg/svg-import.c
index b2872203..56ba4eae 100644
--- a/plug-ins/svg/svg-import.c
+++ b/plug-ins/svg/svg-import.c
@@ -546,9 +546,8 @@ apply_style(DiaObject *obj, xmlNodePtr node, DiaSvgStyle *parent_style,
obj->ops->set_props(obj, props);
- if (gs->font)
- dia_font_unref (gs->font);
- g_free(gs);
+ g_clear_object (&gs->font);
+ g_free (gs);
}
/*!
@@ -818,14 +817,14 @@ read_text_svg(xmlNodePtr node, DiaSvgStyle *parent_style,
prop->attr.position.y = point.y;
/* FIXME: looks like a leak but without this an imported svg is
* crashing on release */
- prop->attr.font = dia_font_ref (gs->font);
+ prop->attr.font = g_object_ref (gs->font);
if (font_height > 0.0) {
- /* font-size should be the line-height according to SVG spec,
- * but see node_set_text_style() - round-trip first */
- real font_scale = dia_font_get_height (prop->attr.font) / dia_font_get_size (prop->attr.font);
+ /* font-size should be the line-height according to SVG spec,
+ * but see node_set_text_style() - round-trip first */
+ real font_scale = dia_font_get_height (prop->attr.font) / dia_font_get_size (prop->attr.font);
prop->attr.height = font_height * font_scale;
} else {
- prop->attr.height = gs->font_height;
+ prop->attr.height = gs->font_height;
}
/* when operating with default values foreground and background are intentionally swapped
* to avoid getting white text by default */
@@ -847,14 +846,13 @@ read_text_svg(xmlNodePtr node, DiaSvgStyle *parent_style,
break;
}
new_obj->ops->set_props(new_obj, props);
- prop_list_free(props);
+ prop_list_free (props);
if (matrix)
- _transform_object (new_obj, matrix, ctx);
+ _transform_object (new_obj, matrix, ctx);
}
- if (gs->font)
- dia_font_unref (gs->font);
- g_free(gs);
- g_free(matrix);
+ g_clear_object (&gs->font);
+ g_free (gs);
+ g_free (matrix);
return list;
}
@@ -1587,8 +1585,7 @@ read_items (xmlNodePtr startnode,
/* remember for meta */
obj = group;
}
- if (group_gs->font)
- dia_font_unref (group_gs->font);
+ g_clear_object (&group_gs->font);
g_free (group_gs);
g_free (matrix);
} else if (!xmlStrcmp(node->name, (const xmlChar *)"symbol")) {
diff --git a/plug-ins/wpg/wpg-import.c b/plug-ins/wpg/wpg-import.c
index e52f7659..75105f1f 100644
--- a/plug-ins/wpg/wpg-import.c
+++ b/plug-ins/wpg/wpg-import.c
@@ -464,7 +464,7 @@ _do_textstyle (WpgImportRenderer *ren, WPGTextStyle *ts)
dia_renderer_set_font (DIA_RENDERER (ren), font, height);
- dia_font_unref (font);
+ g_clear_object (&font);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]