summaryrefslogtreecommitdiffstats
path: root/ui/base
diff options
context:
space:
mode:
Diffstat (limited to 'ui/base')
-rw-r--r--ui/base/x/x11_util.cc35
-rw-r--r--ui/base/x/x11_util_internal.h7
2 files changed, 25 insertions, 17 deletions
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc
index df8c8d8..6234069 100644
--- a/ui/base/x/x11_util.cc
+++ b/ui/base/x/x11_util.cc
@@ -56,7 +56,8 @@ CachedPictFormats* get_cached_pict_formats() {
const size_t kMaxCacheSize = 5;
int DefaultX11ErrorHandler(Display* d, XErrorEvent* e) {
- LOG(ERROR) << GetErrorEventDescription(d, e);
+ MessageLoop::current()->PostTask(
+ FROM_HERE, NewRunnableFunction(LogErrorEventDescription, d, *e));
return 0;
}
@@ -826,29 +827,29 @@ void SetX11ErrorHandlers(XErrorHandler error_handler,
io_error_handler ? io_error_handler : DefaultX11IOErrorHandler);
}
-std::string GetErrorEventDescription(Display *dpy,
- XErrorEvent *error_event) {
+void LogErrorEventDescription(Display* dpy,
+ XErrorEvent error_event) {
char error_str[256];
char request_str[256];
- XGetErrorText(dpy, error_event->error_code, error_str, sizeof(error_str));
+ 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);
+ 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 {
+ } else {
int num_ext;
- char **ext_list = XListExtensions(dpy, &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) {
+ if (error_event.request_code == ext_code) {
std::string msg = StringPrintf(
- "%s.%d", ext_list[i], error_event->minor_code);
+ "%s.%d", ext_list[i], error_event.minor_code);
XGetErrorDatabaseText(
dpy, "XRequest", msg.c_str(), "Unknown", request_str,
sizeof(request_str));
@@ -858,12 +859,16 @@ std::string GetErrorEventDescription(Display *dpy,
XFreeExtensionList(ext_list);
}
- return base::StringPrintf(
- "X Error detected: serial %lu, error_code %u (%s), "
- "request_code %u minor_code %u (%s)",
- error_event->serial, error_event->error_code, error_str,
- error_event->request_code, error_event->minor_code, request_str);
+ 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 << ")";
}
+
// ----------------------------------------------------------------------------
// End of x11_util_internal.h
diff --git a/ui/base/x/x11_util_internal.h b/ui/base/x/x11_util_internal.h
index cee2bec..87b75ef8 100644
--- a/ui/base/x/x11_util_internal.h
+++ b/ui/base/x/x11_util_internal.h
@@ -40,8 +40,11 @@ namespace ui {
void SetX11ErrorHandlers(XErrorHandler error_handler,
XIOErrorHandler io_error_handler);
- // Returns a string suitable for logging the error event.
- std::string GetErrorEventDescription(Display* dpy, XErrorEvent* error_event);
+ // NOTE: This function should not be called directly from the
+ // X11 Error handler because it queries the server to decode the
+ // error message, which may trigger other errors. A suitable workaround
+ // is to post a task in the error handler to call this function.
+ void LogErrorEventDescription(Display* dpy, XErrorEvent error_event);
} // namespace ui