Auto merge of #27396 - jdm:home-button, r=Manishearth

Avoid crashing when no homepage preference is set.

Fixes #27394.
This commit is contained in:
bors-servo 2020-07-24 20:07:35 -04:00 committed by GitHub
commit 8a5a5cb91b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View file

@ -1,5 +1,7 @@
#pragma once #pragma once
#define FALLBACK_DEFAULT_URL L"https://servo.org/hl-home/"
// For development purpose. // For development purpose.
// Will override shell.homepage preference: // Will override shell.homepage preference:
// #define OVERRIDE_DEFAULT_URL L"data:text/html,<input>" // #define OVERRIDE_DEFAULT_URL L"data:text/html,<input>"

View file

@ -327,7 +327,9 @@ void Servo::GoHome() {
ApplicationDataContainer localSettings = ApplicationDataContainer localSettings =
ApplicationData::Current().LocalSettings(); ApplicationData::Current().LocalSettings();
auto prefs = localSettings.Containers().Lookup(L"servoUserPrefs"); auto prefs = localSettings.Containers().Lookup(L"servoUserPrefs");
auto home = unbox_value<hstring>(prefs.Values().Lookup(L"shell.homepage")); auto home_pref = prefs.Values().Lookup(L"shell.homepage");
auto home =
home_pref ? unbox_value<hstring>(home_pref) : FALLBACK_DEFAULT_URL;
LoadUri(home); LoadUri(home);
} }