Skip to content
Snippets Groups Projects
Commit 78fecef0 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Fix add source dispose bug

parent 78c4e871
No related branches found
No related tags found
Loading
Pipeline #28549 failed
...@@ -13,14 +13,19 @@ void AddCtrl::init() { ...@@ -13,14 +13,19 @@ void AddCtrl::init() {
} }
void AddCtrl::show() { void AddCtrl::show() {
if (screen->childIndex(window) == -1) { if (!window || screen->childIndex(window) == -1) {
window = new ftl::gui2::AddSourceWindow(screen, this); window = new ftl::gui2::AddSourceWindow(screen, this);
} }
window->requestFocus();
window->setVisible(true); window->setVisible(true);
window->requestFocus();
screen->performLayout(); screen->performLayout();
} }
void AddCtrl::disposeWindow() {
window->dispose();
window = nullptr;
}
ftl::Configurable *AddCtrl::add(const std::string &uri) { ftl::Configurable *AddCtrl::add(const std::string &uri) {
try { try {
if (io->feed()->sourceActive(uri)) { if (io->feed()->sourceActive(uri)) {
......
...@@ -18,6 +18,7 @@ public: ...@@ -18,6 +18,7 @@ public:
virtual void init() override; virtual void init() override;
virtual void show(); virtual void show();
void disposeWindow();
ftl::Configurable *add(const std::string &uri); ftl::Configurable *add(const std::string &uri);
......
...@@ -32,7 +32,7 @@ AddSourceWindow::AddSourceWindow(nanogui::Widget* parent, AddCtrl *ctrl) : ...@@ -32,7 +32,7 @@ AddSourceWindow::AddSourceWindow(nanogui::Widget* parent, AddCtrl *ctrl) :
auto close = new nanogui::Button(buttonPanel(), "", ENTYPO_ICON_CROSS); auto close = new nanogui::Button(buttonPanel(), "", ENTYPO_ICON_CROSS);
close->setTheme(dynamic_cast<ftl::gui2::Screen*>(screen())->getTheme("window_dark")); close->setTheme(dynamic_cast<ftl::gui2::Screen*>(screen())->getTheme("window_dark"));
close->setBackgroundColor(theme()->mWindowHeaderGradientBot); close->setBackgroundColor(theme()->mWindowHeaderGradientBot);
close->setCallback([this](){ dispose();}); close->setCallback([this](){ this->close();});
rebuild(); rebuild();
...@@ -267,7 +267,8 @@ void AddSourceWindow::rebuild() { ...@@ -267,7 +267,8 @@ void AddSourceWindow::rebuild() {
void AddSourceWindow::close() { void AddSourceWindow::close() {
setVisible(false); setVisible(false);
dispose(); //dispose();
ctrl_->disposeWindow();
} }
void AddSourceWindow::draw(NVGcontext *ctx) { void AddSourceWindow::draw(NVGcontext *ctx) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment