MCPcopy Create free account
hub / github.com/axmolengine/axmol / reset

Method reset

tests/cpp-tests/Source/BugsTest/Bug-422.cpp:45–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45void Bug422Layer::reset()
46{
47 static int localtag = 0;
48 localtag++;
49
50 // TO TRIGGER THE BUG:
51 // remove the itself from parent from an action
52 // The menu will be removed, but the instance will be alive
53 // and then a new node will be allocated occupying the memory.
54 // => CRASH BOOM BANG
55 auto node = getChildByTag(localtag - 1);
56 AXLOGD("Menu: {}", fmt::ptr(node));
57 removeChild(node, true);
58 // [self removeChildByTag:localtag-1 cleanup:NO];
59
60 auto item1 = MenuItemFont::create("One", AX_CALLBACK_1(Bug422Layer::menuCallback, this));
61 AXLOGD("MenuItemFont: {}", fmt::ptr(item1));
62 MenuItem* item2 = MenuItemFont::create("Two", AX_CALLBACK_1(Bug422Layer::menuCallback, this));
63 auto menu = Menu::create(item1, item2, nullptr);
64 menu->alignItemsVertically();
65
66 float x = AXRANDOM_0_1() * 50;
67 float y = AXRANDOM_0_1() * 50;
68 menu->setPosition(menu->getPosition() + Vec2(x, y));
69 addChild(menu, 0, localtag);
70
71 //[self check:self];
72}
73
74void Bug422Layer::check(Node* t)
75{

Callers 14

mainFunction · 0.45
axmol_android_app_initFunction · 0.45
mainFunction · 0.45
axmol_android_app_initFunction · 0.45
mainFunction · 0.45
axmol_android_app_initFunction · 0.45
mainFunction · 0.45
axmol_android_app_initFunction · 0.45
mainFunction · 0.45
axmol_android_app_initFunction · 0.45
mainFunction · 0.45
axmol_android_app_initFunction · 0.45

Calls 7

getChildByTagFunction · 0.85
createFunction · 0.85
alignItemsVerticallyMethod · 0.80
ptrFunction · 0.50
Vec2Function · 0.50
setPositionMethod · 0.45
getPositionMethod · 0.45

Tested by 2

DownloaderTestMethod · 0.36
DownloaderMultiTaskMethod · 0.36