HandleBeforeWindowClose and HandleLoadEnd

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

HandleBeforeWindowClose and HandleLoadEnd

Postby emerick » Fri Aug 20, 2010 9:24 am

I've run into situations (typically when loading long web pages) where HandleLoadEnd is being called after HandleBeforeWindowClose. The situation usually looks like this:

1. Load a long-ish web page (maybe NYT front page or Google News or something like that).
2. Close the browser before it finishes loading.
3. HandleBeforeWindowClose triggers.
4. HandleLoadEnd triggers.

In my particular application, I end up crashing in HandleLoadEnd (step 4), because I'm trying to dereference a cached browser pointer that was set to NULL by HandleBeforeWindowClose. Obviously, I can guard against dereferencing the NULL pointer, but I'm wondering if this sequence of events is intended. It seems to me that when HandleBeforeWindowClose triggers, I shouldn't receive any additional events from CEF after that point, since that's occuring post-WM_DESTROY.

Please correct me if I'm mistaken in any of this! If this is indeed a bug, I'd be happy to open a new case; I just wanted to run it by everyone here first.

Thanks,

Emerick
emerick
Expert
 
Posts: 154
Joined: Sun Feb 21, 2010 7:57 pm
Location: Belmont, MA

Re: HandleBeforeWindowClose and HandleLoadEnd

Postby magreenblatt » Mon Aug 23, 2010 8:40 am

HandleBeforeWindowClose is called before the WebKit window is destroyed. If a page is currently loading then that load is not canceled and HandleLoadEnd is not called until the window is actually in the process of being destroyed. This is likely the situation that you're seeing.

It would probably be better to cancel the load and make sure HandleLoadEnd is called before HandleBeforeWindowClose.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: HandleBeforeWindowClose and HandleLoadEnd

Postby emerick » Tue Aug 24, 2010 9:39 am

Right, I think that makes sense. Would you like me to enter a bug for this?

Emerick
emerick
Expert
 
Posts: 154
Joined: Sun Feb 21, 2010 7:57 pm
Location: Belmont, MA

Re: HandleBeforeWindowClose and HandleLoadEnd

Postby magreenblatt » Tue Aug 24, 2010 9:44 am

Would you like me to enter a bug for this?

Sure. A patch would be even better ;-).
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: HandleBeforeWindowClose and HandleLoadEnd

Postby emerick » Tue Aug 24, 2010 9:53 am

Haha, fair enough. I'll start by entering a bug. :-)
emerick
Expert
 
Posts: 154
Joined: Sun Feb 21, 2010 7:57 pm
Location: Belmont, MA


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 75 guests