From a6c120ad499d8410a4d50249d5c6bf7c53f7058e Mon Sep 17 00:00:00 2001 From: Quentin Quadrat Date: Sat, 20 Apr 2024 13:18:37 +0200 Subject: [PATCH] Simplification: remove m_initialized and move allocation of impl --- addons/gdcef/gdcef/src/gdcef.cpp | 15 ++++----------- addons/gdcef/gdcef/src/gdcef.hpp | 6 ------ 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/addons/gdcef/gdcef/src/gdcef.cpp b/addons/gdcef/gdcef/src/gdcef.cpp index 73d765b..9a3457e 100644 --- a/addons/gdcef/gdcef/src/gdcef.cpp +++ b/addons/gdcef/gdcef/src/gdcef.cpp @@ -109,11 +109,12 @@ void GDCef::_init() //------------------------------------------------------------------------------ bool GDCef::initialize(godot::Dictionary config) { - if (m_initialized) + if (m_impl != nullptr) { GDCEF_ERROR("Already initialized"); return false; } + m_impl = new GDCef::Impl(*this); // Get the folder path in which your application and CEF artifacts are present fs::path folder; @@ -173,7 +174,6 @@ bool GDCef::initialize(godot::Dictionary config) m_impl = nullptr; return false; } - m_initialized = true; GDCEF_DEBUG_VAL("CefInitialize done with success"); return true; } @@ -181,7 +181,7 @@ bool GDCef::initialize(godot::Dictionary config) //------------------------------------------------------------------------------ bool GDCef::isAlive() { - return m_initialized && m_impl; + return m_impl != nullptr; } //------------------------------------------------------------------------------ @@ -415,12 +415,6 @@ static void configureBrowser(CefBrowserSettings& browser_settings, browser_settings.webgl = getConfig(config, "webgl", STATE_ENABLED); } -//------------------------------------------------------------------------------ -GDCef::GDCef() -{ - m_impl = new GDCef::Impl(*this); -} - //------------------------------------------------------------------------------ GDCef::~GDCef() { @@ -434,9 +428,8 @@ void GDCef::shutdown() if (m_impl != nullptr) { CefQuitMessageLoop(); - m_impl = nullptr; } - m_initialized = false; + m_impl = nullptr; } //------------------------------------------------------------------------------ diff --git a/addons/gdcef/gdcef/src/gdcef.hpp b/addons/gdcef/gdcef/src/gdcef.hpp index 176d1d4..035ecee 100644 --- a/addons/gdcef/gdcef/src/gdcef.hpp +++ b/addons/gdcef/gdcef/src/gdcef.hpp @@ -220,8 +220,6 @@ class GDCef : public godot::Node public: - GDCef(); - // ------------------------------------------------------------------------- //! \brief Destructor. Release CEF memory and sub CEF processes are notified //! that the application is exiting. All browsers are destroyed. @@ -300,10 +298,6 @@ class GDCef : public godot::Node CefWindowInfo m_window_info; //! \brief CefSettings m_cef_settings; - //! \brief Since we have to pass parameter to Godot _init() which is not possible. - //! We have to call initialize() method which can be potentially be called several - //! times. - bool m_initialized = false; //! \brief Hold last error messages mutable std::stringstream m_error; //! \brief Allow accessing to camera and microphones