[glibmm] Gio::Action, ActionGroup: Fix memory problems.



commit 566548222c2bb53661a7d9717f916e5ef07a224d
Author: Kjell Ahlstedt <kjell ahlstedt bredband net>
Date:   Tue Jul 30 09:38:47 2013 +0200

    Gio::Action, ActionGroup: Fix memory problems.
    
    * gio/src/action.ccg: get_state_bool(): Unref GVariant.
    * tools/m4/convert_gio.m4: Take a copy when const GVariantType* is converted
    to Glib::VariantType. Affects Action and ActionGroup. Bug #690134.

 gio/src/action.ccg      |    4 +++-
 tools/m4/convert_gio.m4 |    2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/gio/src/action.ccg b/gio/src/action.ccg
index 2ca354b..dbc1279 100644
--- a/gio/src/action.ccg
+++ b/gio/src/action.ccg
@@ -32,7 +32,9 @@ bool Action::get_state_bool() const
 
   GVariant* state = g_action_get_state(const_cast<GAction*>(gobj()));
   g_return_val_if_fail(state, false);
-  return g_variant_get_boolean(state);
+  const bool result = g_variant_get_boolean(state);
+  g_variant_unref(state);
+  return result;
 }
 
 void Action::change_state(bool value)
diff --git a/tools/m4/convert_gio.m4 b/tools/m4/convert_gio.m4
index e08b167..8a2d632 100644
--- a/tools/m4/convert_gio.m4
+++ b/tools/m4/convert_gio.m4
@@ -304,7 +304,7 @@ _CONVERSION(`const Glib::VariantBase&',`GVariant*',`const_cast<GVariant*>(($3).g
 _CONVERSION(`const Glib::VariantContainerBase&',`GVariant*',`const_cast<GVariant*>(($3).gobj())')
 
 #VariantType
-_CONVERSION(`const GVariantType*',`Glib::VariantType',`Glib::wrap(const_cast<GVariantType*>($3), false)')
+_CONVERSION(`const GVariantType*',`Glib::VariantType',`Glib::wrap(const_cast<GVariantType*>($3), true)')
 _CONVERSION(`const Glib::VariantType&',`const GVariantType*',`$3.gobj()')
 
 #Volume


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]