diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-08-21 00:50:45 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-21 00:50:45 -0400 |
commit | 5f89dc87bd26ddb62931251edf7c76c782b96a94 (patch) | |
tree | 7783c77cd9dd7696a2fa299616d7db26312f498e /support/hololens/ServoApp/ServoControl/Servo.cpp | |
parent | 2e0d1ad567dce6be99dbae33c3e0dd9993a8d4fb (diff) | |
parent | 3933b432fac75edcfc087c6f961f1d02e70cb8f6 (diff) | |
download | servo-5f89dc87bd26ddb62931251edf7c76c782b96a94.tar.gz servo-5f89dc87bd26ddb62931251edf7c76c782b96a94.zip |
Auto merge of #23983 - paulrouget:handlePanic, r=jdm
[hololens] Handle servo panic
Depends on #23981
Fix #23937
I've used a different approach than checking the return code of every single functions.
Basically calling a C function on panic.
That means the errors are not recoverable. I think it's fine for now.
I'm open to any other better approach.
@jdm what do you think?
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23983)
<!-- Reviewable:end -->
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 |