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

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

Ever since 
"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'
>                                                 ^
> /usr/include/glib-2.0/glib/gmacros.h:990:38: note: expanded from macro 'GLIB_DEPRECATED_MACRO_FOR'
>                                      ^
> /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.)

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


near the top of vcl/unx/gtk/gloactiongroup.cxx, similar to what is done 
"While I could swear that it worked yesterday".)

More information about the LibreOffice mailing list