From 3a6268b3b53469089a2d8c451a42f5aed93e2647 Mon Sep 17 00:00:00 2001 From: "ftang%netscape.com" Date: Fri, 10 Dec 1999 20:37:50 +0000 Subject: [PATCH] fix bug 21205. Make nsMacTSMMessagePump a singleton so it won't install and remove TSM AEHandler when modle dialogbox appShell create/destroy. r=pinkerton/waterson --- widget/src/mac/nsMacMessagePump.cpp | 4 +--- widget/src/mac/nsMacTSMMessagePump.cpp | 20 ++++++++++++++++++++ widget/src/mac/nsMacTSMMessagePump.h | 5 +++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/widget/src/mac/nsMacMessagePump.cpp b/widget/src/mac/nsMacMessagePump.cpp index e53440ddd701..474d4c4f2d72 100644 --- a/widget/src/mac/nsMacMessagePump.cpp +++ b/widget/src/mac/nsMacMessagePump.cpp @@ -171,7 +171,7 @@ nsMacMessagePump::nsMacMessagePump(nsToolkit *aToolkit, nsMacMessageSink* aSink) // // create the TSM Message Pump // - mTSMMessagePump = new nsMacTSMMessagePump(); + mTSMMessagePump = nsMacTSMMessagePump::GetSingleton(); NS_ASSERTION(mTSMMessagePump!=NULL,"nsMacMessagePump::nsMacMessagePump: Unable to create TSM Message Pump."); } @@ -192,8 +192,6 @@ nsMacMessagePump::~nsMacMessagePump() // // release the TSM Message Pump // - if (mTSMMessagePump) - delete mTSMMessagePump; } //================================================================= diff --git a/widget/src/mac/nsMacTSMMessagePump.cpp b/widget/src/mac/nsMacTSMMessagePump.cpp index 544c331fd05d..3b4daf449488 100644 --- a/widget/src/mac/nsMacTSMMessagePump.cpp +++ b/widget/src/mac/nsMacTSMMessagePump.cpp @@ -91,6 +91,26 @@ nsMacTSMMessagePump::~nsMacTSMMessagePump() #endif } +//------------------------------------------------------------------------- +nsMacTSMMessagePump* nsMacTSMMessagePump::gSingleton = nsnull; +//------------------------------------------------------------------------- +nsMacTSMMessagePump* nsMacTSMMessagePump::GetSingleton() +{ + if(nsnull == gSingleton) + { + gSingleton = new nsMacTSMMessagePump(); + NS_ASSERTION(gSingleton!=NULL,"nsMacTSMMessagePump::GetSingleton: Unable to create TSM Message Pump."); + } + return gSingleton; +} +//------------------------------------------------------------------------- +void nsMacTSMMessagePump::Shutdown() +{ + if(gSingleton) { + delete gSingleton; + gSingleton = nsnull; + } +} //------------------------------------------------------------------------- // diff --git a/widget/src/mac/nsMacTSMMessagePump.h b/widget/src/mac/nsMacTSMMessagePump.h index 8b712e9a771c..2308dbbc7fbc 100644 --- a/widget/src/mac/nsMacTSMMessagePump.h +++ b/widget/src/mac/nsMacTSMMessagePump.h @@ -41,6 +41,9 @@ public: nsMacTSMMessagePump(); ~nsMacTSMMessagePump(); + static nsMacTSMMessagePump* GetSingleton(); + void Shutdown(); + private: static pascal OSErr PositionToOffsetHandler(const AppleEvent *theAppleEvent, AppleEvent *reply, UInt32 handlerRefcon); static pascal OSErr OffsetToPositionHandler(const AppleEvent *theAppleEvent, AppleEvent *reply, UInt32 handlerRefcon); @@ -48,6 +51,8 @@ private: static AEEventHandlerUPP mPos2OffsetUPP; static AEEventHandlerUPP mOffset2PosUPP; static AEEventHandlerUPP mUpdateUPP; + + static nsMacTSMMessagePump* gSingleton; };