0
我在我的MFC应用程序的简单图像缓存类,跟踪从文件系统加载的图片:Gdiplus ::图像对象和boost :: shared_ptr的
typedef boost::shared_ptr<Gdiplus::Image> ImagePtr;
typedef std::map<std::string, ImagePtr> ImageMap;
每当图像通过文件要求名称,查找完成,或者如果已经加载,则返回相应的ImagePtr。
当我退出我的应用程序并且共享指针被破坏时,会发生此问题。我在这里得到一个访问冲突,在checked_delete.hpp:
// verify that types are complete for increased safety
template<class T> inline void checked_delete(T * x)
{
// intentionally complex - simplification causes regressions
typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
(void) sizeof(type_must_be_complete);
delete x; // <-------- violation here!!
}
是GDI +管理这些对象的给我吗?如果是这样,我需要对我的shared_ptr执行什么操作,以便它不会调用delete?或者是另外一些错误?
在此先感谢!
嗯,我没有明确地实际调用它。但是你提出了一个有趣的观点,因为我依赖于智能指针,并且图像缓存将在CWinApp派生类的析构函数上被破坏。时间去尝试一下:) – 2011-01-26 20:28:43