Bug 691443 - crash [@ nsAccessibleWrap::GetHWNDFor], r=davidb
authorAlexander Surkov <surkov.alexander@gmail.com>
Tue, 11 Oct 2011 09:06:10 +0900
changeset 79011 f4fa6df431be373458eb0d57e37b011a4ab89414
parent 79010 cd148629d7e7cf71a7eb03886c5835091906191f
child 79012 9975c3dd08a639340f2f335dc7bedb3059b8c7c6
push idunknown
push userunknown
push dateunknown
reviewersdavidb
bugs691443
milestone10.0a1
Bug 691443 - crash [@ nsAccessibleWrap::GetHWNDFor], r=davidb
accessible/src/msaa/nsAccessibleWrap.cpp
--- a/accessible/src/msaa/nsAccessibleWrap.cpp
+++ b/accessible/src/msaa/nsAccessibleWrap.cpp
@@ -1612,29 +1612,31 @@ nsAccessibleWrap::GetHWNDFor(nsAccessibl
 {
   if (aAccessible) {
     // Popup lives in own windows, use its HWND until the popup window is
     // hidden to make old JAWS versions work with collapsed comboboxes (see
     // discussion in bug 379678).
     nsIFrame* frame = aAccessible->GetFrame();
     if (frame) {
       nsIWidget* widget = frame->GetNearestWidget();
-      bool isVisible = false;
-      widget->IsVisible(isVisible);
-      if (isVisible) {
-        nsCOMPtr<nsIPresShell> shell(aAccessible->GetPresShell());
-        nsIViewManager* vm = shell->GetViewManager();
-        if (vm) {
-          nsCOMPtr<nsIWidget> rootWidget;
-          vm->GetRootWidget(getter_AddRefs(rootWidget));
-          // Make sure the accessible belongs to popup. If not then use
-          // document HWND (which might be different from root widget in the
-          // case of window emulation).
-          if (rootWidget != widget)
-            return static_cast<HWND>(widget->GetNativeData(NS_NATIVE_WINDOW));
+      if (widget) {
+        bool isVisible = false;
+        widget->IsVisible(isVisible);
+        if (isVisible) {
+          nsCOMPtr<nsIPresShell> shell(aAccessible->GetPresShell());
+          nsIViewManager* vm = shell->GetViewManager();
+          if (vm) {
+            nsCOMPtr<nsIWidget> rootWidget;
+            vm->GetRootWidget(getter_AddRefs(rootWidget));
+            // Make sure the accessible belongs to popup. If not then use
+            // document HWND (which might be different from root widget in the
+            // case of window emulation).
+            if (rootWidget != widget)
+              return static_cast<HWND>(widget->GetNativeData(NS_NATIVE_WINDOW));
+          }
         }
       }
     }
 
     nsDocAccessible* document = aAccessible->GetDocAccessible();
     if (document)
       return static_cast<HWND>(document->GetNativeWindow());
   }