diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-25 20:35:20 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-25 20:35:20 +0000 |
commit | 8402216f491cfbc56d41b47a871b2609a6e47ffe (patch) | |
tree | 0f64ce92e8b149b00d97a34f9fefd0b6c6f8f6fd /gfx | |
parent | 4c46659fc913b8507f2c4df8eab96b1bda248199 (diff) | |
download | chromium_src-8402216f491cfbc56d41b47a871b2609a6e47ffe.zip chromium_src-8402216f491cfbc56d41b47a871b2609a6e47ffe.tar.gz chromium_src-8402216f491cfbc56d41b47a871b2609a6e47ffe.tar.bz2 |
GTK: add more syncronization to GtkNativeViewIdManager to avoid a crash.
BUG=46197
TEST=manual (see bug)
Review URL: http://codereview.chromium.org/2860024
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50886 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gfx')
-rw-r--r-- | gfx/gtk_native_view_id_manager.cc | 1 | ||||
-rw-r--r-- | gfx/gtk_native_view_id_manager.h | 16 |
2 files changed, 13 insertions, 4 deletions
diff --git a/gfx/gtk_native_view_id_manager.cc b/gfx/gtk_native_view_id_manager.cc index 47dc2fb..91407283a 100644 --- a/gfx/gtk_native_view_id_manager.cc +++ b/gfx/gtk_native_view_id_manager.cc @@ -116,6 +116,7 @@ void GtkNativeViewManager::OnRealize(gfx::NativeView widget) { } void GtkNativeViewManager::OnUnrealize(gfx::NativeView widget) { + AutoLock unrealize_locked(unrealize_lock_); AutoLock locked(lock_); const gfx::NativeViewId id = GetWidgetId(widget); diff --git a/gfx/gtk_native_view_id_manager.h b/gfx/gtk_native_view_id_manager.h index 048cd2d..3a23942 100644 --- a/gfx/gtk_native_view_id_manager.h +++ b/gfx/gtk_native_view_id_manager.h @@ -63,6 +63,8 @@ class GtkNativeViewManager { void OnUnrealize(gfx::NativeView widget); void OnDestroy(gfx::NativeView widget); + Lock& unrealize_lock() { return unrealize_lock_; } + private: // This object is a singleton: GtkNativeViewManager(); @@ -78,12 +80,18 @@ class GtkNativeViewManager { gfx::NativeViewId GetWidgetId(gfx::NativeView id); + // This lock can be used to block GTK from unrealizing windows. This is needed + // when the BACKGROUND_X11 thread is using a window obtained via GetXIDForId, + // and can't allow the X11 resource to be deleted. + Lock unrealize_lock_; + // protects native_view_to_id_ and id_to_info_ Lock lock_; - // If asked for an id for the same widget twice, we want to return the same - // id. So this records the current mapping. - std::map<gfx::NativeView, gfx::NativeViewId> native_view_to_id_; - std::map<gfx::NativeViewId, NativeViewInfo> id_to_info_; + + // If asked for an id for the same widget twice, we want to return the same + // id. So this records the current mapping. + std::map<gfx::NativeView, gfx::NativeViewId> native_view_to_id_; + std::map<gfx::NativeViewId, NativeViewInfo> id_to_info_; DISALLOW_COPY_AND_ASSIGN(GtkNativeViewManager); }; |