Help needed using components as member variables

MichaelB <[email protected]> Thu, 02 Jan 2003 21:58:08 +0100
Newsgroups gmane.comp.mozilla.devel.xpcom
Organization Another Netscape Collabra Server User
Message-ID <[email protected]>
Hello,
whenever I declare a component as a member variable in my own component, 
a Debug Error occurs after my destructor is called. What am I doing wrong?
My class definition looks like this: (only included relevant stuff)

class bciMenu : public bciIMenu
{
public:
   NS_DECL_ISUPPORTS
   NS_DECL_BCIIMENU

   bciMenu();
   virtual ~bciMenu();

  private:
   PRUint8 mClassCount;
   //nsSupportsArray mElementArray;
   //nsCOMArray<nsIDOMElement> mElementArray;
   //nsCOMPtr<nsISupportsArray> mElementArray;
   //nsVoidArray mElementArray;
   PRUint16 mCurPos;
};

Uncommenting either of these lines gives the following message when my 
destructor is called:
"Microsoft Visual C++ Debug Library
Debug Error!
DAMAGE: after Normal block (#180427) at 0x036EB568"

On entering the debugger, I see that the call stack looks like this:
_free_dbg_lk
free
operator delete
bciMenu:: 'scalar deleting destructor
bciMenu::Release

To me it looks like some object is trying to be freed too often! But I 
am not doing anything to mElementArray in my code so I don't see what is 
going wrong. Maybe someone has experienced this and can shed some light 
on the matter? Thanks! Michael