revert: delayed initialization of cef was causing issues, reverted

This commit is contained in:
Almamu 2025-04-05 08:02:42 +02:00
parent b00531e647
commit b931b317fb
2 changed files with 32 additions and 39 deletions

View File

@ -6,42 +6,16 @@
using namespace WallpaperEngine::WebBrowser;
CWebBrowserContext::CWebBrowserContext (int argc, char** argv) : m_stopped (true), m_argc (argc), m_argv (argv) {}
CWebBrowserContext::~CWebBrowserContext () {
this->stop ();
}
void CWebBrowserContext::markAsUsed () {
if (this->m_stopped) {
this->delayedInitialization();
}
}
void CWebBrowserContext::stop () {
if (this->m_stopped) {
return;
}
sLog.out ("Shutting down CEF");
this->m_stopped = true;
CefShutdown ();
}
void CWebBrowserContext::delayedInitialization () {
this->m_stopped = false;
CWebBrowserContext::CWebBrowserContext (int argc, char** argv) : m_stopped (false) {
// clone original argc/argv as they'll be modified by cef
char** argv2 = new char*[this->m_argc];
char** argv2 = new char*[argc];
for (int i = 0; i < this->m_argc; i++) {
argv2 [i] = new char [strlen (this->m_argv [i]) + 1];
strcpy (argv2 [i], this->m_argv [i]);
for (int i = 0; i < argc; i++) {
argv2 [i] = new char [strlen (argv [i]) + 1];
strcpy (argv2 [i], argv [i]);
}
CefMainArgs args (this->m_argc, argv2);
CefMainArgs args (argc, argv2);
int exit_code = CefExecuteProcess (
args, nullptr, nullptr); // Spawned processes will terminate here(see CefIninitilize below). Maybe implementing
@ -72,4 +46,28 @@ void CWebBrowserContext::delayedInitialization () {
if (!result) {
sLog.exception ("CefInitialize: failed");
}
}
CWebBrowserContext::~CWebBrowserContext () {
this->stop ();
}
void CWebBrowserContext::markAsUsed () {
this->m_inUse = true;
}
bool CWebBrowserContext::isUsed () {
return this->m_inUse;
}
void CWebBrowserContext::stop () {
if (this->m_stopped) {
return;
}
sLog.out ("Shutting down CEF");
this->m_stopped = true;
CefShutdown ();
}

View File

@ -7,16 +7,11 @@ namespace WallpaperEngine::WebBrowser {
~CWebBrowserContext();
void markAsUsed();
bool isUsed();
void stop();
private:
/**
* Handles the actual initialization logic
*/
void delayedInitialization();
int m_argc;
char** m_argv;
bool m_stopped;
bool m_inUse;
};
} // namespace WallpaperEngine::WebBrowser