Suppose I have this code...
class GraphFactory : public QObject
{
private:
QMap<QString, IGraphCreator*> factory_;
public:
virtual ~GraphFactory();
};
GraphFactory::~GraphFactory()
{
// Free up the graph creators
QMap<QString, IGraphCreator*>::iterator itr;
for (itr = factory_.begin(); itr != factory_.end(); itr++)
{
IGraphCreator * creator = itr.value();
delete creator;
creator = NULL;
}
}
When is the QMap factory_ destroyed? Before the call to the destructor, or during the destructor? (I understand that the destructor will be called when an instance of GraphFactory goes out of scope. But when are the non-pointers member destroyed?)
Edit: I am getting invalid values for the factory_ map when it reaches the destructor. A break point shows that the value wouldn't have tampered with the value stored inside the QMap.