diff --git a/applications/gui2/src/modules/addsource.cpp b/applications/gui2/src/modules/addsource.cpp index 166d76a915b48f6809886e25253a24e2312821df..89eef76aff511001de79d6e3208cc91be644b8bd 100644 --- a/applications/gui2/src/modules/addsource.cpp +++ b/applications/gui2/src/modules/addsource.cpp @@ -13,14 +13,19 @@ void AddCtrl::init() { } void AddCtrl::show() { - if (screen->childIndex(window) == -1) { + if (!window || screen->childIndex(window) == -1) { window = new ftl::gui2::AddSourceWindow(screen, this); } - window->requestFocus(); window->setVisible(true); + window->requestFocus(); screen->performLayout(); } +void AddCtrl::disposeWindow() { + window->dispose(); + window = nullptr; +} + ftl::Configurable *AddCtrl::add(const std::string &uri) { try { if (io->feed()->sourceActive(uri)) { diff --git a/applications/gui2/src/modules/addsource.hpp b/applications/gui2/src/modules/addsource.hpp index b76daad9b0575ac1d78432bbc1dcd5f9abbb6562..eab8fef9d6fb27f5dc9d03b3c51e437b758f41da 100644 --- a/applications/gui2/src/modules/addsource.hpp +++ b/applications/gui2/src/modules/addsource.hpp @@ -18,6 +18,7 @@ public: virtual void init() override; virtual void show(); + void disposeWindow(); ftl::Configurable *add(const std::string &uri); diff --git a/applications/gui2/src/views/addsource.cpp b/applications/gui2/src/views/addsource.cpp index 362eb2a4f3dc67c7e9b4d8fd83b8e5a8527e021c..e698d2dcdf85170da60e670c820778f1e14e1c36 100644 --- a/applications/gui2/src/views/addsource.cpp +++ b/applications/gui2/src/views/addsource.cpp @@ -32,7 +32,7 @@ AddSourceWindow::AddSourceWindow(nanogui::Widget* parent, AddCtrl *ctrl) : auto close = new nanogui::Button(buttonPanel(), "", ENTYPO_ICON_CROSS); close->setTheme(dynamic_cast<ftl::gui2::Screen*>(screen())->getTheme("window_dark")); close->setBackgroundColor(theme()->mWindowHeaderGradientBot); - close->setCallback([this](){ dispose();}); + close->setCallback([this](){ this->close();}); rebuild(); @@ -267,7 +267,8 @@ void AddSourceWindow::rebuild() { void AddSourceWindow::close() { setVisible(false); - dispose(); + //dispose(); + ctrl_->disposeWindow(); } void AddSourceWindow::draw(NVGcontext *ctx) {