Narrow retained UI overlay lifetime debt

This commit is contained in:
2026-06-15 19:26:11 +02:00
parent f907d88c26
commit 565564c061
15 changed files with 603 additions and 67 deletions

View File

@@ -32,7 +32,6 @@ void NodeDialogOpen::init_controls()
{
btn_ok = find<NodeButton>("btn-ok");
btn_cancel = find<NodeButton>("btn-cancel");
pp::panopainter::bind_legacy_click_destroys_node(*btn_cancel, *this);
btn_delete = find<NodeButton>("btn-delete");
btn_delete->on_click = [this](Node*) {
if (!current)
@@ -41,7 +40,13 @@ void NodeDialogOpen::init_controls()
auto msgbox = pp::panopainter::make_legacy_overlay_node<NodeMessageBox>(*App::I);
msgbox->m_title->set_text("Delete Project");
msgbox->m_message->set_text(("Are you sure you want to delete " + current->m_file_name + "?").c_str());
msgbox->btn_ok->on_click = [this,msgbox](Node*){
const auto overlay = pp::panopainter::open_legacy_overlay_node_with_handle(*this, msgbox);
if (!overlay)
{
return;
}
const auto overlay_handle = overlay.value();
const auto on_confirm = [this, overlay_handle](Node*){
auto path = current->m_path;
int idx = container->get_child_index(current);
container->remove_child(current);
@@ -60,9 +65,17 @@ void NodeDialogOpen::init_controls()
image_tex->tex.reset();
}
Asset::delete_file(path);
pp::panopainter::close_legacy_dialog_node(*msgbox);
const auto close_status =
pp::panopainter::close_legacy_overlay_node(*this, overlay_handle);
(void)close_status;
};
msgbox->btn_ok->on_click = on_confirm;
msgbox->on_submit = on_confirm;
msgbox->btn_cancel->on_click = [this, overlay_handle](Node*) {
const auto close_status =
pp::panopainter::close_legacy_overlay_node(*this, overlay_handle);
(void)close_status;
};
(void)pp::panopainter::attach_legacy_overlay_node_to_root(*this, msgbox);
root()->update();
};
container = find<Node>("files-list");
@@ -177,7 +190,6 @@ void NodeDialogSave::init_controls()
{
btn_ok = find<NodeButton>("btn-ok");
btn_cancel = find<NodeButton>("btn-cancel");
pp::panopainter::bind_legacy_click_destroys_node(*btn_cancel, *this);
input = find<NodeTextInput>("txt-input");
input->on_return = [&](NodeTextInput* target){
if (btn_ok->on_click)
@@ -236,7 +248,6 @@ void NodeDialogNewDoc::init_controls()
btn_ok = find<NodeButton>("btn-ok");
m_resolution = find<NodeComboBox>("resolution");
btn_cancel = find<NodeButton>("btn-cancel");
pp::panopainter::bind_legacy_click_destroys_node(*btn_cancel, *this);
input = find<NodeTextInput>("txt-input");
input->on_return = [&](NodeTextInput* target){
if (btn_ok->on_click)