From 8a995004585ff82f49eda586e23b273317a1b7fc Mon Sep 17 00:00:00 2001 From: "rods%netscape.com" Date: Fri, 5 Mar 1999 15:33:40 +0000 Subject: [PATCH] Fixed voidarray problem and a few other minor things --- widget/src/windows/nsMenuItem.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/widget/src/windows/nsMenuItem.cpp b/widget/src/windows/nsMenuItem.cpp index 587d8674370..57a340c1b45 100644 --- a/widget/src/windows/nsMenuItem.cpp +++ b/widget/src/windows/nsMenuItem.cpp @@ -54,16 +54,16 @@ nsresult nsMenuItem::QueryInterface(REFNSIID aIID, void** aInstancePtr) NS_ADDREF_THIS(); return NS_OK; } - if (aIID.Equals(kISupportsIID)) { - *aInstancePtr = (void*)(nsISupports*)(nsIMenuItem*)this; - NS_ADDREF_THIS(); - return NS_OK; - } if (aIID.Equals(kIMenuListenerIID)) { *aInstancePtr = (void*)(nsIMenuListener*)this; NS_ADDREF_THIS(); return NS_OK; } + if (aIID.Equals(kISupportsIID)) { + *aInstancePtr = (void*)(nsISupports*)(nsIMenuItem*)this; + NS_ADDREF_THIS(); + return NS_OK; + } return NS_NOINTERFACE; } @@ -94,6 +94,7 @@ nsMenuItem::~nsMenuItem() { NS_IF_RELEASE(mMenu); NS_IF_RELEASE(mTarget); + NS_IF_RELEASE(mListener); } //------------------------------------------------------------------------- @@ -145,6 +146,7 @@ NS_METHOD nsMenuItem::Create(nsIMenu * aParent, const nsString &aLabel, PRUint32 mCommand = aCommand; mLabel = aLabel; mMenu = aParent; + NS_ADDREF(mMenu); nsISupports * sups; if (NS_OK == aParent->QueryInterface(kISupportsIID,(void**)&sups)) { @@ -214,6 +216,7 @@ NS_METHOD nsMenuItem::GetCommand(PRUint32 & aCommand) NS_METHOD nsMenuItem::GetTarget(nsIWidget *& aTarget) { aTarget = mTarget; + NS_ADDREF(mTarget); return NS_OK; } @@ -227,12 +230,16 @@ NS_METHOD nsMenuItem::GetNativeData(void *& aData) NS_METHOD nsMenuItem::AddMenuListener(nsIMenuListener * aMenuListener) { mListener = aMenuListener; + NS_ADDREF(mListener); return NS_OK; } //------------------------------------------------------------------------- NS_METHOD nsMenuItem::RemoveMenuListener(nsIMenuListener * aMenuListener) { + if (mListener == aMenuListener) { + NS_IF_RELEASE(mListener); + } return NS_OK; }