<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Dec 18, 2007, at 6:42 PM, Russell Shaw wrote:</div><blockquote type="cite">Make X synchronous and BadMatch errors will be easier to find.<br></blockquote></div><br><div>Interestingly, using XPeekIfEvent() wrapped in XSynchronize(True/False) calls makes the BadMatch sometimes less likely to occur. To reproduce the error I've been minimizing (manually, I'm in Gnome) and then un-minimizing via a call to my map_raise_focus() function. Without the XSynchronize() calls this gives the error on either the first or second attempt to un-minimize.  With XSynchronize() calls it sometimes (though sometimes not) takes about 10 tries, but the error always does eventually happen.</div><div><br class="webkit-block-placeholder"></div><div>I've looked over the code that is being executed in its entirety to check if any other Xlib function could have caused a BadMatch error and it appears XSetInputFocus() is the only culprit.</div><div><br class="webkit-block-placeholder"></div><div>Just for reference, in the code that's being executed I've only got these functions:</div><div><div><span class="Apple-tab-span" style="white-space:pre">    </span>XPeekIfEvent()</div><div><span class="Apple-tab-span" style="white-space:pre">       </span>XSelectInput()</div><div><span class="Apple-tab-span" style="white-space:pre">       </span>XGetWindowAttributes()</div><div><span class="Apple-tab-span" style="white-space:pre">       </span>XMapRaised()</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>XSetInputFocus()</div><div><span class="Apple-tab-span" style="white-space:pre">     </span>XGetWindowProperty()</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>XGetWMName()</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>XFree()</div><div><br></div><div>Even assuming I'm not using one of those correctly, none of them but the XSetInputFocus() can cause a BadMatch, or is there a way I can get BadMatch some other way?</div><div><br class="webkit-block-placeholder"></div><div><br class="webkit-block-placeholder"></div><div>Incidentally, since XSynchronize() was able to give me sometimes more stability I thought that maybe the solution that uses XWindowEvent() is also only exhibiting sometimes more stability as well. So I tried as hard as I could to crash the program that's using XWindowEvent() but I just can't do it, it appears to work all the time whereas the XPeekIfEvent() fails very quickly.</div><div><br class="webkit-block-placeholder"></div><div>I also printed out the values of the XEvent that causes the do-while-XWindowEvent() loop to exit and the XEvent returned by XPeekIfEvent() and they're the same --- So XPeekIfEvent() and XWindowEvent() are returning the same event exactly how I want them to, but one fails and the other doesn't. So yeah, I'm completely clueless now. Maybe I _DO_ want to remove the XEvent from the event queue?</div></div><div><br class="webkit-block-placeholder"></div><div>On Dec 18, 2007, at 6:10 PM, Peter Harris wrote:</div><div><blockquote type="cite">The only remaining thing I can think of is the return type: Bool.<br></blockquote><div><font class="Apple-style-span" color="#144FAE"><br class="webkit-block-placeholder"></font></div><div>The only includes I've got are X11 headers, stl headers, and ctime which makes errors like this less likely. I just checked that I didn't typedef of #define Bool/True/False to be sure but nope that's not the problem either. I even changed all True to 1, False to 0, and Bool to int just to be extra double for sure ;) No luck.</div></div><br><div apple-content-edited="true"><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div>--</div><div>Andrew Troschinetz</div><div>Applied Research Laboratories</div></span></div></span></div></body></html>