[gnome-flashback] screenshot: unref GdkWindow from gdk_screen_get_active_window



commit fa996c2769de6535583dd124792bc9a6ff26daad
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date:   Tue Sep 15 14:20:27 2015 +0300

    screenshot: unref GdkWindow from gdk_screen_get_active_window
    
    From GDK reference manual:
    The returned window should be unrefed using g_object_unref () when
    no longer needed.

 gnome-flashback/libscreenshot/gf-screenshot.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/gnome-flashback/libscreenshot/gf-screenshot.c b/gnome-flashback/libscreenshot/gf-screenshot.c
index 25915af..230ae67 100644
--- a/gnome-flashback/libscreenshot/gf-screenshot.c
+++ b/gnome-flashback/libscreenshot/gf-screenshot.c
@@ -418,6 +418,7 @@ static GdkWindow *
 find_current_window (GdkDisplay *display)
 {
   GdkWindow *window;
+  GdkWindow *toplevel;
 
   window = find_active_window ();
 
@@ -430,17 +431,26 @@ find_current_window (GdkDisplay *display)
       device = gdk_device_manager_get_client_pointer (manager);
 
       window = gdk_device_get_window_at_position (device, NULL, NULL);
+
+      if (window)
+        g_object_ref (window);
     }
 
   if (window)
     {
       if (window_is_desktop (window))
-        return NULL;
+        {
+          g_object_unref (window);
+          return NULL;
+        }
+
+      toplevel = gdk_window_get_toplevel (window);
 
-      window = gdk_window_get_toplevel (window);
+      g_object_unref (window);
+      return toplevel;
     }
 
-  return window;
+  return NULL;
 }
 
 static GdkWindow *


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