Bug 556524. Check for nsWindow existence before creating taskbar preview. r=roc a=blocker
authorFelipe Gomes <felipc@gmail.com>
Thu, 03 Feb 2011 16:47:23 -0800
changeset 61918 019e47cc11e27c8fbd2dd3909f3dbca2baa1bda0
parent 61917 d6fb5f21cc57a789e4115c142930bbb8a5c08cf8
child 61919 95fa72a8e8ab387ae57d177addfa9b93f1873170
push id18537
push userfelipc@gmail.com
push dateFri, 04 Feb 2011 00:48:05 +0000
treeherdermozilla-central@019e47cc11e2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc, blocker
bugs556524
milestone2.0b12pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 556524. Check for nsWindow existence before creating taskbar preview. r=roc a=blocker
browser/components/wintaskbar/WindowsPreviewPerTab.jsm
widget/src/windows/WinTaskbar.cpp
--- a/browser/components/wintaskbar/WindowsPreviewPerTab.jsm
+++ b/browser/components/wintaskbar/WindowsPreviewPerTab.jsm
@@ -454,17 +454,23 @@ TabWindow.prototype = {
 
   // Invoked when the given tab is added to this window
   newTab: function (tab) {
     let controller = new PreviewController(this, tab);
     let docShell = this.win
                   .QueryInterface(Ci.nsIInterfaceRequestor)
                   .getInterface(Ci.nsIWebNavigation)
                   .QueryInterface(Ci.nsIDocShell);
-    let preview = AeroPeek.taskbar.createTaskbarTabPreview(docShell, controller);
+    let preview;
+    try {
+      preview = AeroPeek.taskbar.createTaskbarTabPreview(docShell, controller);
+    } catch (e) {
+      controller.destroy();
+      return;
+    }
     preview.visible = AeroPeek.enabled;
     preview.active = this.tabbrowser.selectedTab == tab;
     // Grab the default favicon
     getFaviconAsImage(null, function (img) {
       // It is possible that we've already gotten the real favicon, so make sure
       // we have not set one before setting this default one.
       if (!preview.icon)
         preview.icon = img;
--- a/widget/src/windows/WinTaskbar.cpp
+++ b/widget/src/windows/WinTaskbar.cpp
@@ -354,16 +354,21 @@ WinTaskbar::CreateTaskbarTabPreview(nsID
   NS_ENSURE_ARG_POINTER(shell);
   NS_ENSURE_ARG_POINTER(controller);
 
   HWND toplevelHWND = ::GetAncestor(GetHWNDFromDocShell(shell), GA_ROOT);
 
   if (!toplevelHWND)
     return NS_ERROR_INVALID_ARG;
 
+  nsWindow *window = nsWindow::GetNSWindowPtr(toplevelHWND);
+
+  if (!window)
+    return NS_ERROR_INVALID_ARG;
+
   nsRefPtr<TaskbarTabPreview> preview(new TaskbarTabPreview(mTaskbar, controller, toplevelHWND, shell));
   if (!preview)
     return NS_ERROR_OUT_OF_MEMORY;
 
   preview.forget(_retval);
 
   return NS_OK;
 }