[opencv] 68/98: Fix a memory leak indirectly caused by cvDestroyWindow

Mattia Rizzolo mattia at debian.org
Tue Oct 4 17:51:27 UTC 2016


This is an automated email from the git hooks/post-receive script.

mattia pushed a commit to annotated tag 2.4.13
in repository opencv.

commit 97ac59cb73cc2e9bebadb004023abdce815c33ff
Author: Roman Donchenko <roman.donchenko at itseez.com>
Date:   Tue Mar 29 14:06:05 2016 +0300

    Fix a memory leak indirectly caused by cvDestroyWindow
---
 modules/highgui/src/window_gtk.cpp | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/modules/highgui/src/window_gtk.cpp b/modules/highgui/src/window_gtk.cpp
index c91e27d..bb69224 100644
--- a/modules/highgui/src/window_gtk.cpp
+++ b/modules/highgui/src/window_gtk.cpp
@@ -1007,13 +1007,33 @@ static void icvDeleteWindow( CvWindow* window )
     }
 
     cvFree( &window );
+
+    // if last window...
+    if( hg_windows == 0 )
+    {
 #ifdef HAVE_GTHREAD
-    // if last window, send key press signal
-    // to jump out of any waiting cvWaitKey's
-    if(hg_windows==0 && thread_started){
-        g_cond_broadcast(cond_have_key);
-    }
+        if( thread_started )
+        {
+            // send key press signal to jump out of any waiting cvWaitKey's
+            g_cond_broadcast( cond_have_key );
+        }
+        else
+        {
+#endif
+            // Some GTK+ modules (like the Unity module) use GDBusConnection,
+            // which has a habit of postponing cleanup by performing it via
+            // idle sources added to the main loop. Since this was the last window,
+            // we can assume that no event processing is going to happen in the
+            // nearest future, so we should force that cleanup (by handling all pending
+            // events) while we still have the chance.
+            // This is not needed if thread_started is true, because the background
+            // thread will process events continuously.
+            while( gtk_events_pending() )
+                gtk_main_iteration();
+#ifdef HAVE_GTHREAD
+        }
 #endif
+    }
 }
 
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/opencv.git



More information about the debian-science-commits mailing list