From f6e58283a64e36af65a58001da063c2d0910ca08 Mon Sep 17 00:00:00 2001 From: amaitland Date: Fri, 20 Apr 2018 10:45:03 +1000 Subject: [PATCH] LegacyBinding - Remove objects from cache if key already exists Temp fix for #2301 Will be resolved properly in #2306 --- .../CefAppUnmanagedWrapper.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp b/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp index 3e6a93eef4..6878bab5e5 100644 --- a/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp +++ b/CefSharp.BrowserSubprocess.Core/CefAppUnmanagedWrapper.cpp @@ -478,6 +478,16 @@ namespace CefSharp for each (JavascriptObject^ obj in Enumerable::OfType(javascriptObjects)) { + //Using LegacyBinding with multiple ChromiumWebBrowser instances that share the same + //render process and using LegacyBinding will cause problems for the limited caching implementation + //that exists at the moment, for now we'll remove an object if already exists, same behaviour + //as the new binding method. + //TODO: This should be removed when https://github.com/cefsharp/CefSharp/issues/2306 + //Is complete as objects will be stored at the browser level + if (_javascriptObjects->ContainsKey(obj->JavascriptName)) + { + _javascriptObjects->Remove(obj->JavascriptName); + } _javascriptObjects->Add(obj->JavascriptName, obj); } }