From 40a9f19352d8a1bbfdf9ccc49f44bc94bca67d31 Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Fri, 2 Oct 2015 16:00:57 -0700 Subject: [PATCH] Fixed: crash when opening a platformWindow with a popup blocker Previously, when opening a CPPlatformWindow a crash happened when this new window was blocked by the browser (addblock, or browser feature). Now when opening an external window, we check if the DOMWindow has been created. This PR has modified the method isVisible of CPPlatformWindow. We now check if the _DOMWindow is not NULL and undefined. --- AppKit/Platform/CPPlatformWindow.j | 2 +- AppKit/Platform/DOM/CPPlatformWindow+DOM.j | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/AppKit/Platform/CPPlatformWindow.j b/AppKit/Platform/CPPlatformWindow.j index fb742b351..de2080bcc 100644 --- a/AppKit/Platform/CPPlatformWindow.j +++ b/AppKit/Platform/CPPlatformWindow.j @@ -213,7 +213,7 @@ var PrimaryPlatformWindow = NULL; - (BOOL)isVisible { #if PLATFORM(DOM) - return _DOMWindow !== NULL; + return _DOMWindow !== NULL && _DOMWindow !== undefined; #else return NO; #endif diff --git a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j index e96a5708c..bb183bd99 100644 --- a/AppKit/Platform/DOM/CPPlatformWindow+DOM.j +++ b/AppKit/Platform/DOM/CPPlatformWindow+DOM.j @@ -568,6 +568,9 @@ _CPPlatformWindowWillCloseNotification = @"_CPPlatformWindowWillCloseNotificatio _DOMWindow = window.open("about:blank", "_blank", "menubar=no,location=no,resizable=yes,scrollbars=no,status=no,left=" + CGRectGetMinX(_contentRect) + ",top=" + CGRectGetMinY(_contentRect) + ",width=" + CGRectGetWidth(_contentRect) + ",height=" + CGRectGetHeight(_contentRect)); + if (!_DOMWindow) + return; + [PlatformWindows addObject:self]; // FIXME: cpSetFrame? @@ -1414,6 +1417,9 @@ _CPPlatformWindowWillCloseNotification = @"_CPPlatformWindowWillCloseNotificatio - (void)order:(CPWindowOrderingMode)orderingMode window:(CPWindow)aWindow relativeTo:(CPWindow)otherWindow { + if (!_DOMWindow) + return; + [CPPlatform initializeScreenIfNecessary]; // Grab the appropriate level for the layer, and create it if