From 367b777a2d715d4ffa2c33f35083397d1cf89e54 Mon Sep 17 00:00:00 2001 From: "Gergely Polonkai (W00d5t0ck)" Date: Sat, 5 Oct 2013 02:18:30 +0200 Subject: [PATCH] Initialize SWE-GLib from each class init function This is to satisfy #8. Also, this makes SWE-GLib available for GLib before 2.36, as gswe_init() also calls g_type_init(), which was necessary before GLib 2.36 --- src/gswe-enumtypes.c.template | 3 +++ src/gswe-timestamp.c | 8 +++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gswe-enumtypes.c.template b/src/gswe-enumtypes.c.template index cdd55e5..d20e822 100644 --- a/src/gswe-enumtypes.c.template +++ b/src/gswe-enumtypes.c.template @@ -16,6 +16,7 @@ * You should have received a copy of the GNU General Public License * along with this library; if not, see . */ +#include "swe-glib.h" #include "gswe-enumtypes.h" #include "@filename@" @@ -31,6 +32,8 @@ GType { static volatile gsize g_define_type_id__volatile = 0; + gswe_init(); + if (g_once_init_enter(&g_define_type_id__volatile)) { static const G@Type@Value values[] = { /*** END value-header ***/ diff --git a/src/gswe-timestamp.c b/src/gswe-timestamp.c index 192f88e..33129b5 100644 --- a/src/gswe-timestamp.c +++ b/src/gswe-timestamp.c @@ -865,6 +865,8 @@ gswe_timestamp_get_julian_day(GsweTimestamp *timestamp, GError **err) GsweTimestamp * gswe_timestamp_new(void) { + gswe_init(); + return GSWE_TIMESTAMP(g_object_new(GSWE_TYPE_TIMESTAMP, NULL)); } @@ -886,7 +888,11 @@ gswe_timestamp_new(void) GsweTimestamp * gswe_timestamp_new_from_gregorian_full(gint year, gint month, gint day, gint hour, gint minute, gint second, gint microsecond, gdouble time_zone_offset) { - GsweTimestamp *timestamp = GSWE_TIMESTAMP(g_object_new(GSWE_TYPE_TIMESTAMP, + GsweTimestamp *timestamp; + + gswe_init(); + + timestamp = GSWE_TIMESTAMP(g_object_new(GSWE_TYPE_TIMESTAMP, "gregorian-year", year, "gregorian-month", month, "gregorian-day", day,