Re: How to get WebBrowser to release the APP object??
Tim Ward <tw2@ipaccess.com> wrote:
I've got an SDI application with a CHtmlView.
In the same .exe is an Asynchronous Pluggable Protocol implementation.
In the view's OnInitialUpdate I do the RegisterNameSpace() stuff so
that the WebBrowser knows where to find my APP, all of which works
fine.
The trouble is that the application won't shut down, and this turns
out to be because AfxOleCanExitApp says it can't exit because there
is one object still in use.
Are you calling UnregisterNameSpace when shutting down?
Tracing the calls to construct and destroy my object that implements
IInternetProtocol I observe that a dozen or so such objects are
constructed, and all but one of them are immediately destroyed
without being used. (Why, I wonder?? - but never mind, that's not the
problem.)
I'll answer anyway. Every time browser needs to manipulate a URL (e.g.
to resolve a relative URL of the link or image references against the
base URL of the page, or to determine security context) it constructs an
instance of your APP in hopes that it implements IInternetProtocolInfo.
Yours probably doesn't, so an instance is created, queried for
IInternetProtocolInfo and immediately released.
The one object that is actually used (from Start() to Read(), all
works OK) appears never to be destroyed, so I'm assuming that this is
the one object that is causing AfxOldCanExitApp to refuse to shut
down the application.
Are you releasing the sink pointer in your Terminate implementation?
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925