假设我有这个代码......
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;
}
}
QMap factory_什么时候销毁?在调用析构函数之前,还是在析构函数期间?(我知道当 GraphFactory 的实例超出范围时将调用析构函数。但是非指针成员何时被销毁?)
编辑:当 factory_ map 到达析构函数时,我得到了无效的值。断点表明该值不会篡改存储在 QMap 中的值。