nsToolkit destructor was decrementing the refcount on the global event queue handler; a prelude to stopping event handling. It now does this only if it had previously incremented the refcount: a thing done in Init, not the constructor. bug 21596. r:pinkerton,scc.

This commit is contained in:
danm%netscape.com 2000-02-11 06:56:57 +00:00
Родитель 03c71d0912
Коммит 4cbfb93c9c
2 изменённых файлов: 13 добавлений и 4 удалений

Просмотреть файл

@ -110,7 +110,7 @@ NS_IMPL_ISUPPORTS1(nsToolkit, nsIToolkit);
//-------------------------------------------------------------------------
//
//-------------------------------------------------------------------------
nsToolkit::nsToolkit()
nsToolkit::nsToolkit() : mInited(false)
{
NS_INIT_REFCNT();
if (gEventQueueHandler == nsnull)
@ -122,7 +122,12 @@ nsToolkit::nsToolkit()
//-------------------------------------------------------------------------
nsToolkit::~nsToolkit()
{
if (gEventQueueHandler) {
/* StopPumping decrements a refcount on gEventQueueHandler; a prelude toward
stopping event handling. This is not something you want to do unless you've
bloody well started event handling and incremented the refcount. That's
done in the Init method, not the constructor, and that's what mInited is about.
*/
if (mInited && gEventQueueHandler) {
if (gEventQueueHandler->StopPumping()) {
delete gEventQueueHandler;
gEventQueueHandler = nsnull;
@ -140,6 +145,7 @@ NS_IMETHODIMP nsToolkit::Init(PRThread */*aThread*/)
{
if (gEventQueueHandler)
gEventQueueHandler->StartPumping();
mInited = true;
return NS_OK;
}

Просмотреть файл

@ -64,8 +64,11 @@ public:
NS_IMETHOD Init(PRThread *aThread);
// Appearance Mgr
static bool HasAppearanceManager();
// Appearance Mgr
static bool HasAppearanceManager();
protected:
bool mInited;
};