From 7ec1d78205ff7d85f89e797c1fc37eb19feff468 Mon Sep 17 00:00:00 2001 From: amaitland Date: Thu, 9 Jul 2015 11:14:58 +1000 Subject: [PATCH] Don't send message if browser->IsDisposed - shouldn't be throwing exceptions in destructor/finalizer blocks --- CefSharp.Core/Internals/CefSharpBrowserWrapper.cpp | 5 +++++ CefSharp.Core/Internals/CefSharpBrowserWrapper.h | 5 +++++ CefSharp.Core/Internals/JavascriptCallbackProxy.h | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CefSharp.Core/Internals/CefSharpBrowserWrapper.cpp b/CefSharp.Core/Internals/CefSharpBrowserWrapper.cpp index 87cc4c30f..894894b52 100644 --- a/CefSharp.Core/Internals/CefSharpBrowserWrapper.cpp +++ b/CefSharp.Core/Internals/CefSharpBrowserWrapper.cpp @@ -252,3 +252,8 @@ MCefRefPtr CefSharpBrowserWrapper::Browser::get() { return _browser; } + +bool CefSharpBrowserWrapper::IsDisposed::get() +{ + return _disposed; +} diff --git a/CefSharp.Core/Internals/CefSharpBrowserWrapper.h b/CefSharp.Core/Internals/CefSharpBrowserWrapper.h index a1b0d9379..82e69a301 100644 --- a/CefSharp.Core/Internals/CefSharpBrowserWrapper.h +++ b/CefSharp.Core/Internals/CefSharpBrowserWrapper.h @@ -197,6 +197,11 @@ namespace CefSharp /// /*--cef()--*/ virtual bool SendProcessMessage(CefProcessId targetProcess, CefRefPtr message); + + property bool IsDisposed + { + bool get(); + } }; } } \ No newline at end of file diff --git a/CefSharp.Core/Internals/JavascriptCallbackProxy.h b/CefSharp.Core/Internals/JavascriptCallbackProxy.h index f753ff102..423e511bb 100644 --- a/CefSharp.Core/Internals/JavascriptCallbackProxy.h +++ b/CefSharp.Core/Internals/JavascriptCallbackProxy.h @@ -45,7 +45,7 @@ namespace CefSharp !JavascriptCallbackProxy() { auto browser = GetBrowser(); - if (browser != nullptr) + if (browser != nullptr && !browser->IsDisposed) { browser->SendProcessMessage(CefProcessId::PID_RENDERER, CreateDestroyMessage()); }