mac: InspectableWebContents should be destroyed before release NSWindow.
Fixes atom/atom#1841.
This commit is contained in:
parent
e576d4c014
commit
d6079782d1
3 changed files with 13 additions and 7 deletions
|
@ -57,12 +57,12 @@ NativeWindow::NativeWindow(content::WebContents* web_contents,
|
||||||
base::DictionaryValue* options)
|
base::DictionaryValue* options)
|
||||||
: content::WebContentsObserver(web_contents),
|
: content::WebContentsObserver(web_contents),
|
||||||
has_frame_(true),
|
has_frame_(true),
|
||||||
|
inspectable_web_contents_(
|
||||||
|
brightray::InspectableWebContents::Create(web_contents)),
|
||||||
is_closed_(false),
|
is_closed_(false),
|
||||||
node_integration_("except-iframe"),
|
node_integration_("except-iframe"),
|
||||||
has_dialog_attached_(false),
|
has_dialog_attached_(false),
|
||||||
weak_factory_(this),
|
weak_factory_(this) {
|
||||||
inspectable_web_contents_(
|
|
||||||
brightray::InspectableWebContents::Create(web_contents)) {
|
|
||||||
options->GetBoolean(switches::kFrame, &has_frame_);
|
options->GetBoolean(switches::kFrame, &has_frame_);
|
||||||
|
|
||||||
#if defined(OS_MACOSX)
|
#if defined(OS_MACOSX)
|
||||||
|
|
|
@ -251,6 +251,8 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
// Window icon.
|
// Window icon.
|
||||||
gfx::Image icon_;
|
gfx::Image icon_;
|
||||||
|
|
||||||
|
scoped_ptr<brightray::InspectableWebContents> inspectable_web_contents_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Schedule a notification unresponsive event.
|
// Schedule a notification unresponsive event.
|
||||||
void ScheduleUnresponsiveEvent(int ms);
|
void ScheduleUnresponsiveEvent(int ms);
|
||||||
|
@ -304,7 +306,6 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
scoped_ptr<DevToolsWebContentsObserver> devtools_web_contents_observer_;
|
scoped_ptr<DevToolsWebContentsObserver> devtools_web_contents_observer_;
|
||||||
|
|
||||||
scoped_ptr<AtomJavaScriptDialogManager> dialog_manager_;
|
scoped_ptr<AtomJavaScriptDialogManager> dialog_manager_;
|
||||||
scoped_ptr<brightray::InspectableWebContents> inspectable_web_contents_;
|
|
||||||
|
|
||||||
// Maps url to file path, used by the file requests sent from devtools.
|
// Maps url to file path, used by the file requests sent from devtools.
|
||||||
typedef std::map<std::string, base::FilePath> PathsMap;
|
typedef std::map<std::string, base::FilePath> PathsMap;
|
||||||
|
|
|
@ -66,7 +66,6 @@ static const CGFloat kAtomWindowCornerRadius = 4.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)windowWillClose:(NSNotification*)notification {
|
- (void)windowWillClose:(NSNotification*)notification {
|
||||||
shell_->window() = nil;
|
|
||||||
[self autorelease];
|
[self autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,6 +176,9 @@ NativeWindowMac::NativeWindowMac(content::WebContents* web_contents,
|
||||||
[[AtomNSWindowDelegate alloc] initWithShell:this];
|
[[AtomNSWindowDelegate alloc] initWithShell:this];
|
||||||
[window() setDelegate:delegate];
|
[window() setDelegate:delegate];
|
||||||
|
|
||||||
|
// We will manage window's lifetime ourselves.
|
||||||
|
[window() setReleasedWhenClosed:NO];
|
||||||
|
|
||||||
// Enable the NSView to accept first mouse event.
|
// Enable the NSView to accept first mouse event.
|
||||||
bool acceptsFirstMouse = false;
|
bool acceptsFirstMouse = false;
|
||||||
options->GetBoolean(switches::kAcceptFirstMouse, &acceptsFirstMouse);
|
options->GetBoolean(switches::kAcceptFirstMouse, &acceptsFirstMouse);
|
||||||
|
@ -198,9 +200,12 @@ NativeWindowMac::NativeWindowMac(content::WebContents* web_contents,
|
||||||
}
|
}
|
||||||
|
|
||||||
NativeWindowMac::~NativeWindowMac() {
|
NativeWindowMac::~NativeWindowMac() {
|
||||||
|
// Force InspectableWebContents to be destroyed before we destroy window,
|
||||||
|
// because it may still be observing the window at this time.
|
||||||
|
inspectable_web_contents_.reset();
|
||||||
|
|
||||||
if (window())
|
if (window())
|
||||||
// Use autorelease since we may have delegates or observers at this time.
|
[window_ release];
|
||||||
[window() autorelease];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindowMac::Close() {
|
void NativeWindowMac::Close() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue