Hi,
I have a pointer to a map that I am trying to delete (this map was allocated with new).
This map is valid I think, when I hover on it while debugging, it shows pMap
: [0]()
..
When I try to delete this empty map, my app just quits and I get a
First-chance exception at 0xsomelocation in myapp.exe: 0xsomenumber: The object invoked has disconnected from its clients.
in the output window. What does this mean?
Thanks..
EDIT: Here's some sample code:
typedef map<const char*, StructA*, StructB> myMap;
typedef vector<myMap *> myMapStack;
StructB has an overloaded operator ()
Edit: StructB IS indeed a struct, sorry, the operator () is just a string comparing function..
In some part of my code, a class's constructor calls a method, let's call it InitClass(), that initializes a myMap pointer like so:
pMyMap = new myMap; // I also tried this with new myMap()
// this pointer is then pushed onto the a map stack
pMyMapStack.push_back(pMyMap);
Later on in this class' destructor, I go
pMyMap = pMyMapStack.back();
pMyMapStack.pop_back();
delete pMyMap; // after I step over this line the app quits.. and displays that message
Thanks
EDIT: I reverted back to an older version of the code that worked, and it's working fine now..
What worked was something like this:
// after the pMyMapStack.pop_back()
int x = pMyMap->size();
if (x >= 0)
delete pMyMap;
Earlier on I had changed it to this:
// after the pMyMapStack.pop_back()
int (x = pMyMap->size();
if (x >= 0){
pMyMap->clear();
delete pMyMap;
}
Weird.. There might be something else wrong in the code, but I just can't figure out where yet.. It is too big (and I'd probably get fired) if I posted the code in it's entirety so let's just leave it at that..
I think it might have been a pointer to a null map that I was trying to clear or delete that was causing the problems..
Thanks for all those who tried to help... :)