mi-preview: use ensure_native() in realized()
authorStefan Sauer <ensonic@users.sf.net>
Mon, 21 Oct 2013 07:07:09 +0000 (09:07 +0200)
committerStefan Sauer <ensonic@users.sf.net>
Mon, 21 Oct 2013 07:07:09 +0000 (09:07 +0200)
This fixes X crashers at startup when preparing the overlay.

mediainfo/src/mi-info.vala
mediainfo/src/mi-preview.vala

index a1d4efa4e8149217e12f9586ef002ad05bd5333e..74ec668c6543d8c3dc1cc403e7a8e02255fb135f 100644 (file)
@@ -506,9 +506,12 @@ public class MediaInfo.Info : Box
   }  
 
   private void on_element_sync_message (Gst.Bus bus, Message message) {
-    if (Gst.Video.is_video_overlay_prepare_window_handle_message (message)) {
+    if (Video.is_video_overlay_prepare_window_handle_message (message)) {
+      Gdk.Window window = preview.get_window ();
+      debug ("prepare overlay: %p", window);
       overlay = message.src as Gst.Video.Overlay;
-      overlay.set_window_handle ((uint *)Gdk.X11Window.get_xid (preview.get_window ()));
+      overlay.set_window_handle ((uint *)Gdk.X11Window.get_xid (window));
+      debug ("prepared overlay");
     }
   }
 
index 8ceb093b826ab19c1138e1dca71c865279e0b45d..fbc3f29103d883f06c0413b3d489fd603196233d 100644 (file)
@@ -116,6 +116,13 @@ public class MediaInfo.Preview : DrawingArea {
         alloc.x, alloc.y, alloc_width, alloc_height);
   }
   
+  public override void realize () {
+    base.realize();
+    debug ("realize");
+    if (!get_window ().ensure_native ())
+      error ("Couldn't create native window needed for GstVideoOverlay!");
+  }
+
   public override bool draw (Cairo.Context cr) {
     if (content != null) {
       Gdk.Pixbuf pb = content.scale_simple (alloc_width, alloc_height, Gdk.InterpType.BILINEAR);