Bug 980876 - Null check GamepadService in case of events still in play during shutdown. r=smaug, a=sledru
authorTed Mielczarek <ted@mielczarek.org>
Mon, 07 Apr 2014 14:28:41 -0400
changeset 183671 30c45853f8cb
parent 183670 7ccc27d5c8f4
child 183681 64fcbdc63ed7
push id3441
push userryanvm@gmail.com
push date2014-04-08 16:59 +0000
treeherdermozilla-beta@30c45853f8cb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, sledru
bugs980876
milestone29.0
Bug 980876 - Null check GamepadService in case of events still in play during shutdown. r=smaug, a=sledru
hal/windows/WindowsGamepad.cpp
--- a/hal/windows/WindowsGamepad.cpp
+++ b/hal/windows/WindowsGamepad.cpp
@@ -253,16 +253,19 @@ public:
                              mGamepadAxes(gamepad.numAxes),
                              mType(type),
                              mWhich(which),
                              mData(data) {
   }
 
   NS_IMETHOD Run() {
     nsRefPtr<GamepadService> gamepadsvc(GamepadService::GetService());
+    if (!gamepadsvc) {
+      return NS_OK;
+    }
 
     switch (mType) {
     case Button:
       gamepadsvc->NewButtonEvent(mGlobalID, mWhich, mData & BUTTON_DOWN_MASK);
       break;
     case Axis: {
       float adjustedData = ((float)mData * 2.0f) / (float)kMaxAxisValue - 1.0f;
       gamepadsvc->NewAxisMoveEvent(mGlobalID, mWhich, adjustedData);
@@ -315,16 +318,19 @@ public:
                                   mGamepadButtons(gamepad.numButtons),
                                   mGamepadAxes(gamepad.numAxes),
                                   mGamepadHats(gamepad.numHats),
                                   mType(type) {
   }
 
   NS_IMETHOD Run() {
     nsRefPtr<GamepadService> gamepadsvc(GamepadService::GetService());
+    if (!gamepadsvc) {
+      return NS_OK;
+    }
     if (mType == Added) {
       int globalID = gamepadsvc->AddGamepad(mName.get(),
                                             mozilla::dom::NoMapping,
                                             mGamepadButtons,
                                             mGamepadAxes +
                                             mGamepadHats*2);
       if (gService) {
         gService->SetGamepadID(mLocalID, globalID);