|
|
Created:
11 years, 1 month ago by Mark Mentovai Modified:
9 years, 7 months ago CC:
chromium-reviews_googlegroups.com, brettw+cc_chromium.org, ben+cc_chromium.org, John Grabowski, jam, pam+watch_chromium.org, darin (slow to review) Base URL:
svn://svn.chromium.org/chrome/trunk/src/ Visibility:
Public. |
DescriptionMake sure RenderWidgetHostViewCocoa doesn't disappear inside of -keyEvent:
BUG=25857
TEST=see bug 25857 comment 10
Patch Set 1 #
Total comments: 2
Patch Set 2 : '' #Patch Set 3 : '' #
Total comments: 1
Messages
Total messages: 11 (0 generated)
Take a look at the bug too. I'm not terribly familiar with the ownership model in here, and I don't know if this is ultimately the best way to go.
http://codereview.chromium.org/341022/diff/1/2 File chrome/browser/renderer_host/render_widget_host_view_mac.mm (right): http://codereview.chromium.org/341022/diff/1/2#newcode586 Line 586: widgetHost->ForwardKeyboardEvent(event); After r30032 , we can be destroyed after this line. Both windows and linux don't do anything after this call, so they should be fine. Wouldn't it be better to set some flag in `dealloc` and then return after this lien? That way interpretKeyEvents: is not called (it _should_ be save, because cmd-w etc shouldn't trigger an IME key anyway, but it feels more explicit)
http://codereview.chromium.org/341022/diff/1/2 File chrome/browser/renderer_host/render_widget_host_view_mac.mm (right): http://codereview.chromium.org/341022/diff/1/2#newcode586 Line 586: widgetHost->ForwardKeyboardEvent(event); Nico wrote: > After r30032 , we can be destroyed after this line. Both windows and linux don't > do anything after this call, so they should be fine. > > Wouldn't it be better to set some flag in `dealloc` and then return after this > lien? That way interpretKeyEvents: is not called (it _should_ be save, because > cmd-w etc shouldn't trigger an IME key anyway, but it feels more explicit) How do you propose we do this? Set a member variable flag in this object as we're destroying it? Ain't gonna work.
Give this object a pointer that we make point to a variable on the stack at the beginning of keyEvent:. During dealloc, the pointer would still be valid, and back in the method, the stack variable is still valid. On Wed, Oct 28, 2009 at 10:02 AM, <mark@chromium.org> wrote: > > http://codereview.chromium.org/341022/diff/1/2 > File chrome/browser/renderer_host/render_widget_host_view_mac.mm > (right): > > http://codereview.chromium.org/341022/diff/1/2#newcode586 > Line 586: widgetHost->ForwardKeyboardEvent(event); > Nico wrote: >> >> After r30032 , we can be destroyed after this line. Both windows and > > linux don't >> >> do anything after this call, so they should be fine. > >> Wouldn't it be better to set some flag in `dealloc` and then return > > after this >> >> lien? That way interpretKeyEvents: is not called (it _should_ be save, > > because >> >> cmd-w etc shouldn't trigger an IME key anyway, but it feels more > > explicit) > > How do you propose we do this? =A0Set a member variable flag in this > object as we're destroying it? =A0Ain't gonna work. > > http://codereview.chromium.org/341022 >
On 2009/10/28 17:03:50, Nico wrote: > Give this object a pointer that we make point to a variable on the > stack at the beginning of keyEvent:. During dealloc, the pointer would > still be valid, and back in the method, the stack variable is still > valid. > > On Wed, Oct 28, 2009 at 10:02 AM, <mailto:mark@chromium.org> wrote: > > > > http://codereview.chromium.org/341022/diff/1/2 > > File chrome/browser/renderer_host/render_widget_host_view_mac.mm > > (right): > > > > http://codereview.chromium.org/341022/diff/1/2#newcode586 > > Line 586: widgetHost->ForwardKeyboardEvent(event); > > Nico wrote: > >> > >> After r30032 , we can be destroyed after this line. Both windows and > > > > linux don't > >> > >> do anything after this call, so they should be fine. > > > >> Wouldn't it be better to set some flag in `dealloc` and then return > > > > after this > >> > >> lien? That way interpretKeyEvents: is not called (it _should_ be save, > > > > because > >> > >> cmd-w etc shouldn't trigger an IME key anyway, but it feels more > > > > explicit) > > > > How do you propose we do this? =A0Set a member variable flag in this > > object as we're destroying it? =A0Ain't gonna work. > > > > http://codereview.chromium.org/341022 > > Mark, this is what I wanted to talk to you about runloops for. I think we can avoid all of this (and the somewhat equivalent hack in the browser window) if we got rid of the autorelease pool in our CFRunLoopSource.... but I needed more data on why that was there. I assume we can cover this when we chat.
Nico wrote: > Give this object a pointer that we make point to a variable on the > stack at the beginning of keyEvent:. During dealloc, the pointer would > still be valid, and back in the method, the stack variable is still > valid. I see what you're driving at. I think that the stack boolean thing is a little hokey, but I've come up with an alternative. Do you like this better?
I do. LGTM, but please add a comment that mentions somewhere that the current tab / browser might be gone after |widgetHost->ForwardKeyboardEvent(event);|
On 2009/10/28 18:04:50, Nico wrote: > I do. LGTM, but please add a comment that mentions somewhere that the current > tab / browser might be gone after |widgetHost->ForwardKeyboardEvent(event);| Mark... can you still hold off on this until our meeting? I think I may have a better solution, and I'm afraid you are putting a bandage on a bigger problem. Maybe add Nico to the meeting if he's interested?
Right, I wasn't planning on checking this in until we spoke. Mark dmaclach@chromium.org wrote: > On 2009/10/28 18:04:50, Nico wrote: >> >> I do. LGTM, but please add a comment that mentions somewhere that the >> current >> tab / browser might be gone after >> |widgetHost->ForwardKeyboardEvent(event);| > > Mark... can you still hold off on this until our meeting? I think I may have > a > better solution, and I'm afraid you are putting a bandage on a bigger > problem. > Maybe add Nico to the meeting if he's interested? > > > http://codereview.chromium.org/341022 >
drive-by. After the meeting, what have we decided? http://codereview.chromium.org/341022/diff/4003/4004 File chrome/browser/renderer_host/render_widget_host_view_mac.mm (right): http://codereview.chromium.org/341022/diff/4003/4004#newcode557 Line 557: scoped_nsobject<RenderWidgetHostViewCocoa> keepSelfAlive([self retain]); in mozilla these were generally named kungFuDeathGrip with nsCOMPtr :=)
I'm closing this without checking it in. It shouldn't be needed once we get http://codereview.chromium.org/343024. |