From 766fb3350d7b0cf7fd3830070dc2d61f0243c98e Mon Sep 17 00:00:00 2001 From: Jim Mathies Date: Wed, 13 Mar 2013 09:11:17 -0500 Subject: [PATCH] Bug 844362 - Don't invoke various interfaces during shutdown if GetActivationFactory for a interface fails (crashfix). r=tabraldes DONTBUILD CLOSED TREE --- widget/windows/winrt/MetroInput.cpp | 33 ++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/widget/windows/winrt/MetroInput.cpp b/widget/windows/winrt/MetroInput.cpp index d4a67ec007e..fd77a6aead5 100644 --- a/widget/windows/winrt/MetroInput.cpp +++ b/widget/windows/winrt/MetroInput.cpp @@ -284,6 +284,20 @@ MetroInput::MetroInput(MetroWidget* aWidget, NS_ASSERTION(aWidget, "Attempted to create MetroInput for null widget!"); NS_ASSERTION(aWindow, "Attempted to create MetroInput for null window!"); + mTokenPointerPressed.value = 0; + mTokenPointerReleased.value = 0; + mTokenPointerMoved.value = 0; + mTokenPointerEntered.value = 0; + mTokenPointerExited.value = 0; + mTokenPointerWheelChanged.value = 0; + mTokenAcceleratorKeyActivated.value = 0; + mTokenEdgeGesture.value = 0; + mTokenManipulationStarted.value = 0; + mTokenManipulationUpdated.value = 0; + mTokenManipulationCompleted.value = 0; + mTokenTapped.value = 0; + mTokenRightTapped.value = 0; + mTouches.Init(); // Note that this is not thread-safe. @@ -1335,19 +1349,22 @@ void MetroInput::UnregisterInputEvents() { // Unregister ourselves for the edge swipe event WRL::ComPtr edgeStatics; - Foundation::GetActivationFactory( + if (SUCCEEDED(Foundation::GetActivationFactory( WRL::Wrappers::HStringReference( RuntimeClass_Windows_UI_Input_EdgeGesture).Get(), - edgeStatics.GetAddressOf()); - WRL::ComPtr edge; - edgeStatics->GetForCurrentView(edge.GetAddressOf()); - edge->remove_Completed(mTokenEdgeGesture); + edgeStatics.GetAddressOf()))) { + WRL::ComPtr edge; + if (SUCCEEDED(edgeStatics->GetForCurrentView(edge.GetAddressOf()))) { + edge->remove_Completed(mTokenEdgeGesture); + } + } // Unregister ourselves from the AcceleratorKeyActivated event WRL::ComPtr coreAcceleratorKeys; - mDispatcher.As(&coreAcceleratorKeys); - coreAcceleratorKeys->remove_AcceleratorKeyActivated( - mTokenAcceleratorKeyActivated); + if (SUCCEEDED(mDispatcher.As(&coreAcceleratorKeys))) { + coreAcceleratorKeys->remove_AcceleratorKeyActivated( + mTokenAcceleratorKeyActivated); + } // Unregister ourselves from the window events. This is extremely important; // once this object is destroyed we don't want Windows to try to send events