diff --git a/src/ruis/widget/slider/scroll_bar.cpp b/src/ruis/widget/slider/scroll_bar.cpp index 124e711b3..5ac163e3b 100644 --- a/src/ruis/widget/slider/scroll_bar.cpp +++ b/src/ruis/widget/slider/scroll_bar.cpp @@ -94,17 +94,25 @@ 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, + 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 // @@ -112,22 +120,25 @@ 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([&]() { - 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 = + this->context.get().loader().load("ruis_npt_slider_bg").to_shared_ptr(); + } + if (!this->params.handle) { + this->params.handle = + this->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 +210,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() {