Deprecated G_TYPE_INSTANCE_GET_PRIVATE in vcl/unx/gtk/gloactiongroup.cxx

Stephan Bergmann sbergman at redhat.com
Thu Sep 26 10:11:59 UTC 2019


Ever since 
<https://gerrit.libreoffice.org/plugins/gitiles/core/+/36c1c2c2754dda6e8d2b2802e3881465adaafbec%5E!/> 
"Added GLOMenu and GLOActionGroup. Menu is published with actions (not 
working)", g_lo_action_group_init in vcl/unx/gtk/gloactiongroup.cxx 
contains a call

>     group->priv = G_TYPE_INSTANCE_GET_PRIVATE (group,
>                                                  G_TYPE_LO_ACTION_GROUP,
>                                                  GLOActionGroupPrivate);

that GLib 2.62 (as seen on Fedora 31) now warns about:

> [CXX] vcl/unx/gtk3/gtk3gloactiongroup.cxx
> In file included from vcl/unx/gtk3/gtk3gloactiongroup.cxx:3:
> vcl/unx/gtk3/../gtk/gloactiongroup.cxx:317:19: warning: G_ADD_PRIVATE [-W#pragma-messages]
>     group->priv = G_TYPE_INSTANCE_GET_PRIVATE (group,
>                   ^
> /usr/include/glib-2.0/gobject/gtype.h:643:145: note: expanded from macro 'G_TYPE_INSTANCE_GET_PRIVATE'
> #define G_TYPE_INSTANCE_GET_PRIVATE(instance, g_type, c_type)   ((c_type*) g_type_instance_get_private ((GTypeInstance*) (instance), (g_type))) GLIB_DEPRECATED_MACRO_IN_2_58_FOR(G_ADD_PRIVATE)
>                                                                                                                                                 ^
> /usr/include/glib-2.0/glib/gversionmacros.h:831:49: note: expanded from macro 'GLIB_DEPRECATED_MACRO_IN_2_58_FOR'
> # define GLIB_DEPRECATED_MACRO_IN_2_58_FOR(f)   GLIB_DEPRECATED_MACRO_FOR(f)
>                                                 ^
> /usr/include/glib-2.0/glib/gmacros.h:990:38: note: expanded from macro 'GLIB_DEPRECATED_MACRO_FOR'
> #define GLIB_DEPRECATED_MACRO_FOR(f) _GLIB_GNUC_DO_PRAGMA(GCC warning #f)
>                                      ^
> /usr/include/glib-2.0/glib/gmacros.h:988:33: note: expanded from macro '_GLIB_GNUC_DO_PRAGMA'
> #define _GLIB_GNUC_DO_PRAGMA(x) _Pragma(G_STRINGIFY (x))
>                                 ^
> <scratch space>:57:6: note: expanded from here
>  GCC warning "G_ADD_PRIVATE"
>      ^
> 1 warning generated.

(And while Clang keeps that a warning even with -Werror, it causes a 
true error breaking the build when building with GCC and --enable-werror.)

<https://developer.gnome.org/gobject/stable/gobject-Type-Information.html#G-TYPE-INSTANCE-GET-PRIVATE:CAPS> 
states:  "G_TYPE_INSTANCE_GET_PRIVATE has been deprecated since version 
2.58 and should not be used in newly-written code.  Use G_ADD_PRIVATE 
and the generated your_type_get_instance_private() function instead"

But I have no idea how to fix that.  So if anybody can clean it up, that 
would be great.  (Failing that, we can always add a sledgehammer

> #define GLIB_DISABLE_DEPRECATION_WARNINGS

near the top of vcl/unx/gtk/gloactiongroup.cxx, similar to what is done 
in 
<https://gerrit.libreoffice.org/plugins/gitiles/core/+/59f96e1736c14575aee7575e73b50e96cf467bb0%5E!/> 
"While I could swear that it worked yesterday".)



More information about the LibreOffice mailing list