mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 08:36:15 +00:00
LibCore+Everywhere: Remove ArgsParser::add*(char const*&)
This is not guaranteed to always work correctly as ArgsParser deals in StringViews and might have a non-properly-null-terminated string as a value. As a bonus, using StringView (and DeprecatedString where necessary) leads to nicer looking code too :^)
This commit is contained in:
committed by
Andreas Kling
parent
60908adcbe
commit
500044906d
@@ -51,7 +51,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
|
||||
auto app_icon = GUI::Icon::default_icon("filetype-image"sv);
|
||||
|
||||
char const* path = nullptr;
|
||||
StringView path;
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_positional_argument(path, "The image file to be displayed.", "file", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(arguments);
|
||||
@@ -68,7 +68,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
auto main_toolbar = TRY(toolbar_container->try_add<GUI::Toolbar>());
|
||||
|
||||
auto widget = TRY(root_widget->try_add<ViewWidget>());
|
||||
if (path) {
|
||||
if (!path.is_empty()) {
|
||||
widget->set_path(path);
|
||||
}
|
||||
widget->on_scale_change = [&](float scale) {
|
||||
|
||||
Reference in New Issue
Block a user