From f21716bea832bdcf4b210ffd917ab10e455faa61 Mon Sep 17 00:00:00 2001 From: igagis-bot Date: Thu, 26 Nov 2026 10:24:55 +0200 Subject: [PATCH 1/3] widget: fix -Wmaybe-uninitialized error in scroll_bar with GCC 16 GCC 16 raises a false-positive -Wmaybe-uninitialized in the scroll_bar constructor: it cannot track values initialized before the use across base class constructor calls. Move the default resource loading into the constructor body and suppress the warning for GCC 16. --- src/ruis/widget/slider/scroll_bar.cpp | 32 ++++++++++++++++++--------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/ruis/widget/slider/scroll_bar.cpp b/src/ruis/widget/slider/scroll_bar.cpp index 124e711b3..8919243fb 100644 --- a/src/ruis/widget/slider/scroll_bar.cpp +++ b/src/ruis/widget/slider/scroll_bar.cpp @@ -94,6 +94,14 @@ std::vector> make_widgets(const utki::shared_ref< } } // namespace +// GCC 16 raises a false-positive -Wmaybe-uninitialized in this constructor, +// because values initialized before the use cannot be tracked across the +// base class constructor calls. +// So, we suppress the warning. +#if CFG_COMPILER == CFG_COMPILER_GCC && CFG_COMPILER_VERSION_MAJOR == 16 +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif scroll_bar::scroll_bar( // const utki::shared_ref& c, all_parameters params @@ -117,17 +125,18 @@ scroll_bar::scroll_bar( // make_widgets(context) ), handle(this->get_widget("ruis_handle")), - params([&]() { - auto& sbp = params.scroll_bar_params; - if (!sbp.background) { - sbp.background = context.get().loader().load("ruis_npt_slider_bg").to_shared_ptr(); - } - if (!sbp.handle) { - sbp.handle = context.get().loader().load("ruis_npt_slider_handle").to_shared_ptr(); - } - return params.scroll_bar_params; - }()) + params(params.scroll_bar_params) { + // load default resources if not provided + // NOTE: cannot be done in the member initializer list, GCC complains + // about a possibly-uninitialized value there + if (!this->params.background) { + this->params.background = context.get().loader().load("ruis_npt_slider_bg").to_shared_ptr(); + } + if (!this->params.handle) { + this->params.handle = context.get().loader().load("ruis_npt_slider_handle").to_shared_ptr(); + } + auto& np = this->get_widget_as("ruis_background"); auto& hi = this->get_widget_as("ruis_handle_image"); @@ -199,6 +208,9 @@ scroll_bar::scroll_bar( // return event_status::consumed; }; } +#if CFG_COMPILER == CFG_COMPILER_GCC && CFG_COMPILER_VERSION_MAJOR == 16 +# pragma GCC diagnostic pop +#endif void scroll_bar::on_fraction_change() { From 214c5e1a7e650b0845b835e0dc508ea412676972 Mon Sep 17 00:00:00 2001 From: igagis-bot Date: Thu, 26 Nov 2026 12:30:29 +0200 Subject: [PATCH 2/3] widget: fix clang-format violations in the GCC pragma blocks Use '#'+tab before the pragma directive, as required by the project's clang-format configuration. --- src/ruis/widget/slider/scroll_bar.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ruis/widget/slider/scroll_bar.cpp b/src/ruis/widget/slider/scroll_bar.cpp index 8919243fb..5d63f8a73 100644 --- a/src/ruis/widget/slider/scroll_bar.cpp +++ b/src/ruis/widget/slider/scroll_bar.cpp @@ -99,8 +99,8 @@ std::vector> make_widgets(const utki::shared_ref< // base class constructor calls. // So, we suppress the warning. #if CFG_COMPILER == CFG_COMPILER_GCC && CFG_COMPILER_VERSION_MAJOR == 16 -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif scroll_bar::scroll_bar( // const utki::shared_ref& c, @@ -209,7 +209,7 @@ scroll_bar::scroll_bar( // }; } #if CFG_COMPILER == CFG_COMPILER_GCC && CFG_COMPILER_VERSION_MAJOR == 16 -# pragma GCC diagnostic pop +# pragma GCC diagnostic pop #endif void scroll_bar::on_fraction_change() From 76371ae054f7e94cadd093f8f4cfd8b10afb3eb5 Mon Sep 17 00:00:00 2001 From: Ivan Gagis's Bot Date: Fri, 27 Nov 2026 03:45:03 +0200 Subject: [PATCH 3/3] widget: address review comments in scroll_bar constructor - rename 'c' parameter to 'context' - use this->context style in the initializer list and constructor body --- src/ruis/widget/slider/scroll_bar.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/ruis/widget/slider/scroll_bar.cpp b/src/ruis/widget/slider/scroll_bar.cpp index 5d63f8a73..5ac163e3b 100644 --- a/src/ruis/widget/slider/scroll_bar.cpp +++ b/src/ruis/widget/slider/scroll_bar.cpp @@ -103,16 +103,16 @@ std::vector> make_widgets(const utki::shared_ref< # pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif scroll_bar::scroll_bar( // - const utki::shared_ref& c, + const utki::shared_ref& context, all_parameters params ) : widget( // - c, + context, std::move(params.layout_params), std::move(params.widget) ), fraction_band_widget( // - context, + this->context, { .fraction = params.fraction, .band_fraction = params.band_fraction // @@ -120,9 +120,9 @@ scroll_bar::scroll_bar( // ), oriented(std::move(params.oriented_params)), container( // - context, + this->context, {.params = {.layout = layout::pile}}, - make_widgets(context) + make_widgets(this->context) ), handle(this->get_widget("ruis_handle")), params(params.scroll_bar_params) @@ -131,10 +131,12 @@ scroll_bar::scroll_bar( // // NOTE: cannot be done in the member initializer list, GCC complains // about a possibly-uninitialized value there if (!this->params.background) { - this->params.background = context.get().loader().load("ruis_npt_slider_bg").to_shared_ptr(); + this->params.background = + this->context.get().loader().load("ruis_npt_slider_bg").to_shared_ptr(); } if (!this->params.handle) { - this->params.handle = context.get().loader().load("ruis_npt_slider_handle").to_shared_ptr(); + this->params.handle = + this->context.get().loader().load("ruis_npt_slider_handle").to_shared_ptr(); } auto& np = this->get_widget_as("ruis_background");