mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:17:45 +00:00
Presenter: Fix a crash in loading untitled presentations
The Presentation::title() and Presentation::author() functions return a StringView to the title/author defined in the json file or a default value. Previously, this would return a StringView to already-freed memory and crash the application when setting the window title. This commit fixes that issue :^)
This commit is contained in:
parent
e305b32d9a
commit
9d9a6b6b64
1 changed files with 6 additions and 2 deletions
|
@ -30,12 +30,16 @@ void Presentation::append_slide(Slide slide)
|
|||
|
||||
StringView Presentation::title() const
|
||||
{
|
||||
return m_metadata.get("title"sv).value_or("Untitled Presentation"sv);
|
||||
if (m_metadata.contains("title"sv))
|
||||
return m_metadata.get("title"sv)->view();
|
||||
return "Untitled Presentation"sv;
|
||||
}
|
||||
|
||||
StringView Presentation::author() const
|
||||
{
|
||||
return m_metadata.get("author"sv).value_or("Unknown Author"sv);
|
||||
if (m_metadata.contains("author"sv))
|
||||
return m_metadata.get("author"sv)->view();
|
||||
return "Unknown Author"sv;
|
||||
}
|
||||
|
||||
void Presentation::next_frame()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue