Avoid crashing when no homepage preference is set.

This commit is contained in:
Josh Matthews 2020-07-24 16:08:09 -04:00
parent 6a9aac3e65
commit 4f7b44c850
2 changed files with 5 additions and 1 deletions

View file

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

View file

@ -319,7 +319,9 @@ void Servo::GoHome() {
ApplicationDataContainer localSettings =
ApplicationData::Current().LocalSettings();
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);
}