summaryrefslogtreecommitdiff
path: root/glib/src/optiongroup.ccg
diff options
context:
space:
mode:
authorKjell Ahlstedt <kjell.ahlstedt@bredband.net>2017-03-20 15:49:15 +0100
committerKjell Ahlstedt <kjell.ahlstedt@bredband.net>2017-03-20 15:49:15 +0100
commit8a01f927bb7b1740c2008fc35a16c2b326271428 (patch)
tree881e109a51cf5223a2aaf79e643ac2484602bffc /glib/src/optiongroup.ccg
parent8c37e116a6a3a862b7574fa607cf69b3b6267dfe (diff)
downloadglibmm-8a01f927bb7b1740c2008fc35a16c2b326271428.tar.gz
Glib::OptionGroup: Take advantage of GOptionGroup's refcount
GOptionGroup is refcounted. Glib::OptionGroup::has_ownership is unnecessary. Replace gobj_give_ownership() by gobj_copy(). Glib::OptionGroup is not made refcounted, for reasons explained in a comment in optiongroup.hg.
Diffstat (limited to 'glib/src/optiongroup.ccg')
-rw-r--r--glib/src/optiongroup.ccg18
1 files changed, 6 insertions, 12 deletions
diff --git a/glib/src/optiongroup.ccg b/glib/src/optiongroup.ccg
index 81d924bb..b4e63a8d 100644
--- a/glib/src/optiongroup.ccg
+++ b/glib/src/optiongroup.ccg
@@ -269,8 +269,7 @@ OptionGroup::option_arg_callback(
OptionGroup::OptionGroup(const Glib::ustring& name, const Glib::ustring& description,
const Glib::ustring& help_description)
: gobject_(g_option_group_new(name.c_str(), description.c_str(), help_description.c_str(),
- this /* user_data */, nullptr /* destroy_func */)),
- has_ownership_(true)
+ this /* user_data */, nullptr /* destroy_func */))
{
// g_callback_pre_parse(), post_parse_callback(), g_callback_error(), and
// option_arg_callback() depend on user_data being this. The first three
@@ -283,18 +282,16 @@ OptionGroup::OptionGroup(const Glib::ustring& name, const Glib::ustring& descrip
g_option_group_set_error_hook(gobj(), &g_callback_error);
}
-OptionGroup::OptionGroup(GOptionGroup* castitem) : gobject_(castitem), has_ownership_(true)
+OptionGroup::OptionGroup(GOptionGroup* castitem) : gobject_(castitem)
{
// Always takes ownership - never takes copy.
}
OptionGroup::OptionGroup(OptionGroup&& other) noexcept
: map_entries_(std::move(other.map_entries_)),
- gobject_(std::move(other.gobject_)),
- has_ownership_(std::move(other.has_ownership_))
+ gobject_(std::move(other.gobject_))
{
other.gobject_ = nullptr;
- other.has_ownership_ = false;
}
OptionGroup&
@@ -304,10 +301,8 @@ OptionGroup::operator=(OptionGroup&& other) noexcept
map_entries_ = std::move(other.map_entries_);
gobject_ = std::move(other.gobject_);
- has_ownership_ = std::move(other.has_ownership_);
other.gobject_ = nullptr;
- other.has_ownership_ = false;
return *this;
}
@@ -322,7 +317,7 @@ OptionGroup::release_gobject() noexcept
cpp_entry.release_c_arg();
}
- if (has_ownership_ && gobject_)
+ if (gobject_)
{
g_option_group_unref(gobj());
gobject_ = nullptr;
@@ -847,10 +842,9 @@ OptionGroup::CppOptionEntry::convert_c_to_cpp()
}
GOptionGroup*
-OptionGroup::gobj_give_ownership()
+OptionGroup::gobj_copy() const
{
- has_ownership_ = false;
- return gobj();
+ return g_option_group_ref(gobject_);
}
} // namespace Glib