Bug 632969 - 1/4 - X error handling fixes - r=bjacob, a=blocker
authorKarl Tomlinson <karlt+@karlt.net>
Fri, 11 Feb 2011 18:11:30 -0500
changeset 62482 895e4d18639adaf4332464023a22a64acb7b1caf
parent 62481 7ed4cb02ffbfcc335d38d54b0fb77d2fe45fd6e8
child 62483 0c4dc6d59c544315fc5a68ee192a64bc0c224b67
push idunknown
push userunknown
push dateunknown
reviewersbjacob, blocker
bugs632969
milestone2.0b12pre
Bug 632969 - 1/4 - X error handling fixes - r=bjacob, a=blocker
gfx/src/X11Util.cpp
gfx/src/X11Util.h
--- a/gfx/src/X11Util.cpp
+++ b/gfx/src/X11Util.cpp
@@ -41,21 +41,23 @@
 
 namespace mozilla {
 
 ScopedXErrorHandler::ErrorEvent* ScopedXErrorHandler::sXErrorPtr;
 
 int
 ScopedXErrorHandler::ErrorHandler(Display *, XErrorEvent *ev)
 {
-    sXErrorPtr->mError = *ev;
+    // only record the error if no error was previously recorded.
+    // this means that in case of multiple errors, it's the first error that we report.
+    if (!sXErrorPtr->mError.error_code)
+      sXErrorPtr->mError = *ev;
     return 0;
 }
 
-
 ScopedXErrorHandler::ScopedXErrorHandler()
 {
     // let sXErrorPtr point to this object's mXError object, but don't reset this mXError object!
     // think of the case of nested ScopedXErrorHandler's.
     mOldXErrorPtr = sXErrorPtr;
     sXErrorPtr = &mXError;
     mOldErrorHandler = XSetErrorHandler(ErrorHandler);
 }
--- a/gfx/src/X11Util.h
+++ b/gfx/src/X11Util.h
@@ -153,19 +153,21 @@ public:
 
     static int
     ErrorHandler(Display *, XErrorEvent *ev);
 
     ScopedXErrorHandler();
 
     ~ScopedXErrorHandler();
 
-    /** \returns true if a X error occurred since the last time this method was called on this ScopedXErrorHandler object.
+    /** \returns true if a X error occurred since the last time this method was called on this ScopedXErrorHandler object,
+     *           or since the creation of this ScopedXErrorHandler object if this method was never called on it.
      *
-     * \param ev this optional parameter, if set, will be filled with the XErrorEvent object
+     * \param ev this optional parameter, if set, will be filled with the XErrorEvent object. If multiple errors occurred,
+     *           the first one will be returned.
      */
     bool SyncAndGetError(Display *dpy, XErrorEvent *ev = nsnull);
 };
 
 
 } // namespace mozilla
 
 #endif  // mozilla_X11Util_h