Index: content/browser/renderer_host/render_widget_host_impl.cc |
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc |
index d84036b63929a0fc5f1ac3c1a1f09bf11180dae6..56c26bd5766385323d62d22df45f9f332770513d 100644 |
--- a/content/browser/renderer_host/render_widget_host_impl.cc |
+++ b/content/browser/renderer_host/render_widget_host_impl.cc |
@@ -2218,9 +2218,11 @@ bool RenderWidgetHostImpl::KeyPressListenersHandleEvent( |
if (event.skip_in_browser || event.type != WebKeyboardEvent::RawKeyDown) |
return false; |
- for (std::list<KeyboardListener*>::iterator it = keyboard_listeners_.begin(); |
- it != keyboard_listeners_.end(); ++it) { |
- if ((*it)->HandleKeyPressEvent(event)) |
+ std::list<KeyboardListener*>::iterator it = keyboard_listeners_.begin(); |
+ while(it != keyboard_listeners_.end()) { |
+ // It is possible for the handler to delete itself and not handle the key |
+ // press. |
+ if ((*(it++))->HandleKeyPressEvent(event)) |
Ilya Sherman
2013/04/18 00:33:32
This isn't guaranteed to work. You should (a) use
csharp
2013/04/18 19:53:02
Ah, I didn't know about ObserverList, awesome.
|
return true; |
} |