From b8e6949dfb8a88c832e82f8b7e853fe0ed462da0 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 24 Aug 2024 14:08:25 +0200 Subject: Remove scrollable page from gsr page, fix crash when navigating back --- src/gui/ScrollablePage.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/gui/ScrollablePage.cpp') diff --git a/src/gui/ScrollablePage.cpp b/src/gui/ScrollablePage.cpp index a2b6c8f..41ede41 100644 --- a/src/gui/ScrollablePage.cpp +++ b/src/gui/ScrollablePage.cpp @@ -19,14 +19,13 @@ namespace gsr { } // Process widgets by visibility (backwards) - for(auto it = widgets.rbegin(), end = widgets.rend(); it != end; ++it) { - if(it->get() != selected_widget) { - if(!(*it)->on_event(event, window, offset)) + return widgets.for_each_reverse([selected_widget, &window, &event, offset](std::unique_ptr &widget) { + if(widget.get() != selected_widget) { + if(!widget->on_event(event, window, offset)) return false; } - } - - return true; + return true; + }); } void ScrollablePage::draw(mgl::Window &window, mgl::vec2f offset) { @@ -48,7 +47,8 @@ namespace gsr { Widget *selected_widget = selected_child_widget; - for(auto &widget : widgets) { + for(size_t i = 0; i < widgets.size(); ++i) { + auto &widget = widgets[i]; if(widget.get() != selected_widget) widget->draw(window, offset); } -- cgit v1.2.3