[pygtk] Plug reference leak on main signal watch source



commit cec183f138153df7c6573b01f3a44a5fe54dfc54
Author: Paul Pogonyshev <pogonyshev gmx net>
Date:   Sat May 2 16:55:53 2009 +0300

    Plug reference leak on main signal watch source
    
    Additionally rename pygtk_signal_watch_finalize() to
    pygtk_main_watch_finalize() for consistency.  Fixes bug #579406.
---
 gtk/gtk.override |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/gtk/gtk.override b/gtk/gtk.override
index f5babed..8d7a0f5 100644
--- a/gtk/gtk.override
+++ b/gtk/gtk.override
@@ -1188,7 +1188,7 @@ pygtk_main_watch_dispatch(GSource    *source,
 }
 
 static void
-pygtk_signal_watch_finalize(GSource *source)
+pygtk_main_watch_finalize(GSource *source)
 {
     PySignalWatchSource *real_source = (PySignalWatchSource*)source;
 
@@ -1196,8 +1196,17 @@ pygtk_signal_watch_finalize(GSource *source)
 	if (real_source->fds[0] != 0)
 	    close(real_source->fds[0]);
 	
-	if (real_source->fds[1] != 0)
-	    close(real_source->fds[1]);
+	if (real_source->fds[1] != 0) {
+#if HAVE_PYSIGNAL_SETWAKEUPFD
+            int  wakeup_fd = PySignal_SetWakeupFd(-1);
+            if (wakeup_fd != real_source->fds[1]) {
+                /* Probably should never happen. */
+                PySignal_SetWakeupFd(wakeup_fd);
+            }
+#endif
+
+            close(real_source->fds[1]);
+        }
     }
 }
 
@@ -1206,7 +1215,7 @@ static GSourceFuncs pygtk_main_watch_funcs =
     pygtk_main_watch_prepare,
     pygtk_main_watch_check,
     pygtk_main_watch_dispatch,
-    pygtk_signal_watch_finalize
+    pygtk_main_watch_finalize
 };
 
 static GSource *
@@ -1227,6 +1236,7 @@ _wrap_gtk_main(PyObject *self)
     main_watch = pygtk_main_watch_new();
     pyg_begin_allow_threads;
     g_source_attach(main_watch, NULL);
+    g_source_unref(main_watch);
     gtk_main();
     g_source_destroy(main_watch);
     pyg_end_allow_threads;



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