aboutsummaryrefslogtreecommitdiffstats
path: root/support/hololens/ServoApp/ServoControl/Servo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'support/hololens/ServoApp/ServoControl/Servo.cpp')
-rw-r--r--support/hololens/ServoApp/ServoControl/Servo.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/support/hololens/ServoApp/ServoControl/Servo.cpp b/support/hololens/ServoApp/ServoControl/Servo.cpp
index fbc6d7d9c24..84077811c96 100644
--- a/support/hololens/ServoApp/ServoControl/Servo.cpp
+++ b/support/hololens/ServoApp/ServoControl/Servo.cpp
@@ -22,12 +22,16 @@ void flush() { sServo->Delegate().Flush(); }
void make_current() { sServo->Delegate().MakeCurrent(); }
void wakeup() { sServo->Delegate().WakeUp(); }
bool on_allow_navigation(const char *url) {
- return sServo->Delegate().OnServoAllowNavigation(char2hstring(url));
+ return sServo->Delegate().OnServoAllowNavigation(char2hstring(url));
};
void on_animating_changed(bool aAnimating) {
sServo->Delegate().OnServoAnimatingChanged(aAnimating);
}
+void on_panic(const char *backtrace) {
+ throw hresult_error(E_FAIL, char2hstring(backtrace));
+}
+
Servo::Servo(GLsizei width, GLsizei height, ServoDelegate &aDelegate)
: mWindowHeight(height), mWindowWidth(width), mDelegate(aDelegate) {
@@ -55,7 +59,9 @@ Servo::Servo(GLsizei width, GLsizei height, ServoDelegate &aDelegate)
c.on_shutdown_complete = &on_shutdown_complete;
c.on_allow_navigation = &on_allow_navigation;
- init_with_egl(o, &wakeup, c);
+ capi::register_panic_handler(&on_panic);
+
+ capi::init_with_egl(o, &wakeup, c);
}
Servo::~Servo() { sServo = nullptr; }
@@ -63,11 +69,13 @@ Servo::~Servo() { sServo = nullptr; }
winrt::hstring char2hstring(const char *c_str) {
// FIXME: any better way of doing this?
auto str = std::string(c_str);
- int size_needed = MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
+ int size_needed =
+ MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), NULL, 0);
std::wstring str2(size_needed, 0);
- MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &str2[0], size_needed);
- winrt::hstring str3 {str2};
+ MultiByteToWideChar(CP_UTF8, 0, &str[0], (int)str.size(), &str2[0],
+ size_needed);
+ winrt::hstring str3{str2};
return str3;
}
-} // namespace servo
+} // namespace winrt::servo