Closed
Bug 107485
Opened 24 years ago
Closed 21 years ago
nsPluginHostImpl's shutdown listener should be a weak reference
Categories
(Core Graveyard :: Plug-ins, defect)
Tracking
(Not tracked)
RESOLVED
FIXED
People
(Reporter: depman1, Assigned: timeless)
References
Details
Attachments
(1 obsolete file)
reproduced with 10/27 debug mozilla nightly build.
1. Set up debugger in VC++ & set breakpoint in nsComponentManager.cpp: line 2075
2. Launch app in the debugger (F5).
3. Quit the app.
4. Check the stack trace and doubleclick on destructor line:
nsPluginHostImpl::~nsPluginHostImpl() line 2430
Result: Destructor in nsPluginHostImpl() calls do_GetService
Expected: Should register shutdown listener.
Here's the code for the destructor. It's using nsIObserverService object:
nsPluginHostImpl::~nsPluginHostImpl()
{
PLUGIN_LOG(PLUGIN_LOG_ALWAYS,("nsPluginHostImpl::dtor\n"));
#ifdef NS_DEBUG
printf("nsPluginHostImpl dtor\n");
#endif
nsCOMPtr<nsIObserverService> obsService =
do_GetService("@mozilla.org/observer-service;1");
if (obsService)
{
obsService->RemoveObserver(this, "quit-application");
obsService->RemoveObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID);
}
Destroy();
}
Comment 1•24 years ago
|
||
We are already using a shutdown listener here! In fact, the code in the
destructor is unregistering the listener and thefore needs to
do_GetService(nsIObserverService). Would it help to move this unregistering code
to nsPluginHostImpl::Destroy()? This can only be called once....whoever is
first, either the shutdown observer or ~nsPluginHostImpl. Please advise.
I recall one of the reason this being done was there once a bug (and could still
be) that ~nsPluginHostImpl would not always be called at browser shutdown and
plugins wouldn't be able to clean themselves up (bad!). I think one of the
reason it wasn't called was because the service manager was being held past
XPCOM shutdown. Well, it just so happens, that at least on Windows, the JRE
1.3.x Java plugin would hold on to the service manager and cause this bug! I'm
not sure if this is accurate, but I was told the reason Java did this was for
the Java console or taskbar icon or something.
Comment 2•24 years ago
|
||
You should impl nsWeakReference, and then use PR_TRUE as the last argument to
AddObserver. That way you won't need to unregister yourself.
Comment 3•24 years ago
|
||
did I get it right?
Comment 4•24 years ago
|
||
removing myself from cc:
bug 100212 comment 38 fixed the core problem.
Assignee: av → timeless
Comment 6•24 years ago
|
||
Comment on attachment 71484 [details] [diff] [review]
patch
yup, you got it right. r=dougt.
Attachment #71484 -
Flags: review+
Status: NEW → ASSIGNED
Summary: nsPluginHostImpl calls getService on shutdown; should register shutdown listener → nsPluginHostImpl's shutdown listener should be a weak reference
Comment 7•24 years ago
|
||
Comment on attachment 71484 [details] [diff] [review]
patch
sr=darin
Attachment #71484 -
Flags: superreview+
| Reporter | ||
Comment 8•22 years ago
|
||
wasn't this supposed to be checked in?
Comment on attachment 71484 [details] [diff] [review]
patch
2002-05-30:
mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp 1.390
mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp 1.389
mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp 1.388
mozilla/modules/plugin/base/src/nsPluginHostImpl.h 1.77
Attachment #71484 -
Attachment is obsolete: true
Status: ASSIGNED → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Updated•4 years ago
|
Product: Core → Core Graveyard
You need to log in
before you can comment on or make changes to this bug.
Description
•