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..52f211f2955c5d1e8b28451982b4778ac50eda4f 100644 |
--- a/chrome/browser/media/window_icon_util_x11.cc |
+++ b/chrome/browser/media/window_icon_util_x11.cc |
@@ -7,6 +7,7 @@ |
#include <X11/Xatom.h> |
#include <X11/Xutil.h> |
+#include "ui/gfx/x/x11_error_tracker.h" |
#include "ui/gfx/x/x11_types.h" |
gfx::ImageSkia GetWindowIcon(content::DesktopMediaID id) { |
@@ -20,10 +21,20 @@ gfx::ImageSkia GetWindowIcon(content::DesktopMediaID id) { |
unsigned long size; |
long* data; |
+ // The |error_tracker| essentially provides an empty X error handler for |
sky
2016/08/26 19:38:36
Excellent description. Thanks!
qiangchen
2016/08/26 19:55:24
Acknowledged.
|
+ // the call of XGetWindowProperty. The motivation is to guard against crash |
+ // for any reason that XGetWindowProperty fails. For example, at the time that |
+ // XGetWindowProperty is called, the window handler (a.k.a |id.id|) may |
+ // already be invalid due to the fact that the end user has closed the |
+ // corresponding window, etc. |
+ std::unique_ptr<gfx::X11ErrorTracker> error_tracker( |
Lei Zhang
2016/08/30 09:39:34
Can this just be the following?
{
gfx::X11Error
qiangchen
2016/08/30 17:10:45
By other reviewer's comment, as we want to release
|
+ new gfx::X11ErrorTracker()); |
int status = XGetWindowProperty(display, id.id, property, 0L, ~0L, False, |
AnyPropertyType, &actual_type, &actual_format, |
&size, &bytes_after, |
reinterpret_cast<unsigned char**>(&data)); |
+ error_tracker.reset(); |
+ |
if (status != Success) { |
return gfx::ImageSkia(); |
} |