Skip to content

Commit

Permalink
Simplification: remove m_initialized and move allocation of impl
Browse files Browse the repository at this point in the history
  • Loading branch information
Lecrapouille committed Apr 20, 2024
1 parent a332467 commit a6c120a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
15 changes: 4 additions & 11 deletions addons/gdcef/gdcef/src/gdcef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -173,15 +174,14 @@ bool GDCef::initialize(godot::Dictionary config)
m_impl = nullptr;
return false;
}
m_initialized = true;
GDCEF_DEBUG_VAL("CefInitialize done with success");
return true;
}

//------------------------------------------------------------------------------
bool GDCef::isAlive()
{
return m_initialized && m_impl;
return m_impl != nullptr;
}

//------------------------------------------------------------------------------
Expand Down Expand Up @@ -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()
{
Expand All @@ -434,9 +428,8 @@ void GDCef::shutdown()
if (m_impl != nullptr)
{
CefQuitMessageLoop();
m_impl = nullptr;
}
m_initialized = false;
m_impl = nullptr;
}

//------------------------------------------------------------------------------
Expand Down
6 changes: 0 additions & 6 deletions addons/gdcef/gdcef/src/gdcef.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a6c120a

Please sign in to comment.