[gtkmm] Gtk::PrintJob: Fix a call to Glib::throw_exception()



commit 6631ac0af6f9dc4f8017e753092af32cfa503517
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Mon Jul 10 18:27:42 2017 +0200

    Gtk::PrintJob: Fix a call to Glib::throw_exception()
    
    Glib::throw_exception(GError*) takes ownership of the GError.
    SignalProxy_Custom_gtk_callback() must give a copy to throw_exception().

 gtk/src/printjob.ccg |   15 +++++----------
 1 files changed, 5 insertions(+), 10 deletions(-)
---
diff --git a/gtk/src/printjob.ccg b/gtk/src/printjob.ccg
index 2ab8b4e..6d2aba3 100644
--- a/gtk/src/printjob.ccg
+++ b/gtk/src/printjob.ccg
@@ -25,13 +25,12 @@ static void SignalProxy_Custom_gtk_callback(GtkPrintJob* print_job, gpointer dat
 
   try
   {
+    if (gerror)
+      Glib::Error::throw_exception(g_error_copy(gerror));
 
     // Create a suitable C++ instance to pass to the C++ method;
     auto job = Glib::wrap(print_job);
-
-    if (gerror) Glib::Error::throw_exception(const_cast<GError*>(gerror)); //TODO: Remove the case when this 
is fixed in glibmm.
     (*the_slot)(job);
-
   }
   catch(...)
   {
@@ -39,21 +38,17 @@ static void SignalProxy_Custom_gtk_callback(GtkPrintJob* print_job, gpointer dat
   }
 }
 
-static void SignalProxy_Custom_gtk_callback_destroy(void* data)
-{
-  delete static_cast<Gtk::PrintJob::SlotPrintJobComplete*>(data);
-}
-
 namespace Gtk
 {
 
 void PrintJob::send(const SlotPrintJobComplete& slot)
 {
   // Create a copy of the slot. A pointer to this will be passed through the callback's data parameter.
-  // It will be deleted when SignalProxy_Custom_gtk_callback_destroy() is called.
+  // It will be deleted when Glib::destroy_notify_delete<SlotPrintJobComplete>() is called.
   auto slot_copy = new SlotPrintJobComplete(slot);
 
-  gtk_print_job_send(gobj(), &SignalProxy_Custom_gtk_callback, slot_copy, 
&SignalProxy_Custom_gtk_callback_destroy);
+  gtk_print_job_send(gobj(), &SignalProxy_Custom_gtk_callback, slot_copy,
+   &Glib::destroy_notify_delete<SlotPrintJobComplete>);
 }
 
 std::vector<PageRange> PrintJob::get_page_ranges() const


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