summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authordominich@chromium.org <dominich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-27 18:58:29 +0000
committerdominich@chromium.org <dominich@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-27 18:58:29 +0000
commit31c31b2bab65f6b0f87ab234aa0f253f9f55f4df (patch)
tree4019f44e24ebd0e8284a2197f65407a971faf76d /ui
parent785b6e7a46fc2e0ec1f40abd67fc5930c95094ad (diff)
downloadchromium_src-31c31b2bab65f6b0f87ab234aa0f253f9f55f4df.zip
chromium_src-31c31b2bab65f6b0f87ab234aa0f253f9f55f4df.tar.gz
chromium_src-31c31b2bab65f6b0f87ab234aa0f253f9f55f4df.tar.bz2
Revert 102978 - Change X11 error handler override to allow easy X11 error checking.
BUG=None TEST=None Review URL: http://codereview.chromium.org/7889040 TBR=dominich@chromium.org Review URL: http://codereview.chromium.org/8052015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102985 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/base/x/x11_util.cc115
-rw-r--r--ui/base/x/x11_util_internal.h5
-rw-r--r--ui/gfx/gl/gl_bindings.h6
-rw-r--r--ui/gfx/gl/gl_context_glx.cc6
4 files changed, 47 insertions, 85 deletions
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc
index 0dd6e9c..39c2cff 100644
--- a/ui/base/x/x11_util.cc
+++ b/ui/base/x/x11_util.cc
@@ -65,8 +65,6 @@ CachedPictFormats* get_cached_pict_formats() {
const size_t kMaxCacheSize = 5;
int DefaultX11ErrorHandler(Display* d, XErrorEvent* e) {
- DCHECK(!MessageLoop::current() ||
- MessageLoop::current()->type() == MessageLoop::TYPE_UI);
MessageLoop::current()->PostTask(
FROM_HERE, NewRunnableFunction(LogErrorEventDescription, d, *e));
return 0;
@@ -78,14 +76,6 @@ int DefaultX11IOErrorHandler(Display* d) {
_exit(1);
}
-XErrorHandler current_error_handler = DefaultX11ErrorHandler;
-XErrorEvent last_error_event = {0, NULL, 0, 0, 0, 0, 0 };
-
-int BaseX11ErrorHandler(Display* d, XErrorEvent* e) {
- last_error_event = *e;
- return current_error_handler(d, e);
-}
-
Atom GetAtom(const char* name) {
#if defined(TOOLKIT_USES_GTK)
return gdk_x11_get_xatom_by_name_for_display(
@@ -115,49 +105,6 @@ bool GetProperty(XID window, const std::string& property_name, long max_length,
property);
}
-std::string BuildX11ErrorString(const XErrorEvent& error_event) {
- char error_str[256];
- char request_str[256];
-
- XGetErrorText(error_event.display, error_event.error_code, error_str,
- sizeof(error_str));
-
- strncpy(request_str, "Unknown", sizeof(request_str));
- if (error_event.request_code < 128) {
- std::string num = base::UintToString(error_event.request_code);
- XGetErrorDatabaseText(error_event.display, "XRequest", num.c_str(),
- "Unknown", request_str, sizeof(request_str));
- } else {
- int num_ext;
- char** ext_list = XListExtensions(error_event.display, &num_ext);
-
- for (int i = 0; i < num_ext; i++) {
- int ext_code, first_event, first_error;
- XQueryExtension(error_event.display, ext_list[i], &ext_code, &first_event,
- &first_error);
- if (error_event.request_code == ext_code) {
- std::string msg = StringPrintf(
- "%s.%d", ext_list[i], error_event.minor_code);
- XGetErrorDatabaseText(error_event.display, "XRequest", msg.c_str(),
- "Unknown", request_str, sizeof(request_str));
- break;
- }
- }
- XFreeExtensionList(ext_list);
- }
-
- std::ostringstream error_ss;
- error_ss << "X Error detected: "
- << "serial " << error_event.serial << ", "
- << "error_code " << static_cast<int>(error_event.error_code)
- << " (" << error_str << "), "
- << "request_code " << static_cast<int>(error_event.request_code)
- << ", "
- << "minor_code " << static_cast<int>(error_event.minor_code)
- << " (" << request_str << ")";
- return error_ss.str();
-}
-
} // namespace
bool XDisplayExists() {
@@ -748,7 +695,6 @@ bool ChangeWindowDesktop(XID window, XID destination) {
}
void SetDefaultX11ErrorHandlers() {
- XSetErrorHandler(BaseX11ErrorHandler);
SetX11ErrorHandlers(NULL, NULL);
}
@@ -784,15 +730,6 @@ bool IsX11WindowFullScreen(XID window) {
#endif
}
-void CheckForReportedX11Error() {
- DCHECK(!MessageLoop::current() ||
- MessageLoop::current()->type() == MessageLoop::TYPE_UI);
- if (!last_error_event.display)
- return;
- XSync(last_error_event.display, False);
- LOG(FATAL) << BuildX11ErrorString(last_error_event);
-}
-
// ----------------------------------------------------------------------------
// These functions are declared in x11_util_internal.h because they require
// XLib.h to be included, and it conflicts with many other headers.
@@ -871,21 +808,51 @@ XRenderPictFormat* GetRenderVisualFormat(Display* dpy, Visual* visual) {
void SetX11ErrorHandlers(XErrorHandler error_handler,
XIOErrorHandler io_error_handler) {
- DCHECK(!MessageLoop::current() ||
- MessageLoop::current()->type() == MessageLoop::TYPE_UI);
- current_error_handler = error_handler ?
- error_handler : DefaultX11ErrorHandler;
- XSetIOErrorHandler(io_error_handler ?
- io_error_handler : DefaultX11IOErrorHandler);
+ XSetErrorHandler(error_handler ? error_handler : DefaultX11ErrorHandler);
+ XSetIOErrorHandler(
+ io_error_handler ? io_error_handler : DefaultX11IOErrorHandler);
}
void LogErrorEventDescription(Display* dpy,
const XErrorEvent& error_event) {
- DCHECK(!MessageLoop::current() ||
- MessageLoop::current()->type() == MessageLoop::TYPE_UI);
- DCHECK_EQ(dpy, error_event.display)
- << "Attempt to log error for mismatching X11 display.";
- LOG(ERROR) << BuildX11ErrorString(error_event);
+ char error_str[256];
+ char request_str[256];
+
+ XGetErrorText(dpy, error_event.error_code, error_str, sizeof(error_str));
+
+ strncpy(request_str, "Unknown", sizeof(request_str));
+ if (error_event.request_code < 128) {
+ std::string num = base::UintToString(error_event.request_code);
+ XGetErrorDatabaseText(
+ dpy, "XRequest", num.c_str(), "Unknown", request_str,
+ sizeof(request_str));
+ } else {
+ int num_ext;
+ char** ext_list = XListExtensions(dpy, &num_ext);
+
+ for (int i = 0; i < num_ext; i++) {
+ int ext_code, first_event, first_error;
+ XQueryExtension(dpy, ext_list[i], &ext_code, &first_event, &first_error);
+ if (error_event.request_code == ext_code) {
+ std::string msg = StringPrintf(
+ "%s.%d", ext_list[i], error_event.minor_code);
+ XGetErrorDatabaseText(
+ dpy, "XRequest", msg.c_str(), "Unknown", request_str,
+ sizeof(request_str));
+ break;
+ }
+ }
+ XFreeExtensionList(ext_list);
+ }
+
+ LOG(ERROR)
+ << "X Error detected: "
+ << "serial " << error_event.serial << ", "
+ << "error_code " << static_cast<int>(error_event.error_code)
+ << " (" << error_str << "), "
+ << "request_code " << static_cast<int>(error_event.request_code) << ", "
+ << "minor_code " << static_cast<int>(error_event.minor_code)
+ << " (" << request_str << ")";
}
// ----------------------------------------------------------------------------
diff --git a/ui/base/x/x11_util_internal.h b/ui/base/x/x11_util_internal.h
index c84063f..70eb088 100644
--- a/ui/base/x/x11_util_internal.h
+++ b/ui/base/x/x11_util_internal.h
@@ -50,11 +50,6 @@ UI_EXPORT void SetX11ErrorHandlers(XErrorHandler error_handler,
UI_EXPORT void LogErrorEventDescription(Display* dpy,
const XErrorEvent& error_event);
-// LOG(FATAL) if an X11 errors has been reported. Uses XSync to ensure that all
-// requests have been received and processed by the X server and uses the X
-// display contained in the reported XErrorEvent.
-UI_EXPORT void CheckForReportedX11Error();
-
} // namespace ui
#endif // UI_BASE_X_X11_UTIL_INTERNAL_H_
diff --git a/ui/gfx/gl/gl_bindings.h b/ui/gfx/gl/gl_bindings.h
index af14f84..8951225 100644
--- a/ui/gfx/gl/gl_bindings.h
+++ b/ui/gfx/gl/gl_bindings.h
@@ -26,6 +26,12 @@
#elif defined(USE_X11)
#include <GL/glx.h>
#include <GL/glxext.h>
+
+// Undefine some macros defined by X headers. This is why this file should only
+// be included in .cc files.
+#undef Bool
+#undef None
+#undef Status
#endif
#if defined(OS_WIN)
diff --git a/ui/gfx/gl/gl_context_glx.cc b/ui/gfx/gl/gl_context_glx.cc
index e0ea25e..a23f1a9 100644
--- a/ui/gfx/gl/gl_context_glx.cc
+++ b/ui/gfx/gl/gl_context_glx.cc
@@ -11,7 +11,6 @@ extern "C" {
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "third_party/mesa/MesaLib/include/GL/osmesa.h"
-#include "ui/base/x/x11_util_internal.h"
#include "ui/gfx/gl/gl_bindings.h"
#include "ui/gfx/gl/gl_implementation.h"
#include "ui/gfx/gl/gl_surface_glx.h"
@@ -89,8 +88,6 @@ bool GLContextGLX::Initialize(GLSurface* compatible_surface) {
}
}
- ui::CheckForReportedX11Error();
-
if (!context_) {
// The means by which the context is created depends on whether
// the drawable type works reliably with GLX 1.3. If it does not
@@ -116,8 +113,6 @@ bool GLContextGLX::Initialize(GLSurface* compatible_surface) {
return false;
}
- ui::CheckForReportedX11Error();
-
XVisualInfo visual_info_template;
visual_info_template.visualid = XVisualIDFromVisual(attributes.visual);
@@ -141,7 +136,6 @@ bool GLContextGLX::Initialize(GLSurface* compatible_surface) {
True);
}
}
- ui::CheckForReportedX11Error();
if (!context_) {
LOG(ERROR) << "Couldn't create GL context.";