cleanup constructor/destructor, and use auto_ptr where appropriate.

This commit is contained in:
pinkerton%netscape.com 1998-10-30 00:12:37 +00:00
parent ed30457af8
commit 4a9ab4e630
2 changed files with 6 additions and 12 deletions

View File

@ -32,10 +32,10 @@ NS_IMPL_RELEASE(nsMacWindow);
//
//-------------------------------------------------------------------------
nsMacWindow::nsMacWindow() : nsWindow()
, mWindowMadeHere(PR_FALSE), mMacEventHandler(new nsMacEventHandler(this))
{
NS_INIT_REFCNT();
strcpy(gInstanceClassName, "nsMacWindow");
mMacEventHandler = new nsMacEventHandler(this);
}
@ -46,12 +46,6 @@ nsMacWindow::nsMacWindow() : nsWindow()
//-------------------------------------------------------------------------
nsMacWindow::~nsMacWindow()
{
if (mMacEventHandler)
{
delete mMacEventHandler;
mMacEventHandler = nsnull;
}
if (mWindowPtr)
{
nsRefData* theRefData = (nsRefData*)::GetWRefCon(mWindowPtr);
@ -62,8 +56,7 @@ nsMacWindow::~nsMacWindow()
::SetWRefCon(mWindowPtr, theRefData->GetUserData()); // restore the refCon if we did not create the window
mWindowPtr = nsnull;
if (theRefData)
delete theRefData;
delete theRefData;
}
}
@ -201,7 +194,7 @@ PRBool nsMacWindow::HandleOSEvent(
EventRecord& aOSEvent)
{
PRBool retVal;
if (mMacEventHandler)
if (mMacEventHandler.get())
retVal = mMacEventHandler->HandleOSEvent(aOSEvent);
else
retVal = PR_FALSE;
@ -218,7 +211,7 @@ PRBool nsMacWindow::HandleMenuCommand(
long aMenuResult)
{
PRBool retVal;
if (mMacEventHandler)
if (mMacEventHandler.get())
retVal = mMacEventHandler->HandleMenuCommand(aOSEvent, aMenuResult);
else
retVal = PR_FALSE;

View File

@ -20,6 +20,7 @@
#include "nsWindow.h"
#include "nsMacEventHandler.h"
#include "memory" // for auto_ptr
class nsMacEventHandler;
@ -88,7 +89,7 @@ public:
protected:
PRBool mWindowMadeHere; // true if we created the window
nsMacEventHandler* mMacEventHandler;
auto_ptr<nsMacEventHandler> mMacEventHandler;
};