diff options
author | Kjell Ahlstedt <kjell.ahlstedt@bredband.net> | 2015-03-17 10:33:18 +0100 |
---|---|---|
committer | Kjell Ahlstedt <kjell.ahlstedt@bredband.net> | 2015-03-17 10:33:18 +0100 |
commit | b28bc49e7af2b90d23bb4ea460ca15c8eaf0cc54 (patch) | |
tree | a250d06c6f705b47b658044844d2bf7c7d975f2d | |
parent | 010a2d71e4379a12849d2cda742dfdc0a868d043 (diff) | |
download | glibmm-b28bc49e7af2b90d23bb4ea460ca15c8eaf0cc54.tar.gz |
Gio::Action, ActionGroup: Fix critical messages from vfuncs
* glib/glibmm/wrap.h: Add unwrap_copy(const T& obj).
* gio/src/action.hg:
* gio/src/actiongroup.hg: Make vfuncs that return a GVariant* use the
new Glib::unwrap_copy() overload by adding the _WRAP_VFUNC parameter
refreturn_ctype. It avoids a critical message if Glib::VariantBase::
gobj() == 0, which is not an error in these functions. Bug #705124.
-rw-r--r-- | gio/src/action.hg | 6 | ||||
-rw-r--r-- | gio/src/actiongroup.hg | 5 | ||||
-rw-r--r-- | glib/glibmm/wrap.h | 17 |
3 files changed, 18 insertions, 10 deletions
diff --git a/gio/src/action.hg b/gio/src/action.hg index 207bb93a..eca98122 100644 --- a/gio/src/action.hg +++ b/gio/src/action.hg @@ -222,13 +222,11 @@ public: _WRAP_VFUNC(Glib::VariantType get_parameter_type() const, "get_parameter_type", keep_return) _WRAP_VFUNC(Glib::VariantType get_state_type() const, "get_state_type", keep_return) -#m4 _CONVERSION(`Glib::VariantBase',`GVariant*',`$3.gobj_copy()') - - _WRAP_VFUNC(Glib::VariantBase get_state_hint() const, "get_state_hint") + _WRAP_VFUNC(Glib::VariantBase get_state_hint() const, "get_state_hint", refreturn_ctype) _WRAP_VFUNC(bool get_enabled() const, "get_enabled") - _WRAP_VFUNC(Glib::VariantBase get_state() const, "get_state") + _WRAP_VFUNC(Glib::VariantBase get_state() const, "get_state", refreturn_ctype) #m4 _CONVERSION(`GVariant*',`const Glib::VariantBase&',`Glib::wrap($3, true)') _WRAP_VFUNC(void change_state(const Glib::VariantBase& value), "change_state") diff --git a/gio/src/actiongroup.hg b/gio/src/actiongroup.hg index a7483bac..71385be6 100644 --- a/gio/src/actiongroup.hg +++ b/gio/src/actiongroup.hg @@ -152,9 +152,8 @@ public: _WRAP_VFUNC(Glib::VariantType get_action_parameter_type(const Glib::ustring& name) const, "get_action_parameter_type", keep_return) _WRAP_VFUNC(Glib::VariantType get_action_state_type(const Glib::ustring& name) const, "get_action_state_type", keep_return) -#m4 _CONVERSION(`Glib::VariantBase',`GVariant*',`$3.gobj_copy()') - _WRAP_VFUNC(Glib::VariantBase get_action_state_hint(const Glib::ustring& name) const, "get_action_state_hint") - _WRAP_VFUNC(Glib::VariantBase get_action_state(const Glib::ustring& name) const, "get_action_state") + _WRAP_VFUNC(Glib::VariantBase get_action_state_hint(const Glib::ustring& name) const, "get_action_state_hint", refreturn_ctype) + _WRAP_VFUNC(Glib::VariantBase get_action_state(const Glib::ustring& name) const, "get_action_state", refreturn_ctype) _WRAP_VFUNC(void change_action_state(const Glib::ustring& name, const Glib::VariantBase& value), "change_action_state") _WRAP_VFUNC(void activate_action(const Glib::ustring& name, const Glib::VariantBase& parameter), "activate_action") diff --git a/glib/glibmm/wrap.h b/glib/glibmm/wrap.h index 5b07395b..c4ca34e0 100644 --- a/glib/glibmm/wrap.h +++ b/glib/glibmm/wrap.h @@ -1,9 +1,6 @@ -// -*- c++ -*- #ifndef _GLIBMM_WRAP_H #define _GLIBMM_WRAP_H -/* $Id$ */ - /* Copyright (C) 1998-2002 The gtkmm Development Team * * This library is free software; you can redistribute it and/or @@ -143,6 +140,20 @@ const typename T::BaseObjectType* unwrap(const Glib::RefPtr<const T>& ptr) return (ptr) ? ptr->gobj() : 0; } +// This unwrap_copy() overload is intended primarily for classes wrapped as +// _CLASS_BOXEDTYPE, _CLASS_OPAQUE_COPYABLE or _CLASS_OPAQUE_REFCOUNTED, +// where the C++ objects are not stored in Glib::RefPtr<>s. They have a const +// gobj_copy() member that returns a non-const pointer to the underlying C instance. +/** Get the underlying C instance from the C++ instance and acquire a + * reference or copy. This is just like calling gobj_copy(), but it does its own + * check for a NULL pointer to the underlying C instance. + */ +template <class T> inline +typename T::BaseObjectType* unwrap_copy(const T& obj) +{ + return obj.gobj() ? obj.gobj_copy() : 0; +} + /** Get the underlying C instance from the C++ instance and acquire a * reference. This is just like calling gobj_copy(), but it does its own * check for a NULL pointer. |