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

Unified Diff: chrome/browser/renderer_host/render_widget_host_view_mac.mm

Issue 341022: Make sure RenderWidgetHostViewCocoa doesn't disappear inside of -keyEvent: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/renderer_host/render_widget_host_view_mac.mm
===================================================================
--- chrome/browser/renderer_host/render_widget_host_view_mac.mm (revision 30343)
+++ chrome/browser/renderer_host/render_widget_host_view_mac.mm (working copy)
@@ -5,7 +5,7 @@
#include "chrome/browser/renderer_host/render_widget_host_view_mac.h"
#include "base/histogram.h"
-#include "base/scoped_nsobject.h"
+#import "base/scoped_nsobject.h"
#include "base/string_util.h"
#include "base/sys_string_conversions.h"
#include "chrome/browser/browser_trial.h"
@@ -544,7 +544,7 @@
if (ignoreKeyEvents_)
return NO;
- // We have some magic in |CrApplication sendEvent:| that always sends key
+ // We have some magic in |CrApplication sendEvent:| that always sends key
// events to |keyEvent:| so that cocoa doesn't have a chance to intercept it.
DCHECK([[self window] firstResponder] != self);
return NO;
@@ -554,8 +554,7 @@
if (ignoreKeyEvents_)
return;
- // TODO(avi): Possibly kill self? See RenderWidgetHostViewWin::OnKeyEvent and
- // http://b/issue?id=1192881 .
+ scoped_nsobject<RenderWidgetHostViewCocoa> keepSelfAlive([self retain]);
pink (ping after 24hrs) 2009/10/28 19:56:40 in mozilla these were generally named kungFuDeathG
// Don't cancel child popups; the key events are probably what's triggering
// the popup in the first place.
@@ -591,7 +590,14 @@
// To send an onkeydown() event before an onkeypress() event, we should
// dispatch this NSKeyDown event AFTER sending it to the renderer.
// (See <https://bugs.webkit.org/show_bug.cgi?id=25119>).
- if ([theEvent type] == NSKeyDown)
+ //
+ // If this object's retainCount is 1, the only reference is the one held by
+ // keepSelfAlive. All other references may have been destroyed in the
+ // RenderWidgetHost::ForwardKeyboardEvent call above if it resulted in tab
+ // closure. Were it not for that single reference, this object would
+ // already be deallocated. In that case, there's no point in calling
+ // -interpretKeyEvents:.
+ if ([self retainCount] > 1 && [theEvent type] == NSKeyDown)
[self interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
// Possibly autohide the cursor.
@@ -1255,4 +1261,3 @@
}
@end
-
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698