aboutsummaryrefslogtreecommitdiff
path: root/src/gui/ScrollablePage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/ScrollablePage.cpp')
-rw-r--r--src/gui/ScrollablePage.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/gui/ScrollablePage.cpp b/src/gui/ScrollablePage.cpp
index d5e92d0..cec20d3 100644
--- a/src/gui/ScrollablePage.cpp
+++ b/src/gui/ScrollablePage.cpp
@@ -15,6 +15,14 @@ namespace gsr {
ScrollablePage::ScrollablePage(mgl::vec2f size) : size(size) {}
+ ScrollablePage::~ScrollablePage() {
+ widgets.for_each([this](std::unique_ptr<Widget> &widget) {
+ if(widget->parent_widget == this)
+ widget->parent_widget = nullptr;
+ return true;
+ }, true);
+ }
+
bool ScrollablePage::on_event(mgl::Event &event, mgl::Window &window, mgl::vec2f offset) {
if(!visible)
return true;
@@ -57,8 +65,9 @@ namespace gsr {
// Process widgets by visibility (backwards)
const bool continue_events = widgets.for_each_reverse([selected_widget, &window, &event, offset](std::unique_ptr<Widget> &widget) {
- if(widget.get() != selected_widget) {
- if(!widget->on_event(event, window, offset))
+ Widget *p = widget.get();
+ if(p != selected_widget) {
+ if(!p->on_event(event, window, offset))
return false;
}
return true;