mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 03:27:34 +00:00
AK+Everywhere: Add and use static APIs for LexicalPath
The LexicalPath instance methods dirname(), basename(), title() and extension() will be changed to return StringView const& in a further commit. Due to this, users creating temporary LexicalPath objects just to call one of those getters will recieve a StringView const& pointing to a possible freed buffer. To avoid this, static methods for those APIs have been added, which will return a String by value to avoid those problems. All cases where temporary LexicalPath objects have been used as described above haven been changed to use the static APIs.
This commit is contained in:
parent
9b8f35259c
commit
fc6d051dfd
43 changed files with 80 additions and 56 deletions
|
@ -1064,7 +1064,7 @@ void TerminalWidget::context_menu_event(GUI::ContextMenuEvent& event)
|
|||
// Then add them to the context menu.
|
||||
// FIXME: Adapt this code when we actually support calling LaunchServer with a specific handler in mind.
|
||||
for (auto& handler : handlers) {
|
||||
auto af = Desktop::AppFile::get_for_app(LexicalPath(handler).basename());
|
||||
auto af = Desktop::AppFile::get_for_app(LexicalPath::basename(handler));
|
||||
if (!af->is_valid())
|
||||
continue;
|
||||
auto action = GUI::Action::create(String::formatted("&Open in {}", af->name()), af->icon().bitmap_for_size(16), [this, handler](auto&) {
|
||||
|
@ -1084,7 +1084,7 @@ void TerminalWidget::context_menu_event(GUI::ContextMenuEvent& event)
|
|||
// file://courage/home/anon/something -> /home/anon/something
|
||||
auto path = URL(m_context_menu_href).path();
|
||||
// /home/anon/something -> something
|
||||
auto name = LexicalPath(path).basename();
|
||||
auto name = LexicalPath::basename(path);
|
||||
GUI::Clipboard::the().set_plain_text(name);
|
||||
}));
|
||||
m_context_menu_for_hyperlink->add_separator();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue