Properly removing a window

This commit is contained in:
Pcornat 2026-03-18 19:36:11 +01:00
commit bae36631d2
Signed by: Pcornat
GPG key ID: E0326CC678A00BDD

View file

@ -16,6 +16,7 @@ namespace gui_to_app {
namespace views = std::views; namespace views = std::views;
AppWin2Back::AppWin2Back() : Gtk::Application("org.billy_adventures.character_sheet", Flags::HANDLES_OPEN) { AppWin2Back::AppWin2Back() : Gtk::Application("org.billy_adventures.character_sheet", Flags::HANDLES_OPEN) {
signal_window_removed().connect([](const Gtk::Window *window) { delete window; });
Glib::set_application_name("Billy's character sheet"); Glib::set_application_name("Billy's character sheet");
selection_buttons.reserve(signal_handlers.size()); selection_buttons.reserve(signal_handlers.size());
} }
@ -215,9 +216,8 @@ namespace gui_to_app {
void AppWin2Back::on_quit() noexcept { void AppWin2Back::on_quit() noexcept {
ranges::for_each(get_windows() | views::filter([](const auto windows) { return windows != nullptr; }), ranges::for_each(get_windows() | views::filter([](const auto windows) { return windows != nullptr; }),
[](auto *window) { [this](auto *window) {
window->set_visible(false); remove_window(*window);
delete window;
}); });
quit(); quit();
} }