Fix shutdown

This commit is contained in:
Paul Rouget 2019-07-26 18:25:04 +02:00
parent 449881f566
commit c6a2f6eb05
3 changed files with 7 additions and 4 deletions

View file

@ -40,7 +40,7 @@ void BrowserPage::Shutdown() {
log("Waiting for Servo to shutdown"); log("Waiting for Servo to shutdown");
::WaitForSingleObject(hEvent, INFINITE); ::WaitForSingleObject(hEvent, INFINITE);
StopRenderLoop(); StopRenderLoop();
mServo.reset(); // will call servo::deinit mServo.reset();
} }
} }
} }
@ -168,6 +168,7 @@ void BrowserPage::Loop(cancellation_token cancel) {
mServo->PerformUpdates(); mServo->PerformUpdates();
} }
log("Leaving loop"); log("Leaving loop");
mServo->DeInit();
cancel_current_task(); cancel_current_task();
} // namespace winrt::ServoApp::implementation } // namespace winrt::ServoApp::implementation
@ -188,6 +189,7 @@ void BrowserPage::StartRenderLoop() {
void BrowserPage::StopRenderLoop() { void BrowserPage::StopRenderLoop() {
if (IsLoopRunning()) { if (IsLoopRunning()) {
mLoopCancel.cancel(); mLoopCancel.cancel();
WakeUp();
mLoopTask->wait(); mLoopTask->wait();
mLoopTask.reset(); mLoopTask.reset();
} }

View file

@ -59,7 +59,7 @@ Servo::Servo(GLsizei width, GLsizei height, ServoDelegate &aDelegate)
init_with_egl(o, &wakeup, c); init_with_egl(o, &wakeup, c);
} }
Servo::~Servo() { capi::deinit(); } Servo::~Servo() { sServo = nullptr; }
std::wstring char2w(const char *c_str) { std::wstring char2w(const char *c_str) {
auto str = std::string(c_str); auto str = std::string(c_str);
@ -71,4 +71,4 @@ std::wstring char2w(const char *c_str) {
return str2; return str2;
} }
} // namespace mozilla } // namespace servo

View file

@ -33,7 +33,7 @@ public:
virtual void OnAnimatingChanged(bool) = 0; virtual void OnAnimatingChanged(bool) = 0;
protected: protected:
virtual ~ServoDelegate(){log("A1");}; virtual ~ServoDelegate(){};
}; };
class Servo { class Servo {
@ -43,6 +43,7 @@ public:
ServoDelegate &Delegate() { return mDelegate; } ServoDelegate &Delegate() { return mDelegate; }
void PerformUpdates() { capi::perform_updates(); } void PerformUpdates() { capi::perform_updates(); }
void DeInit() { capi::deinit(); }
void RequestShutdown() { capi::request_shutdown(); } void RequestShutdown() { capi::request_shutdown(); }
void SetBatchMode(bool mode) { capi::set_batch_mode(mode); } void SetBatchMode(bool mode) { capi::set_batch_mode(mode); }
void GoForward() { capi::go_forward(); } void GoForward() { capi::go_forward(); }