Fixed voidarray problem and a few other minor things

This commit is contained in:
rods%netscape.com 1999-03-05 15:33:40 +00:00
Родитель 20cfbbcb94
Коммит 8a99500458
1 изменённых файлов: 12 добавлений и 5 удалений

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

@ -54,16 +54,16 @@ nsresult nsMenuItem::QueryInterface(REFNSIID aIID, void** aInstancePtr)
NS_ADDREF_THIS(); NS_ADDREF_THIS();
return NS_OK; return NS_OK;
} }
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*)(nsISupports*)(nsIMenuItem*)this;
NS_ADDREF_THIS();
return NS_OK;
}
if (aIID.Equals(kIMenuListenerIID)) { if (aIID.Equals(kIMenuListenerIID)) {
*aInstancePtr = (void*)(nsIMenuListener*)this; *aInstancePtr = (void*)(nsIMenuListener*)this;
NS_ADDREF_THIS(); NS_ADDREF_THIS();
return NS_OK; return NS_OK;
} }
if (aIID.Equals(kISupportsIID)) {
*aInstancePtr = (void*)(nsISupports*)(nsIMenuItem*)this;
NS_ADDREF_THIS();
return NS_OK;
}
return NS_NOINTERFACE; return NS_NOINTERFACE;
} }
@ -94,6 +94,7 @@ nsMenuItem::~nsMenuItem()
{ {
NS_IF_RELEASE(mMenu); NS_IF_RELEASE(mMenu);
NS_IF_RELEASE(mTarget); NS_IF_RELEASE(mTarget);
NS_IF_RELEASE(mListener);
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@ -145,6 +146,7 @@ NS_METHOD nsMenuItem::Create(nsIMenu * aParent, const nsString &aLabel, PRUint32
mCommand = aCommand; mCommand = aCommand;
mLabel = aLabel; mLabel = aLabel;
mMenu = aParent; mMenu = aParent;
NS_ADDREF(mMenu);
nsISupports * sups; nsISupports * sups;
if (NS_OK == aParent->QueryInterface(kISupportsIID,(void**)&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) NS_METHOD nsMenuItem::GetTarget(nsIWidget *& aTarget)
{ {
aTarget = mTarget; aTarget = mTarget;
NS_ADDREF(mTarget);
return NS_OK; return NS_OK;
} }
@ -227,12 +230,16 @@ NS_METHOD nsMenuItem::GetNativeData(void *& aData)
NS_METHOD nsMenuItem::AddMenuListener(nsIMenuListener * aMenuListener) NS_METHOD nsMenuItem::AddMenuListener(nsIMenuListener * aMenuListener)
{ {
mListener = aMenuListener; mListener = aMenuListener;
NS_ADDREF(mListener);
return NS_OK; return NS_OK;
} }
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
NS_METHOD nsMenuItem::RemoveMenuListener(nsIMenuListener * aMenuListener) NS_METHOD nsMenuItem::RemoveMenuListener(nsIMenuListener * aMenuListener)
{ {
if (mListener == aMenuListener) {
NS_IF_RELEASE(mListener);
}
return NS_OK; return NS_OK;
} }