[LIBREPORT PATCH rebase] add helper function for GLib initialization

Jiri Moskovcak jmoskovc at redhat.com
Wed Jul 24 14:07:45 UTC 2013


- pushed

On 07/24/2013 12:50 PM, Jakub Filak wrote:
> Related to rhbz#927919
>
> Signed-off-by: Jakub Filak <jfilak at redhat.com>
> ---
>   src/include/internal_libreport.h |  5 +++++
>   src/lib/glib_support.c           | 32 ++++++++++++++++++++++++++++++++
>   2 files changed, 37 insertions(+)
>
> diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
> index afedc73..8eca093 100644
> --- a/src/include/internal_libreport.h
> +++ b/src/include/internal_libreport.h
> @@ -281,6 +281,11 @@ bool is_in_comma_separated_list(const char *value, const char *list);
>   #define is_in_comma_separated_list_of_glob_patterns libreport_is_in_comma_separated_list_of_glob_patterns
>   bool is_in_comma_separated_list_of_glob_patterns(const char *value, const char *list);
>
> +/* Calls GLib version appropriate initialization function.
> + */
> +#define glib_init libreport_glib_init
> +void glib_init(void);
> +
>   /* Frees every element'd data using free(),
>    * then frees list itself using g_list_free(list):
>    */
> diff --git a/src/lib/glib_support.c b/src/lib/glib_support.c
> index 75f8376..d98c690 100644
> --- a/src/lib/glib_support.c
> +++ b/src/lib/glib_support.c
> @@ -17,9 +17,41 @@
>       51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
>   */
>   #include "internal_libreport.h"
> +#include <glib-object.h>
>
>   #define LIST_DELIMITER ","
>
> +void glib_init(void)
> +{
> +#if (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION < 35)
> +    /* Became deprecated in glib-2.35.1 (branch 2.36 commit df02fa1e4cc61a2c7f3aafdf1a6534a831f1c0d6) */
> +    g_type_init();
> +#endif
> +
> +    /* This is not necessary but is IMO is good to know that:
> +     *
> +     * If want to be defensive and ensure we're linked to GObject
> +     * call the following function [1]:
> +     *
> +     * g_type_ensure(G_TYPE_OBJECT);
> +     *
> +     *
> +     * See glib README -> Notes about GLib 2.36, 1st paragraph
> +     *
> +     * 1: https://bugzilla.gnome.org/show_bug.cgi?id=691077
> +     */
> +
> +    /* Help with mysterious bug */
> +    if (g_verbose > 0)
> +    {
> +        const gchar *version_mismatch = glib_check_version(GLIB_MAJOR_VERSION,
> +                                                           GLIB_MINOR_VERSION,
> +                                                           GLIB_MICRO_VERSION);
> +        if (version_mismatch != NULL)
> +            log("Running GLib incompatible version: %s", version_mismatch);
> +    }
> +}
> +
>   /*
>    * Parser comma separated list of strings to Glist
>    *
>



More information about the Crash-catcher mailing list