C XTREE崩溃在出口上,映射/设置迭代器不可用

C++ XTree crash on exit, map/set iterator not dereferencable

本文关键字:设置 迭代器 映射 崩溃 XTREE 出口      更新时间:2023-10-16

我有一些静态类,其中std :: map在其中,一切正常,但是当我退出程序时,它会以错误的"映射/设置迭代器不可删除"崩溃。

这是地图:

struct DataSegment_P { std::string type; };
template <typename T> struct DataSegment : public DataSegment_P{ T value; };
static std::map<std::string, DataSegment_P*> data;

另外两个:

static std::map<std::string, std::shared_ptr<sf::Texture>> textures;
static std::map<std::pair<std::string, std::vector<int>>, std::shared_ptr<sf::Sprite>> sprites;

和最后一个:

struct Asset {
    std::map<std::string, std::string> values;
};
static std::map<std::string, std::vector<std::shared_ptr<Asset>>> assets;

我不能在这里真正粘贴整个代码,因为它是数千行的长度,但是我要清理图。

好吧,我发现了问题。对不起,但是您无法猜到它,所以我只是指出问题,所以如果像我这样的人可以解决它。

我正在使用SFML,我发现您不能在其中使用SF :: RenderWindow的智能指针。那就是导致坠机的原因。