summaryrefslogtreecommitdiff
path: root/Userland/Applications/Spreadsheet
diff options
context:
space:
mode:
authorMax Wipfli <mail@maxwipfli.ch>2021-06-29 16:46:16 +0200
committerAndreas Kling <kling@serenityos.org>2021-06-30 11:13:54 +0200
commitfc6d051dfdddc13835548537d025e760ba186b5b (patch)
tree12a5602dd4efc20f023fea95d390f3e241f6f9cf /Userland/Applications/Spreadsheet
parent9b8f35259c375f6911b76c38ec37e6d422b26bbe (diff)
downloadserenity-fc6d051dfdddc13835548537d025e760ba186b5b.zip
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.
Diffstat (limited to 'Userland/Applications/Spreadsheet')
-rw-r--r--Userland/Applications/Spreadsheet/ExportDialog.cpp2
-rw-r--r--Userland/Applications/Spreadsheet/HelpWindow.cpp4
-rw-r--r--Userland/Applications/Spreadsheet/ImportDialog.cpp2
3 files changed, 4 insertions, 4 deletions
diff --git a/Userland/Applications/Spreadsheet/ExportDialog.cpp b/Userland/Applications/Spreadsheet/ExportDialog.cpp
index c648e8c4ed..dd1f251d05 100644
--- a/Userland/Applications/Spreadsheet/ExportDialog.cpp
+++ b/Userland/Applications/Spreadsheet/ExportDialog.cpp
@@ -300,7 +300,7 @@ Result<void, String> ExportDialog::make_and_run_for(StringView mime, Core::File&
} else {
auto page = GUI::WizardPage::construct(
"Export File Format",
- String::formatted("Select the format you wish to export to '{}' as", LexicalPath { file.filename() }.basename()));
+ String::formatted("Select the format you wish to export to '{}' as", LexicalPath::basename(file.filename())));
page->on_next_page = [] { return nullptr; };
diff --git a/Userland/Applications/Spreadsheet/HelpWindow.cpp b/Userland/Applications/Spreadsheet/HelpWindow.cpp
index 247ef76273..e331054669 100644
--- a/Userland/Applications/Spreadsheet/HelpWindow.cpp
+++ b/Userland/Applications/Spreadsheet/HelpWindow.cpp
@@ -82,7 +82,7 @@ HelpWindow::HelpWindow(GUI::Window* parent)
m_webview->on_link_click = [this](auto& url, auto&, auto&&) {
VERIFY(url.protocol() == "spreadsheet");
if (url.host() == "example") {
- auto entry = LexicalPath(url.path()).basename();
+ auto entry = LexicalPath::basename(url.path());
auto doc_option = m_docs.get(entry);
if (!doc_option.is_object()) {
GUI::MessageBox::show_error(this, String::formatted("No documentation entry found for '{}'", url.path()));
@@ -120,7 +120,7 @@ HelpWindow::HelpWindow(GUI::Window* parent)
widget.add_sheet(sheet.release_nonnull());
window->show();
} else if (url.host() == "doc") {
- auto entry = LexicalPath(url.path()).basename();
+ auto entry = LexicalPath::basename(url.path());
m_webview->load(URL::create_with_data("text/html", render(entry)));
} else {
dbgln("Invalid spreadsheet action domain '{}'", url.host());
diff --git a/Userland/Applications/Spreadsheet/ImportDialog.cpp b/Userland/Applications/Spreadsheet/ImportDialog.cpp
index 7e95c4ea95..0839da1364 100644
--- a/Userland/Applications/Spreadsheet/ImportDialog.cpp
+++ b/Userland/Applications/Spreadsheet/ImportDialog.cpp
@@ -252,7 +252,7 @@ Result<NonnullRefPtrVector<Sheet>, String> ImportDialog::make_and_run_for(String
} else {
auto page = GUI::WizardPage::construct(
"Import File Format",
- String::formatted("Select the format you wish to import '{}' as", LexicalPath { file.filename() }.basename()));
+ String::formatted("Select the format you wish to import '{}' as", LexicalPath::basename(file.filename())));
page->on_next_page = [] { return nullptr; };