Thank you all for the suggestions. I have tested both approaches. <br><br>1. Use gdk_display_sync (gdk_display_get_default())<br><br>Application A (which has the window) is written using QT. Here is the procedure:<br><br>1). Application A calls uiWindow.show() to display window,<br>
2). Call gdk_display_sync (gdk_display_get_default()) right after show(),<br>3). Get windowId, and send to Application B,<br>4). Application B call gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(m_sinkPreview), windowId);<br>
<br>With or without step 2), Application B can crash.<br><br>2. Use gdk_threads_enter and gdk_threads_leave<br><br>I did as suggested by Matthews and Luciana, in application B. This works.<br><br>Thanks again,<br>Yiliang<br>
<br><div class="gmail_quote">On Tue, Mar 2, 2010 at 12:28 PM, Tristan Matthews <span dir="ltr">&lt;<a href="mailto:tristan@sat.qc.ca">tristan@sat.qc.ca</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="gmail_quote">2010/3/2 Tristan Matthews <span dir="ltr">&lt;<a href="mailto:tristan@sat.qc.ca" target="_blank">tristan@sat.qc.ca</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div class="gmail_quote"><div class="im">2010/3/2 Jan Schmidt <span dir="ltr">&lt;<a href="mailto:thaytan@noraisin.net" target="_blank">thaytan@noraisin.net</a>&gt;</span></div><div class="im"><div>Here&#39;s my code:<br>
</div><div><br>bool handleBusMsg(GstMessage *message)<br>

{<br> if (!gst_structure_has_name(message-&gt;structure, &quot;prepare-xwindow-id&quot;))<br>        return false;<br><br>    gdk_threads_enter();<br>    gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(GST_MESSAGE_SRC(message)), getXWindow());<br>


    gdk_threads_leave();<br>}<br><br></div></div></div></blockquote><div><br>I should add, getXWindow() returns the xid which has been provided by Application A (the destination), and that this code lives in Application B (the source).<br>

<br> </div><div><div></div><div class="h5"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="gmail_quote"><div> Thanks,<br><font color="#888888"> Tristan<br>
<br></font></div>
<div><div></div><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
- Jan.<br>
<div><br>
On Sat, 2010-02-27 at 17:23 -0800, yiliang wrote:<br>
</div><div>&gt; Hi,<br>
&gt;<br>
&gt; I have 2 applications. One application (application A) creates a window, and<br>
&gt; sends the window ID to another application (application B). application B<br>
&gt; has a gstreamer video pipeline that uses xvimagesink to display the video as<br>
&gt; overlay in the window using the window ID provided by application A. I am<br>
&gt; sorry if it sounds a little confusing. This is to separate UI from pipeline.<br>
&gt;<br>
&gt; Following function is used to configure xvimagesink with window ID:<br>
&gt;<br>
&gt;     gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(xvimagesink), winId);<br>
&gt;<br>
&gt; Most of time it works fine, but sometimes I encounter the following problem,<br>
&gt; and the application B is terminated:<br>
&gt;<br>
&gt; X Error of failed request:  BadWindow (invalid Window parameter)<br>
&gt;   Major opcode of failed request:  3 (X_GetWindowAttributes)<br>
&gt;   Resource id in failed request:  0x400016f<br>
&gt;   Serial number of failed request:  32<br>
&gt;   Current serial number in output stream:  33<br>
&gt;<br>
&gt; After some debugging, I found the error was generated in function<br>
&gt; gst_xvimagesink_set_xwindow_id() when it called the following function:<br>
&gt;<br>
&gt; XGetWindowAttributes<br>
&gt;<br>
&gt; Could anyone give some hint how to fix this problem?<br>
&gt;<br>
&gt; Thanks,<br>
&gt; Yiliang<br>
&gt;<br>
<br>
<br>
--<br>
</div><font color="#888888">Jan Schmidt &lt;<a href="mailto:thaytan@noraisin.net" target="_blank">thaytan@noraisin.net</a>&gt;<br>
</font><div><div></div><div><br>
<br>
------------------------------------------------------------------------------<br>
Download Intel&amp;#174; Parallel Studio Eval<br>
Try the new software tools for yourself. Speed compiling, find bugs<br>
proactively, and fine-tune applications for parallel performance.<br>
See why Intel Parallel Studio got high marks during beta.<br>
<a href="http://p.sf.net/sfu/intel-sw-dev" target="_blank">http://p.sf.net/sfu/intel-sw-dev</a><br>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.sourceforge.net" target="_blank">gstreamer-devel@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/gstreamer-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/gstreamer-devel</a><br>
</div></div></blockquote></div></div></div><br><br clear="all"><div><div></div><div><br>-- <br>Tristan Matthews<br>email: <a href="mailto:tristan@sat.qc.ca" target="_blank">tristan@sat.qc.ca</a><br>web: <a href="http://tristanswork.blogspot.com" target="_blank">http://tristanswork.blogspot.com</a><br>



</div></div></blockquote></div></div></div><div><div></div><div class="h5"><br><br clear="all"><br>-- <br>Tristan Matthews<br>email: <a href="mailto:tristan@sat.qc.ca" target="_blank">tristan@sat.qc.ca</a><br>web: <a href="http://tristanswork.blogspot.com" target="_blank">http://tristanswork.blogspot.com</a><br>


</div></div><br>------------------------------------------------------------------------------<br>
Download Intel&amp;#174; Parallel Studio Eval<br>
Try the new software tools for yourself. Speed compiling, find bugs<br>
proactively, and fine-tune applications for parallel performance.<br>
See why Intel Parallel Studio got high marks during beta.<br>
<a href="http://p.sf.net/sfu/intel-sw-dev" target="_blank">http://p.sf.net/sfu/intel-sw-dev</a><br>_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.sourceforge.net">gstreamer-devel@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/gstreamer-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/gstreamer-devel</a><br>
<br></blockquote></div><br>