[gtkmm] Gtk::PaperSizeTraits: Implement release_c_type()



commit 8e05df6f7112418c87ed3868a6e3879b5c2b09f5
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Fri Jul 14 19:09:25 2017 +0200

    Gtk::PaperSizeTraits: Implement release_c_type()
    
    Contrary to the comment, release_c_type() is called from get_paper_sizes().
    If release_c_type() is a no-op, get_paper_sizes() leaks memory.

 gtk/src/papersize.ccg |    5 +++++
 gtk/src/papersize.hg  |    2 +-
 2 files changed, 6 insertions(+), 1 deletions(-)
---
diff --git a/gtk/src/papersize.ccg b/gtk/src/papersize.ccg
index f157fd0..f7dadd7 100644
--- a/gtk/src/papersize.ccg
+++ b/gtk/src/papersize.ccg
@@ -83,5 +83,10 @@ void PaperSize::save_to_key_file(Glib::KeyFile& key_file)
   gtk_paper_size_to_key_file( gobj(), (key_file).gobj(), nullptr);
 }
 
+// static
+void PaperSizeTraits::release_c_type(CType ptr)
+{
+  gtk_paper_size_free(const_cast<CTypeNonConst>(ptr));
+}
 
 } // namespace Gtk
diff --git a/gtk/src/papersize.hg b/gtk/src/papersize.hg
index d423213..991d9fb 100644
--- a/gtk/src/papersize.hg
+++ b/gtk/src/papersize.hg
@@ -137,7 +137,7 @@ struct PaperSizeTraits
   static CType   to_c_type      (const CppType& obj) { return obj.gobj();     }
   static CType   to_c_type      (CType          ptr) { return ptr;                   }
   static CppType to_cpp_type    (CType          ptr) { return PaperSize(const_cast<GtkPaperSize*>(ptr), true 
/* make_copy */); /* Does not take ownership */ }
-  static void    release_c_type (CType          /* ptr */) { /* Doesn't happen */ }
+  static void    release_c_type (CType          ptr);
 };
 #endif //DOXYGEN_SHOULD_SKIP_THIS
 


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