diff --git a/config.h.meson b/config.h.meson index b93fda872..ff355d306 100644 --- a/config.h.meson +++ b/config.h.meson @@ -33,3 +33,6 @@ /* Define if fdwalk is available in libc */ #mesondefine HAVE_FDWALK + +/* Define if polkit defines autocleanup functions */ +#mesondefine HAVE_POLKIT_AUTOCLEANUP diff --git a/meson.build b/meson.build index 42ec01c56..778a34c6e 100644 --- a/meson.build +++ b/meson.build @@ -169,6 +169,13 @@ cdata.set('HAVE_FDWALK', cc.has_function('fdwalk') ) +polkit_has_autocleanup = cc.compiles( + '#define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE + #include + void main(void) { g_autoptr(PolkitAgentListener) agent = NULL; }', + dependencies: polkit_dep) +cdata.set('HAVE_POLKIT_AUTOCLEANUP', polkit_has_autocleanup) + buildtype = get_option('buildtype') if buildtype != 'plain' all_warnings = [ diff --git a/src/shell-polkit-authentication-agent.h b/src/shell-polkit-authentication-agent.h index 55b46af11..4f1474956 100644 --- a/src/shell-polkit-authentication-agent.h +++ b/src/shell-polkit-authentication-agent.h @@ -14,8 +14,10 @@ G_BEGIN_DECLS +#ifndef HAVE_POLKIT_AUTOCLEANUP /* Polkit doesn't have g_autoptr support, thus we have to manually set the autoptr function here */ G_DEFINE_AUTOPTR_CLEANUP_FUNC (PolkitAgentListener, g_object_unref) +#endif #define SHELL_TYPE_POLKIT_AUTHENTICATION_AGENT (shell_polkit_authentication_agent_get_type())