From 5d658c7eb05147fca09d016a092139803456ae2d Mon Sep 17 00:00:00 2001 From: Chris Date: Thu, 27 Dec 2018 12:16:18 +0100 Subject: [PATCH] Cef - Added initialized checks to Cef.Get* (#2605) --- CefSharp.Core/Cef.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CefSharp.Core/Cef.h b/CefSharp.Core/Cef.h index c597da69a..583017b9f 100644 --- a/CefSharp.Core/Cef.h +++ b/CefSharp.Core/Cef.h @@ -32,6 +32,8 @@ namespace CefSharp { public ref class Cef sealed { + #define InitializedCheck() if (!_initialized) throw gcnew Exception(__FUNCTION__ + " requires that CEF has been initialized first.") + private: static Object^ _sync; @@ -370,6 +372,8 @@ namespace CefSharp /// A the global cookie manager static ICookieManager^ GetGlobalCookieManager() { + InitializedCheck(); + auto cookieManager = CefCookieManager::GetGlobalManager(NULL); if (cookieManager.get()) { @@ -389,6 +393,8 @@ namespace CefSharp /// A blocking cookie manager static ICookieManager^ GetBlockingCookieManager() { + InitializedCheck(); + auto cookieManager = CefCookieManager::GetBlockingManager(); if (cookieManager.get()) { @@ -500,6 +506,8 @@ namespace CefSharp /// Returns List of structs. static Task^>^ GetPlugins() { + InitializedCheck(); + auto taskVisitor = gcnew TaskWebPluginInfoVisitor(); CefRefPtr visitor = new PluginVisitor(taskVisitor); @@ -550,6 +558,8 @@ namespace CefSharp /// Returns the global request context or null. static IRequestContext^ GetGlobalRequestContext() { + InitializedCheck(); + auto context = CefRequestContext::GetGlobalContext(); if (context.get())