From c26eabcd474a2cd1de9237267eb948c233318adb Mon Sep 17 00:00:00 2001 From: Nicola Fontana Date: Mon, 25 Mar 2019 10:30:44 +0100 Subject: [PATCH] adg: avoid invalid access to private data Use the API and avoid accessing AdgEntityPrivate outside of AdgEntity code. This will make refactoring of private code much easier. --- src/adg/adg-arrow.c | 7 +------ src/adg/adg-table.c | 7 +------ src/adg/adg-text.c | 7 +------ src/adg/adg-toy-text.c | 7 +------ 4 files changed, 4 insertions(+), 24 deletions(-) diff --git a/src/adg/adg-arrow.c b/src/adg/adg-arrow.c index 41d7a18d..4b6417b1 100644 --- a/src/adg/adg-arrow.c +++ b/src/adg/adg-arrow.c @@ -48,7 +48,6 @@ #include "adg-trail.h" #include "adg-path.h" #include "adg-marker.h" -#include "adg-entity-private.h" #include "adg-arrow.h" #include "adg-arrow-private.h" @@ -112,16 +111,12 @@ adg_arrow_init(AdgArrow *arrow) AdgArrowPrivate *data = G_TYPE_INSTANCE_GET_PRIVATE(arrow, ADG_TYPE_ARROW, AdgArrowPrivate); - AdgEntityPrivate *entity_data = ((AdgEntity *) arrow)->data; data->angle = G_PI/6; arrow->data = data; - /* Initialize to custom default some AdgEntity field by directly - * accessing the private struct to avoid notify signal emissions - */ - entity_data->local_mix = ADG_MIX_PARENT; + adg_entity_set_local_mix((AdgEntity *) arrow, ADG_MIX_PARENT); } static void diff --git a/src/adg/adg-table.c b/src/adg/adg-table.c index f7fd2f08..f0df3b81 100644 --- a/src/adg/adg-table.c +++ b/src/adg/adg-table.c @@ -56,7 +56,6 @@ #include "adg-stroke.h" #include "adg-container.h" #include "adg-alignment.h" -#include "adg-entity-private.h" #include "adg-dress.h" #include "adg-param-dress.h" @@ -164,7 +163,6 @@ adg_table_init(AdgTable *table) AdgTablePrivate *data = G_TYPE_INSTANCE_GET_PRIVATE(table, ADG_TYPE_TABLE, AdgTablePrivate); - AdgEntityPrivate *entity_data = ((AdgEntity *) table)->data; data->table_dress = ADG_DRESS_TABLE; data->has_frame = TRUE; @@ -177,10 +175,7 @@ adg_table_init(AdgTable *table) table->data = data; - /* Initialize to custom default some AdgEntity field by directly - * accessing the private struct to avoid notify signal emissions - */ - entity_data->local_mix = ADG_MIX_DISABLED; + adg_entity_set_local_mix((AdgEntity *) table, ADG_MIX_DISABLED); } static void diff --git a/src/adg/adg-text.c b/src/adg/adg-text.c index 6fc48ce5..0df0d43e 100644 --- a/src/adg/adg-text.c +++ b/src/adg/adg-text.c @@ -54,7 +54,6 @@ #include "adg-font-style.h" #include "adg-pango-style.h" #include "adg-textual.h" -#include "adg-entity-private.h" #include "adg-text.h" #include "adg-text-private.h" @@ -144,7 +143,6 @@ adg_text_init(AdgText *text) { AdgTextPrivate *data = G_TYPE_INSTANCE_GET_PRIVATE(text, ADG_TYPE_TEXT, AdgTextPrivate); - AdgEntityPrivate *entity_data = ((AdgEntity *) text)->data; data->font_dress = ADG_DRESS_FONT_TEXT; data->text = NULL; @@ -152,10 +150,7 @@ adg_text_init(AdgText *text) text->data = data; - /* Initialize to custom default some AdgEntity field by directly - * accessing the private struct to avoid notify signal emissions - */ - entity_data->local_mix = ADG_MIX_ANCESTORS_NORMALIZED; + adg_entity_set_local_mix((AdgEntity *) text, ADG_MIX_ANCESTORS_NORMALIZED); } static void diff --git a/src/adg/adg-toy-text.c b/src/adg/adg-toy-text.c index 3a25d288..95cd20c4 100644 --- a/src/adg/adg-toy-text.c +++ b/src/adg/adg-toy-text.c @@ -50,7 +50,6 @@ #include "adg-style.h" #include "adg-font-style.h" #include "adg-textual.h" -#include "adg-entity-private.h" #include "adg-toy-text.h" #include "adg-toy-text-private.h" @@ -139,7 +138,6 @@ adg_toy_text_init(AdgToyText *toy_text) AdgToyTextPrivate *data = G_TYPE_INSTANCE_GET_PRIVATE(toy_text, ADG_TYPE_TOY_TEXT, AdgToyTextPrivate); - AdgEntityPrivate *entity_data = ((AdgEntity *) toy_text)->data; data->font_dress = ADG_DRESS_FONT_TEXT; data->text = NULL; @@ -147,10 +145,7 @@ adg_toy_text_init(AdgToyText *toy_text) toy_text->data = data; - /* Initialize to custom default some AdgEntity field by directly - * accessing the private struct to avoid notify signal emissions - */ - entity_data->local_mix = ADG_MIX_ANCESTORS_NORMALIZED; + adg_entity_set_local_mix((AdgEntity *) toy_text, ADG_MIX_ANCESTORS_NORMALIZED); } static void -- 2.11.4.GIT