From 325ec0f3cf55c18be39096ddecbd419df33ce127 Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 30 Mar 2017 23:29:32 +0200 Subject: [PATCH] Fixed NullReferenceException in DoClose (#1980) * Fixed NullReferenceException in DoClose --- CefSharp.Core/Internals/ClientAdapter.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/CefSharp.Core/Internals/ClientAdapter.cpp b/CefSharp.Core/Internals/ClientAdapter.cpp index 94756ebc4..9679ddfc7 100644 --- a/CefSharp.Core/Internals/ClientAdapter.cpp +++ b/CefSharp.Core/Internals/ClientAdapter.cpp @@ -200,9 +200,12 @@ namespace CefSharp if (handler != nullptr) { - auto browserWrapper = GetBrowserWrapper(browser->GetIdentifier(), browser->IsPopup()); - - return handler->DoClose(_browserControl, browserWrapper); + //By this point it's possible IBrowser references have been disposed + //Rather than attempting to rework the rather complex closing logic + //It's easier to pass in a new wrapper and dispose it straight away + CefSharpBrowserWrapper browserWrapper(browser); + + return handler->DoClose(_browserControl, %browserWrapper); } return false;