Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1113)

Unified Diff: chrome/browser/media/window_icon_util_x11.cc

Issue 2270543003: Display Window Icon In Picker UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Change Error Handler Back Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/media/window_icon_util_x11.cc
diff --git a/chrome/browser/media/window_icon_util_x11.cc b/chrome/browser/media/window_icon_util_x11.cc
index 36462dc229d131d6adbc58c1fadb4b26427e3624..b0f65fc16a339cede1696d61c8dcae3df6db2e6f 100644
--- a/chrome/browser/media/window_icon_util_x11.cc
+++ b/chrome/browser/media/window_icon_util_x11.cc
@@ -9,6 +9,15 @@
#include "ui/gfx/x/x11_types.h"
+// The error handler is for XGetWindowProperty. Otherwise, XGetWindowProperty
+// may throw an exception, and thus crash Chrome. A possibility is that when
+// GetWindowIcon is called after the window is already closed. Anyway, failure
+// to get an icon is not severe enough to worth blocking the normal workflow or
+// crashing Chrome.
+int ErrorHandler(Display* display, XErrorEvent* event) {
+ return 0;
+}
+
gfx::ImageSkia GetWindowIcon(content::DesktopMediaID id) {
DCHECK(id.type == content::DesktopMediaID::TYPE_WINDOW);
@@ -20,10 +29,12 @@ gfx::ImageSkia GetWindowIcon(content::DesktopMediaID id) {
unsigned long size;
long* data;
+ XErrorHandler old_handler = XSetErrorHandler(&ErrorHandler);
Daniel Erat 2016/08/25 23:39:58 please use ui/gfx/x/x11_error_tracker.h instead of
qiangchen 2016/08/25 23:54:19 Done.
int status = XGetWindowProperty(display, id.id, property, 0L, ~0L, False,
AnyPropertyType, &actual_type, &actual_format,
&size, &bytes_after,
reinterpret_cast<unsigned char**>(&data));
+ XSetErrorHandler(old_handler);
if (status != Success) {
return gfx::ImageSkia();
}

Powered by Google App Engine
This is Rietveld 408576698