@@ -1257,27 +1257,28 @@ namespace CefSharp
12571257
12581258 void ClientAdapter::MethodInvocationComplete (MethodInvocationResult^ result)
12591259 {
1260- if (result->CallbackId .HasValue )
1260+ auto browser = GetBrowserWrapper (result->BrowserId );
1261+
1262+ if (result->CallbackId .HasValue && browser != nullptr )
12611263 {
1262- auto message = CefProcessMessage::Create (kJavascriptAsyncMethodCallResponse );
1263- auto argList = message->GetArgumentList ();
1264- SetInt64 (argList, 0 , result->CallbackId .Value );
1265- argList->SetBool (1 , result->Success );
1266- if (result->Success )
1267- {
1268- SerializeV8Object (argList, 2 , result->Result );
1269- }
1270- else
1271- {
1272- argList->SetString (2 , StringUtils::ToNative (result->Message ));
1273- }
1264+ auto wrapper = static_cast <CefSharpBrowserWrapper^>(browser);
12741265
1275- auto browser = GetBrowserWrapper (result->BrowserId );
1266+ auto frame = wrapper-> Browser -> GetFrame (result->FrameId );
12761267
1277- if (browser != nullptr )
1268+ if (frame. get () && frame-> IsValid () )
12781269 {
1279- auto wrapper = static_cast <CefSharpBrowserWrapper^>(browser);
1280- auto frame = wrapper->Browser ->GetFrame (result->FrameId );
1270+ auto message = CefProcessMessage::Create (kJavascriptAsyncMethodCallResponse );
1271+ auto argList = message->GetArgumentList ();
1272+ SetInt64 (argList, 0 , result->CallbackId .Value );
1273+ argList->SetBool (1 , result->Success );
1274+ if (result->Success )
1275+ {
1276+ SerializeV8Object (argList, 2 , result->Result );
1277+ }
1278+ else
1279+ {
1280+ argList->SetString (2 , StringUtils::ToNative (result->Message ));
1281+ }
12811282
12821283 frame->SendProcessMessage (CefProcessId::PID_RENDERER, message);
12831284 }
0 commit comments