🚧 possible fixes reported by GCC analyzer

This commit is contained in:
Vladislav Nepogodin 2022-11-19 04:21:01 +04:00
parent d7f91ebdba
commit 3391c0cb20
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9
2 changed files with 18 additions and 18 deletions

View File

@ -28,15 +28,15 @@ Element centered_widget(Component& container, const std::string_view& title, con
text(title.data()) | bold, text(title.data()) | bold,
filler(), filler(),
// -------- Center Menu -------------- // -------- Center Menu --------------
hbox({ std::move(hbox({
filler(), filler(),
border(vbox({ border(std::move(vbox({
widget, widget,
separator(), separator(),
container->Render() | hcenter | size(HEIGHT, LESS_THAN, 3) | size(WIDTH, GREATER_THAN, 25), container->Render() | hcenter | size(HEIGHT, LESS_THAN, 3) | size(WIDTH, GREATER_THAN, 25),
})), }))),
filler(), filler(),
}) | center, })) | center,
filler(), filler(),
}); });
} }
@ -47,11 +47,11 @@ Element centered_widget_nocontrols(const std::string_view& title, const Element&
text(title.data()) | bold, text(title.data()) | bold,
filler(), filler(),
// -------- Center Menu -------------- // -------- Center Menu --------------
hbox({ std::move(hbox({
filler(), filler(),
border(vbox({widget})), border(std::move(vbox({widget}))),
filler(), filler(),
}) | center, })) | center,
filler(), filler(),
}); });
} }
@ -77,13 +77,13 @@ Element centered_interative_multi(const std::string_view& title, Component& widg
text(title.data()) | bold, text(title.data()) | bold,
filler(), filler(),
// -------- Center Menu -------------- // -------- Center Menu --------------
hbox({ std::move(hbox({
filler(), filler(),
border(vbox({ border(std::move(vbox({
widgets->Render(), widgets->Render(),
})), }))),
filler(), filler(),
}) | center, })) | center,
filler(), filler(),
}); });
} }
@ -92,16 +92,16 @@ Element multiline_text(const std::vector<std::string>& lines) noexcept {
Elements multiline; Elements multiline;
std::transform(lines.cbegin(), lines.cend(), std::back_inserter(multiline), std::transform(lines.cbegin(), lines.cend(), std::back_inserter(multiline),
[=](const std::string& line) -> Element { return text(line); }); [=](auto&& line) -> Element { return std::move(text(line)); });
return vbox(std::move(multiline)) | frame; return std::move(vbox(std::move(multiline))) | frame;
} }
Components from_vector_checklist(const std::vector<std::string>& opts, bool* opts_state) noexcept { Components from_vector_checklist(const std::vector<std::string>& opts, bool* opts_state) noexcept {
Components components; Components components;
for (size_t i = 0; i < opts.size(); ++i) { for (size_t i = 0; i < opts.size(); ++i) {
auto component = Checkbox(&opts[i], &opts_state[i]); auto&& component = Checkbox(&opts[i], &opts_state[i]);
components.emplace_back(component); components.emplace_back(std::move(component));
} }
return components; return components;
} }
@ -285,7 +285,7 @@ void menu_widget(const std::vector<std::string>& entries, const std::function<vo
screen->Loop(renderer); screen->Loop(renderer);
} }
void radiolist_widget(const std::vector<std::string>& entries, const std::function<void()>&& ok_callback, std::int32_t* selected, ScreenInteractive* screen, const WidgetBoxRes widget_res, const WidgetBoxSize widget_sizes) noexcept { void radiolist_widget(const std::vector<std::string>& entries, const std::function<void()>&& ok_callback, std::int32_t* selected, ScreenInteractive* screen, const WidgetBoxRes& widget_res, const WidgetBoxSize widget_sizes) noexcept {
auto radiolist = Container::Vertical({ auto radiolist = Container::Vertical({
Radiobox(&entries, selected), Radiobox(&entries, selected),
}); });
@ -338,7 +338,7 @@ void checklist_widget(const std::vector<std::string>& opts, const std::function<
Components children{}; Components children{};
if (!text.empty()) { if (!text.empty()) {
children = { children = {
Renderer([&] { return detail::multiline_text(utils::make_multiline(text)) | widget_sizes.text_size; }), Renderer([&] { return std::move(detail::multiline_text(utils::make_multiline(text))) | widget_sizes.text_size; }),
Renderer([] { return separator(); }), Renderer([] { return separator(); }),
content, content,
Renderer([] { return separator(); }), Renderer([] { return separator(); }),

View File

@ -40,7 +40,7 @@ namespace detail {
bool yesno_widget(const std::string_view& content, ftxui::Decorator boxsize = size(ftxui::HEIGHT, ftxui::GREATER_THAN, 5)) noexcept; bool yesno_widget(const std::string_view& content, ftxui::Decorator boxsize = size(ftxui::HEIGHT, ftxui::GREATER_THAN, 5)) noexcept;
bool yesno_widget(ftxui::Component& container, ftxui::Decorator boxsize = size(ftxui::HEIGHT, ftxui::GREATER_THAN, 5)) noexcept; bool yesno_widget(ftxui::Component& container, ftxui::Decorator boxsize = size(ftxui::HEIGHT, ftxui::GREATER_THAN, 5)) noexcept;
void menu_widget(const std::vector<std::string>& entries, const std::function<void()>&& ok_callback, std::int32_t* selected, ftxui::ScreenInteractive* screen, const std::string_view& text = "", const WidgetBoxSize widget_sizes = {}) noexcept; void menu_widget(const std::vector<std::string>& entries, const std::function<void()>&& ok_callback, std::int32_t* selected, ftxui::ScreenInteractive* screen, const std::string_view& text = "", const WidgetBoxSize widget_sizes = {}) noexcept;
void radiolist_widget(const std::vector<std::string>& entries, const std::function<void()>&& ok_callback, std::int32_t* selected, ftxui::ScreenInteractive* screen, const WidgetBoxRes widget_res = {}, const WidgetBoxSize widget_sizes = {}) noexcept; void radiolist_widget(const std::vector<std::string>& entries, const std::function<void()>&& ok_callback, std::int32_t* selected, ftxui::ScreenInteractive* screen, const WidgetBoxRes& widget_res = {}, const WidgetBoxSize widget_sizes = {}) noexcept;
void checklist_widget(const std::vector<std::string>& opts, const std::function<void()>&& ok_callback, bool* opts_state, ftxui::ScreenInteractive* screen, const std::string_view& text = "", const std::string_view& title = "New CLI Installer", const WidgetBoxSize widget_sizes = {}) noexcept; void checklist_widget(const std::vector<std::string>& opts, const std::function<void()>&& ok_callback, bool* opts_state, ftxui::ScreenInteractive* screen, const std::string_view& text = "", const std::string_view& title = "New CLI Installer", const WidgetBoxSize widget_sizes = {}) noexcept;
} // namespace detail } // namespace detail
} // namespace tui } // namespace tui