PagesControl leak fix

This commit is contained in:
MihailRis 2023-11-20 03:59:59 +03:00
parent 4ea7bda249
commit 3b5c039db1
2 changed files with 4 additions and 7 deletions

View File

@ -184,9 +184,7 @@ PagesControl::PagesControl() : Container(vec2(), vec2(1)){
}
void PagesControl::add(std::string name, std::shared_ptr<UINode> panel) {
panel->visible(false);
pages[name] = Page{panel};
Container::add(panel);
}
void PagesControl::set(std::string name, bool history) {
@ -195,14 +193,14 @@ void PagesControl::set(std::string name, bool history) {
throw std::runtime_error("no page found");
}
if (current_.panel) {
current_.panel->visible(false);
Container::remove(current_.panel);
}
if (history) {
pageStack.push(curname_);
}
curname_ = name;
current_ = found->second;
current_.panel->visible(true);
Container::add(current_.panel);
size(current_.panel->size());
}
@ -226,7 +224,7 @@ void PagesControl::reset() {
clearHistory();
if (current_.panel) {
curname_ = "";
current_.panel->visible(false);
Container::remove(current_.panel);
current_ = Page{nullptr};
}
}

View File

@ -176,8 +176,7 @@ Panel* create_controls_panel(Engine* engine, PagesControl* pages) {
for (auto& entry : Events::bindings){
string bindname = entry.first;
std::cout << bindname << std::endl;
Panel* subpanel = new Panel(vec2(400, 45), vec4(5.0f), 1.0f);
subpanel->color(vec4(0.0f));
subpanel->orientation(Orientation::horizontal);