Mozilla Home
Privacy
Cookies
Legal
Bugzilla
Browse
Advanced Search
New Bug
Reports
Documentation
Log In
Log In with GitHub
or
Remember me
Browse
Advanced Search
New Bug
Reports
Documentation
Attachment 516774 Details for
Bug 576933
[patch]
use a separate display to make protocol requests within X error handler
separate.display.in.error (text/plain), 3.15 KB, created by
Karl Tomlinson (:karlt)
(
hide
)
Description:
use a separate display to make protocol requests within X error handler
Filename:
MIME Type:
Creator:
Karl Tomlinson (:karlt)
Size:
3.15 KB
patch
obsolete
># HG changeset patch ># Parent aa0d8fc9ae57f62bacc683313149bae17d9237ad >b=576933 use a separate display to make protocol requests within X error handler r?roc > >diff --git a/toolkit/xre/nsX11ErrorHandler.cpp b/toolkit/xre/nsX11ErrorHandler.cpp >--- a/toolkit/xre/nsX11ErrorHandler.cpp >+++ b/toolkit/xre/nsX11ErrorHandler.cpp >@@ -50,56 +50,58 @@ using mozilla::plugins::PluginProcessChi > > #include "mozilla/X11Util.h" > #include <X11/Xlib.h> > > #define BUFSIZE 2048 // What Xlib uses with XGetErrorDatabaseText > > extern "C" { > static int >-IgnoreError(Display *display, XErrorEvent *event) { >- return 0; // This return value is ignored. >-} >- >-static int > X11Error(Display *display, XErrorEvent *event) { > nsCAutoString notes; > char buffer[BUFSIZE]; > > // Get an indication of how long ago the request that caused the error was >- // made. Do this before querying extensions etc below. >+ // made. > unsigned long age = NextRequest(display) - event->serial; > >- // Ignore subsequent errors, which may get processed during the extension >- // queries below for example. >- XSetErrorHandler(IgnoreError); >- > // Get a string to represent the request that caused the error. > nsCAutoString message; > if (event->request_code < 128) { > // Core protocol request > message.AppendInt(event->request_code); > } else { > // Extension request >- int nExts; >- char** extNames = XListExtensions(display, &nExts); >- if (extNames) { >- for (int i = 0; i < nExts; ++i) { >- int major_opcode, first_event, first_error; >- if (XQueryExtension(display, extNames[i], >- &major_opcode, &first_event, &first_error) >- && major_opcode == event->request_code) { >- message.Append(extNames[i]); >- message.Append('.'); >- message.AppendInt(event->minor_code); >- break; >+ >+ // man XSetErrorHandler says "the error handler should not call any >+ // functions (directly or indirectly) on the display that will generate >+ // protocol requests or that will look for input events" so we use another >+ // temporary Display to request extension information. This assumes on >+ // the DISPLAY environment variable has been set and matches what was used >+ // to open |display|. >+ Display *tmpDisplay = XOpenDisplay(NULL); >+ if (tmpDisplay) { >+ int nExts; >+ char** extNames = XListExtensions(tmpDisplay, &nExts); >+ if (extNames) { >+ for (int i = 0; i < nExts; ++i) { >+ int major_opcode, first_event, first_error; >+ if (XQueryExtension(tmpDisplay, extNames[i], >+ &major_opcode, &first_event, &first_error) >+ && major_opcode == event->request_code) { >+ message.Append(extNames[i]); >+ message.Append('.'); >+ message.AppendInt(event->minor_code); >+ break; >+ } > } >+ >+ XFreeExtensionList(extNames); > } >- >- XFreeExtensionList(extNames); >+ XCloseDisplay(tmpDisplay); > } > } > > if (message.IsEmpty()) { > buffer[0] = '\0'; > } else { > XGetErrorDatabaseText(display, "XRequest", message.get(), "", > buffer, sizeof(buffer));
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Flags:
roc
: review+
christian
: approval2.0+
Actions:
View
|
Diff
|
Review
Attachments on
bug 576933
: 516774 |
516782
|
527377
|
527380