From 5d3ac4ec9ee7b1bb3ec7c135dddce16cdf7101f1 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Fri, 1 May 2020 03:52:54 +0200 Subject: [PATCH] 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. --- Applications/DisplaySettings/DisplaySettings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Applications/DisplaySettings/DisplaySettings.cpp b/Applications/DisplaySettings/DisplaySettings.cpp index 259408b6c2..57144f06ab 100644 --- a/Applications/DisplaySettings/DisplaySettings.cpp +++ b/Applications/DisplaySettings/DisplaySettings.cpp @@ -275,7 +275,7 @@ void DisplaySettingsWidget::load_current_settings() Optional 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()) {