DisplaySettings: Don't crash after 'pape'

Running 'pape' without arguments (or just editing the WindowServer.ini by hand)
can confuse DisplaySettings. Specifically, if the 'Wallpaper' is set to
'/res/wallpapers/', then DisplaySettings used to crash because 'name_parts'
wouldn't contain any trailing element.

It's hard to define desired behavior, but this is better than crashing
and confusing the user.
This commit is contained in:
Ben Wiederhake 2020-05-01 03:52:54 +02:00 committed by Andreas Kling
parent 1b140d1b5b
commit 5d3ac4ec9e
Notes: sideshowbarker 2024-07-19 07:03:04 +09:00

View File

@ -275,7 +275,7 @@ void DisplaySettingsWidget::load_current_settings()
Optional<size_t> optional_index;
if (selected_wallpaper.starts_with("/res/wallpapers/")) {
auto name_parts = selected_wallpaper.split('/');
auto name_parts = selected_wallpaper.split('/', true);
optional_index = m_wallpapers.find_first_index(name_parts[2]);
if (optional_index.has_value()) {