Make gswe_antiscion_axis_info_free() to unref its start_sign

This is to fix a bug that makes the library crash when the timestamp
or the chart changes.
This commit is contained in:
Gergely Polonkai 2014-03-15 18:38:27 +01:00
parent e23c789ff0
commit 41a80ca365
5 changed files with 23 additions and 10 deletions

View File

@ -39,6 +39,10 @@ gswe_antiscion_axis_info_free(GsweAntiscionAxisInfo *antiscion_axis_info)
g_free(antiscion_axis_info->name);
}
if (antiscion_axis_info->start_sign != NULL) {
gswe_sign_info_unref(antiscion_axis_info->start_sign);
}
g_free(antiscion_axis_info);
}

View File

@ -128,7 +128,9 @@ void
gswe_antiscion_data_calculate(GsweAntiscionData *antiscion_data)
{
if ((antiscion_data->antiscion_axis_info = g_hash_table_find(gswe_antiscion_axis_info_table, (GHRFunc)find_antiscion, antiscion_data)) == NULL) {
antiscion_data->antiscion_axis_info = g_hash_table_lookup(gswe_antiscion_axis_info_table, GINT_TO_POINTER(GSWE_ANTISCION_AXIS_NONE));
antiscion_data->antiscion_axis_info = gswe_antiscion_axis_info_ref(g_hash_table_lookup(gswe_antiscion_axis_info_table, GINT_TO_POINTER(GSWE_ANTISCION_AXIS_NONE)));
} else {
gswe_antiscion_axis_info_ref(antiscion_data->antiscion_axis_info);
}
}
@ -148,8 +150,8 @@ gswe_antiscion_data_new_with_planets(GswePlanetData *planet1, GswePlanetData *pl
GsweAntiscionData *ret;
ret = gswe_antiscion_data_new();
ret->planet1 = planet1;
ret->planet2 = planet2;
ret->planet1 = gswe_planet_data_ref(planet1);
ret->planet2 = gswe_planet_data_ref(planet2);
gswe_antiscion_data_calculate(ret);

View File

@ -93,6 +93,8 @@ gswe_aspect_data_calculate(GsweAspectData *aspect_data)
if ((aspect_data->aspect_info = g_hash_table_find(gswe_aspect_info_table, (GHRFunc)find_aspect, aspect_data)) == NULL) {
aspect_data->aspect_info = gswe_aspect_info_ref(g_hash_table_lookup(gswe_aspect_info_table, GINT_TO_POINTER(GSWE_ASPECT_NONE)));
} else {
gswe_aspect_info_ref(aspect_data->aspect_info);
}
}

View File

@ -630,10 +630,10 @@ gswe_moment_add_planet(GsweMoment *moment, GswePlanet planet, GError **err)
}
planet_data = gswe_planet_data_new();
planet_data->planet_info = planet_info;
planet_data->planet_info = gswe_planet_info_ref(planet_info);
planet_data->revision = 0;
moment->priv->planet_list = g_list_append(moment->priv->planet_list, planet_data);
moment->priv->planet_list = g_list_append(moment->priv->planet_list, gswe_planet_data_ref(planet_data));
}
static void

View File

@ -52,7 +52,8 @@ static gboolean gswe_initializing = FALSE;
(v)->orb = (o); \
(v)->name = g_strdup(n); \
(v)->points = (h); \
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v));
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v)); \
gswe_planet_info_ref((v));
#define ADD_SIGN(ht, v, s, n, e, q) \
(v) = gswe_sign_info_new(); \
@ -60,14 +61,16 @@ static gboolean gswe_initializing = FALSE;
(v)->name = g_strdup(n); \
(v)->element = (e); \
(v)->quality = (q); \
g_hash_table_replace((ht), GINT_TO_POINTER(s), (v));
g_hash_table_replace((ht), GINT_TO_POINTER(s), (v)); \
gswe_sign_info_ref((v));
#define ADD_HOUSE_SYSTEM(ht, v, i, s, n) \
(v) = gswe_house_system_info_new(); \
(v)->house_system = i; \
(v)->sweph_id = s; \
(v)->name = g_strdup(n); \
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v));
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v)); \
gswe_house_system_info_ref((v));
#define ADD_ASPECT(ht, v, i, n, s, o, h, m) \
(v) = gswe_aspect_info_new(); \
@ -77,7 +80,8 @@ static gboolean gswe_initializing = FALSE;
(v)->orb_modifier = (o); \
(v)->harmonic = (h); \
(v)->major = (m); \
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v));
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v)); \
gswe_aspect_info_ref((v));
#define ADD_ANTISCION(ht, v, hts, vs, i, n, s, m) \
(v) = gswe_antiscion_axis_info_new(); \
@ -86,7 +90,8 @@ static gboolean gswe_initializing = FALSE;
(v)->start_sign = (vs); \
(v)->name = g_strdup(n); \
(v)->sign_offset = m; \
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v));
g_hash_table_replace((ht), GINT_TO_POINTER(i), (v)); \
gswe_antiscion_axis_info_ref((v));
/**
* gswe_error_quark: