]> khamidou — GitHub mirrors - electron.git/commitdiff
Check whether WebContents lives before using its methods
authorCheng Zhao <zcbenz@gmail.com>
Mon, 6 Jul 2015 10:21:04 +0000 (18:21 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Mon, 6 Jul 2015 10:21:04 +0000 (18:21 +0800)
Close #2064.

atom/browser/api/atom_api_web_contents.cc
atom/browser/api/atom_api_web_contents.h

index d07b03760d0b8e2d57a75d90cf295a1006cc47e9..480cb51c30464eba52a6b277cf5e1d93669d3256 100644 (file)
@@ -792,6 +792,10 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
       isolate, v8::Local<v8::ObjectTemplate>::New(isolate, template_));
 }
 
+bool WebContents::IsDestroyed() const {
+  return !IsAlive();
+}
+
 void WebContents::OnRendererMessage(const base::string16& channel,
                                     const base::ListValue& args) {
   // webContents.emit(channel, new Event(), args...);
index e6056d05657423eacd2d3876ea55c6bfc58b8424..085f82e3dd642c137da54cbf223e07d4332b77dc 100644 (file)
@@ -111,6 +111,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
   // mate::Wrappable:
   mate::ObjectTemplateBuilder GetObjectTemplateBuilder(
       v8::Isolate* isolate) override;
+  bool IsDestroyed() const override;
 
   // content::WebContentsDelegate:
   bool AddMessageToConsole(content::WebContents* source,