diff options
author | Paul Rouget <me@paulrouget.com> | 2019-08-16 11:08:02 +0200 |
---|---|---|
committer | Paul Rouget <me@paulrouget.com> | 2019-08-21 06:20:20 +0200 |
commit | 3933b432fac75edcfc087c6f961f1d02e70cb8f6 (patch) | |
tree | a27285e60f381bbac59b069b7cb9053133466075 /support/hololens/ServoApp/ServoControl/Servo.cpp | |
parent | d09692664e357a05d7238c370099eede682a3a4a (diff) | |
download | servo-3933b432fac75edcfc087c6f961f1d02e70cb8f6.tar.gz servo-3933b432fac75edcfc087c6f961f1d02e70cb8f6.zip |
Panic HoloLens app on rust panic
Diffstat (limited to 'support/hololens/ServoApp/ServoControl/Servo.cpp')
-rw-r--r-- | support/hololens/ServoApp/ServoControl/Servo.cpp | 20 |
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 |