diff options
author | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2021-07-26 17:10:44 +0200 |
---|---|---|
committer | Kjell Ahlstedt <kjellahlstedt@gmail.com> | 2021-07-26 17:10:44 +0200 |
commit | 51d81a9ad4cb5383d938257edeb0e5261f76bd81 (patch) | |
tree | 3fba4c136c8fa252693408a5b16e95391cdfa67b /gio | |
parent | eb3f7215e05a46d02b878ef4a6ba4bef85a1ef6f (diff) | |
download | glibmm-51d81a9ad4cb5383d938257edeb0e5261f76bd81.tar.gz |
Gio::AppInfo::get_all(): Use Glib::wrap_auto_interface()
Applies also to get_all_for_type().
Make a complete specialization of Glib::Container_Helpers::TypeTraits for
Glib::RefPtr<Gio::AppInfo>, calling Glib::wrap(GAppInfo*, bool) which uses
Glib::wrap_auto_interface(). The partial specialization in
containerhandle_shared.h calls Glib::wrap_auto(), which is not acceptable
if the GAppInfo object does not already have a wrapper, and its class type
has been wrapped in a C++ class (e.g. GWin32AppInfo or GOsxAppInfo).
Fixes #94
Diffstat (limited to 'gio')
-rw-r--r-- | gio/src/appinfo.ccg | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gio/src/appinfo.ccg b/gio/src/appinfo.ccg index 5c4a7170..c0caaca1 100644 --- a/gio/src/appinfo.ccg +++ b/gio/src/appinfo.ccg @@ -19,6 +19,38 @@ #include <giomm/slot_async.h> #include <gio/gio.h> +namespace Glib +{ +namespace Container_Helpers +{ +/* Specialization for pointers to the GAppInfo interface. + * The partial specialization in glibmm/glib/glibmm/containerhandle_shared.h + * is not well suited for interfaces which do not already have a wrapper. + * Its to_cpp_type() calls Glib::wrap_auto() instead id Glib::wrap_auto_interface(). + * This specialization is used by Glib::ListHandler<>::list_to_vector() in + * Gio::AppInfo::get_all() and Gio::AppInfo::get_all_for_type(). + */ +template <> +struct TypeTraits<Glib::RefPtr<Gio::AppInfo>> +{ + using T = Gio::AppInfo; + using CppType = Glib::RefPtr<T>; + using CType = typename T::BaseObjectType*; + using CTypeNonConst = typename T::BaseObjectType*; + + static CType to_c_type(const CppType& ptr) { return Glib::unwrap(ptr); } + static CType to_c_type(CType ptr) { return ptr; } + static CppType to_cpp_type(CType ptr) { return Glib::wrap(ptr, true); } + + static void release_c_type(CType ptr) + { + GLIBMM_DEBUG_UNREFERENCE(nullptr, ptr); + g_object_unref(ptr); + } +}; +} // namespace Container_Helpers +} // namespace Glib + namespace Gio { |