mirror of https://github.com/axmolengine/axmol.git
Fixed FontAtlasCache::purgeCachedData might cause crash.
This commit is contained in:
parent
8cdcade07a
commit
2c220092e6
|
@ -39,7 +39,8 @@ std::unordered_map<std::string, FontAtlas *> FontAtlasCache::_atlasMap;
|
|||
|
||||
void FontAtlasCache::purgeCachedData()
|
||||
{
|
||||
for (auto & atlas:_atlasMap)
|
||||
auto atlasMapCopy = _atlasMap;
|
||||
for (auto&& atlas : atlasMapCopy)
|
||||
{
|
||||
atlas.second->purgeTexturesAtlas();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "LabelTestNew.h"
|
||||
#include "../testResource.h"
|
||||
#include "renderer/CCRenderer.h"
|
||||
#include "2d/CCFontAtlasCache.h"
|
||||
|
||||
USING_NS_CC;
|
||||
using namespace ui;
|
||||
|
@ -85,6 +86,7 @@ NewLabelTests::NewLabelTests()
|
|||
ADD_TEST_CASE(LabelIssue11585Test);
|
||||
ADD_TEST_CASE(LabelFullTypeFontTest);
|
||||
ADD_TEST_CASE(LabelIssue10688Test);
|
||||
ADD_TEST_CASE(LabelIssue13202Test);
|
||||
};
|
||||
|
||||
LabelTTFAlignmentNew::LabelTTFAlignmentNew()
|
||||
|
@ -2058,3 +2060,28 @@ std::string LabelIssue10688Test::subtitle() const
|
|||
{
|
||||
return "The MenuItemLabel should be displayed in the middle of the screen.";
|
||||
}
|
||||
|
||||
LabelIssue13202Test::LabelIssue13202Test()
|
||||
{
|
||||
auto center = VisibleRect::center();
|
||||
|
||||
auto label = Label::createWithTTF("asdfghjklzxcvbnmqwertyuiop", "fonts/arial.ttf", 150);
|
||||
label->setPosition(center);
|
||||
addChild(label);
|
||||
|
||||
label->getContentSize();
|
||||
label->setString("A");
|
||||
this->scheduleOnce([](float dt){
|
||||
FontAtlasCache::purgeCachedData();
|
||||
}, 0.15f, "FontAtlasCache::purgeCachedData");
|
||||
}
|
||||
|
||||
std::string LabelIssue13202Test::title() const
|
||||
{
|
||||
return "Test for Issue #13202";
|
||||
}
|
||||
|
||||
std::string LabelIssue13202Test::subtitle() const
|
||||
{
|
||||
return "FontAtlasCache::purgeCachedData should not cause crash.";
|
||||
}
|
||||
|
|
|
@ -658,4 +658,15 @@ public:
|
|||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
||||
class LabelIssue13202Test : public AtlasDemoNew
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(LabelIssue13202Test);
|
||||
|
||||
LabelIssue13202Test();
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue