Chromium Code Reviews| 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(); |
| } |