From 431379fa00e1abaa52e1e7cd04edb9aeb739c793 Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Sat, 18 Aug 2012 09:55:59 -0400 Subject: [PATCH] Bug 776132 - When the gonk AppShell is trying to shut down the OrientationObserver, don't call OrientationObserver::GetInstance() -- that might /create/ an orientation observer! r=cjones --HG-- extra : rebase_source : 72ad44ea6edf1c170cb0af6fb3e207550c7bee15 --- widget/gonk/OrientationObserver.cpp | 12 ++++++++++++ widget/gonk/OrientationObserver.h | 4 ++++ widget/gonk/nsAppShell.cpp | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/widget/gonk/OrientationObserver.cpp b/widget/gonk/OrientationObserver.cpp index b37b5d343aea..d06065fbdffc 100644 --- a/widget/gonk/OrientationObserver.cpp +++ b/widget/gonk/OrientationObserver.cpp @@ -183,6 +183,18 @@ OrientationObserver::~OrientationObserver() } } +/* static */ void +OrientationObserver::ShutDown() +{ + if (!sOrientationSensorObserver) { + return; + } + + if (sOrientationSensorObserver->mAutoOrientationEnabled) { + sOrientationSensorObserver->DisableAutoOrientation(); + } +} + void OrientationObserver::Notify(const hal::SensorData& aSensorData) { diff --git a/widget/gonk/OrientationObserver.h b/widget/gonk/OrientationObserver.h index 2d50985a7d6e..1ce7970cb898 100644 --- a/widget/gonk/OrientationObserver.h +++ b/widget/gonk/OrientationObserver.h @@ -37,6 +37,10 @@ public: OrientationObserver(); ~OrientationObserver(); + // Call DisableAutoOrientation on the existing OrientatiOnobserver singleton, + // if it exists. If no OrientationObserver exists, do nothing. + static void ShutDown(); + // Notification from sensor. void Notify(const SensorData& aSensorData); diff --git a/widget/gonk/nsAppShell.cpp b/widget/gonk/nsAppShell.cpp index 2e66604746e5..f55f0ce42edc 100644 --- a/widget/gonk/nsAppShell.cpp +++ b/widget/gonk/nsAppShell.cpp @@ -529,7 +529,7 @@ nsAppShell::Init() NS_IMETHODIMP nsAppShell::Exit() { - OrientationObserver::GetInstance()->DisableAutoOrientation(); + OrientationObserver::ShutDown(); return nsBaseAppShell::Exit(); }