From 4cbfb93c9ccf2c995a239399433dc68138562f64 Mon Sep 17 00:00:00 2001 From: "danm%netscape.com" Date: Fri, 11 Feb 2000 06:56:57 +0000 Subject: [PATCH] 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. --- widget/src/mac/nsToolkit.cpp | 10 ++++++++-- widget/src/mac/nsToolkit.h | 7 +++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/widget/src/mac/nsToolkit.cpp b/widget/src/mac/nsToolkit.cpp index 745c1a7443be..31e3dc1f2d26 100644 --- a/widget/src/mac/nsToolkit.cpp +++ b/widget/src/mac/nsToolkit.cpp @@ -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; } diff --git a/widget/src/mac/nsToolkit.h b/widget/src/mac/nsToolkit.h index 538457bddb4e..f594b5304c17 100644 --- a/widget/src/mac/nsToolkit.h +++ b/widget/src/mac/nsToolkit.h @@ -64,8 +64,11 @@ public: NS_IMETHOD Init(PRThread *aThread); - // Appearance Mgr - static bool HasAppearanceManager(); + // Appearance Mgr + static bool HasAppearanceManager(); + +protected: + bool mInited; };