From 4f7b44c850328ed89a3ba018359e8761632caa11 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Fri, 24 Jul 2020 16:08:09 -0400 Subject: [PATCH] Avoid crashing when no homepage preference is set. --- support/hololens/ServoApp/DefaultUrl.h | 2 ++ support/hololens/ServoApp/ServoControl/Servo.cpp | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/support/hololens/ServoApp/DefaultUrl.h b/support/hololens/ServoApp/DefaultUrl.h index ba1719dc530..e2912b524a5 100644 --- a/support/hololens/ServoApp/DefaultUrl.h +++ b/support/hololens/ServoApp/DefaultUrl.h @@ -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," diff --git a/support/hololens/ServoApp/ServoControl/Servo.cpp b/support/hololens/ServoApp/ServoControl/Servo.cpp index 7adef0a8511..31ca812198d 100644 --- a/support/hololens/ServoApp/ServoControl/Servo.cpp +++ b/support/hololens/ServoApp/ServoControl/Servo.cpp @@ -319,7 +319,9 @@ void Servo::GoHome() { ApplicationDataContainer localSettings = ApplicationData::Current().LocalSettings(); auto prefs = localSettings.Containers().Lookup(L"servoUserPrefs"); - auto home = unbox_value(prefs.Values().Lookup(L"shell.homepage")); + auto home_pref = prefs.Values().Lookup(L"shell.homepage"); + auto home = + home_pref ? unbox_value(home_pref) : FALLBACK_DEFAULT_URL; LoadUri(home); }