Bug 833362 - Don't invoke various interfaces during shutdown if GetActivationFactory for a interface fails (crashfix). r=tabraldes

This commit is contained in:
Jim Mathies 2013-03-12 12:07:49 -05:00
parent a0ea7ae176
commit 0e54a5de06

View File

@ -284,6 +284,20 @@ MetroInput::MetroInput(MetroWidget* aWidget,
NS_ASSERTION(aWidget, "Attempted to create MetroInput for null widget!"); NS_ASSERTION(aWidget, "Attempted to create MetroInput for null widget!");
NS_ASSERTION(aWindow, "Attempted to create MetroInput for null window!"); 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(); mTouches.Init();
// Note that this is not thread-safe. // Note that this is not thread-safe.
@ -1335,19 +1349,22 @@ void
MetroInput::UnregisterInputEvents() { MetroInput::UnregisterInputEvents() {
// Unregister ourselves for the edge swipe event // Unregister ourselves for the edge swipe event
WRL::ComPtr<UI::Input::IEdgeGestureStatics> edgeStatics; WRL::ComPtr<UI::Input::IEdgeGestureStatics> edgeStatics;
Foundation::GetActivationFactory( if (SUCCEEDED(Foundation::GetActivationFactory(
WRL::Wrappers::HStringReference( WRL::Wrappers::HStringReference(
RuntimeClass_Windows_UI_Input_EdgeGesture).Get(), RuntimeClass_Windows_UI_Input_EdgeGesture).Get(),
edgeStatics.GetAddressOf()); edgeStatics.GetAddressOf()))) {
WRL::ComPtr<UI::Input::IEdgeGesture> edge; WRL::ComPtr<UI::Input::IEdgeGesture> edge;
edgeStatics->GetForCurrentView(edge.GetAddressOf()); if (SUCCEEDED(edgeStatics->GetForCurrentView(edge.GetAddressOf()))) {
edge->remove_Completed(mTokenEdgeGesture); edge->remove_Completed(mTokenEdgeGesture);
}
}
// Unregister ourselves from the AcceleratorKeyActivated event // Unregister ourselves from the AcceleratorKeyActivated event
WRL::ComPtr<ICoreAcceleratorKeys> coreAcceleratorKeys; WRL::ComPtr<ICoreAcceleratorKeys> coreAcceleratorKeys;
mDispatcher.As<ICoreAcceleratorKeys>(&coreAcceleratorKeys); if (SUCCEEDED(mDispatcher.As<ICoreAcceleratorKeys>(&coreAcceleratorKeys))) {
coreAcceleratorKeys->remove_AcceleratorKeyActivated( coreAcceleratorKeys->remove_AcceleratorKeyActivated(
mTokenAcceleratorKeyActivated); mTokenAcceleratorKeyActivated);
}
// Unregister ourselves from the window events. This is extremely important; // 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 // once this object is destroyed we don't want Windows to try to send events