Bug 833016 - Fix for FrameworkView addrefing which is causing crashes on shutdown. r=bbondy

This commit is contained in:
Jim Mathies 2013-03-26 17:01:15 -05:00
parent 1257d16906
commit 4b2d35592c
4 changed files with 32 additions and 29 deletions

View File

@ -86,9 +86,25 @@ FrameworkView::Uninitialize()
{
LogFunction();
mShuttingDown = true;
if (mAutomationProvider) {
ComPtr<IUIABridge> provider;
mAutomationProvider.As(&provider);
if (provider) {
provider->Disconnect();
}
}
mAutomationProvider = nullptr;
mMetroInput = nullptr;
mD2DWindowSurface = nullptr;
delete sSettingsArray;
sSettingsArray = nullptr;
mWidget = nullptr;
mMetroApp = nullptr;
mDispatcher = nullptr;
mWindow = nullptr;
return S_OK;
}
@ -192,17 +208,6 @@ FrameworkView::AddEventHandlers() {
void
FrameworkView::ShutdownXPCOM()
{
mShuttingDown = true;
mWidget = nullptr;
ComPtr<IUIABridge> provider;
if (mAutomationProvider) {
mAutomationProvider.As(&provider);
if (provider) {
provider->Disconnect();
}
}
mAutomationProvider = nullptr;
mMetroInput = nullptr;
Uninitialize();
}

View File

@ -52,6 +52,7 @@ MetroApp::CreateView(ABI::Windows::ApplicationModel::Core::IFrameworkView **aVie
LogFunction();
sFrameworkView.Get()->AddRef();
*aViewProvider = sFrameworkView.Get();
return !sFrameworkView ? E_FAIL : S_OK;
}
@ -101,10 +102,14 @@ MetroApp::ShutdownXPCOM()
mozilla::widget::StopAudioSession();
sCoreApp->remove_Suspending(mSuspendEvent);
sCoreApp->remove_Resuming(mResumeEvent);
if (sCoreApp) {
sCoreApp->remove_Suspending(mSuspendEvent);
sCoreApp->remove_Resuming(mResumeEvent);
}
MetroApp::GetView()->ShutdownXPCOM();
if (sFrameworkView) {
sFrameworkView->ShutdownXPCOM();
}
// Shut down xpcom
XRE_metroShutdown();
@ -124,14 +129,6 @@ MetroApp::CoreExit()
}
}
// static
FrameworkView*
MetroApp::GetView()
{
NS_ASSERTION(sFrameworkView, "view has not been created.");
return sFrameworkView.Get();
}
////////////////////////////////////////////////////
// MetroApp events
@ -164,7 +161,10 @@ void
MetroApp::SetBaseWidget(MetroWidget* aPtr)
{
LogThread();
NS_ASSERTION(aPtr, "setting null base widget?");
// Both of these calls AddRef the ptr we pass in
aPtr->SetView(sFrameworkView.Get());
sFrameworkView->SetWidget(aPtr);
}
@ -231,8 +231,6 @@ XRE_MetroCoreApplicationRun()
return false;
}
sFrameworkView = Make<FrameworkView>(sMetroApp.Get());
// Perform any cleanup for unclean shutdowns here, such as when the background session
// is closed via the appbar on the left when outside of Metro. Windows restarts the
// process solely for cleanup reasons.
@ -253,11 +251,12 @@ XRE_MetroCoreApplicationRun()
return false;
}
sFrameworkView = Make<FrameworkView>(sMetroApp.Get());
hr = sCoreApp->Run(sMetroApp.Get());
sFrameworkView = nullptr;
Log(L"Exiting CoreApplication::Run");
sFrameworkView = nullptr;
sCoreApp = nullptr;
sMetroApp = nullptr;

View File

@ -48,7 +48,6 @@ public:
void ShutdownXPCOM();
// Shared pointers between framework and widget
static FrameworkView* GetView();
static void SetBaseWidget(MetroWidget* aPtr);
static void PostSuspendResumeProcessNotification(bool aIsSuspend);
static void PostSleepWakeNotification(bool aIsSuspend);

View File

@ -28,6 +28,7 @@ namespace widget {
namespace winrt {
extern ComPtr<MetroApp> sMetroApp;
extern nsTArray<nsString>* sSettingsArray;
extern ComPtr<FrameworkView> sFrameworkView;
} } }
namespace mozilla {
@ -412,12 +413,11 @@ nsWinMetroUtils::GetHandPreference(int32_t *aHandPreference)
NS_IMETHODIMP
nsWinMetroUtils::GetActivationURI(nsAString &aActivationURI)
{
FrameworkView *view = MetroApp::GetView();
if (!view) {
if (!sFrameworkView) {
NS_WARNING("GetActivationURI used before view is created!");
return NS_OK;
}
view->GetActivationURI(aActivationURI);
sFrameworkView->GetActivationURI(aActivationURI);
return NS_OK;
}