Skip to content
Snippets Groups Projects
Commit 76bac52a authored by svornost's avatar svornost
Browse files

CefExecuteProcess needs the app pointer otherwise initialization in...

CefExecuteProcess needs the app pointer otherwise initialization in multi-process mode doesn't work correctly
parent fe1d91c2
No related branches found
No related tags found
1 merge request!9123Fix FCHost multiprocess mode initialization
......@@ -163,10 +163,6 @@ void FCHostApp::OnContextCreated(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFra
int FCHostApp::main(const CefMainArgs& args, CefCommandLine* commandLine)
{
// It will create the first browser instance in OnContextInitialized() after
// CEF has initialized.
CefRefPtr<FCHostApp> app(new FCHostApp);
// Specify CEF global settings here.
CefSettings settings;
......@@ -176,7 +172,7 @@ int FCHostApp::main(const CefMainArgs& args, CefCommandLine* commandLine)
}
// Cache location is required for local storage
cef_string_from_path(app->GetLocalStorePath(), &settings.cache_path);
cef_string_from_path(this->GetLocalStorePath(), &settings.cache_path);
// When generating projects with CMake the CEF_USE_SANDBOX value will be defined
// automatically. Pass -DUSE_SANDBOX=OFF to the CMake command-line to disable
......@@ -186,7 +182,7 @@ int FCHostApp::main(const CefMainArgs& args, CefCommandLine* commandLine)
#endif
// Initialize CEF for the browser process.
CefInitialize(args, settings, app.get(), nullptr);
CefInitialize(args, settings, this, nullptr);
// Run the CEF message loop. This will block until CefQuitMessageLoop() is
// called.
......
......@@ -14,6 +14,8 @@ class CefCommandLine;
// Implement application-level callbacks for the browser process.
class FCHostApp : public CefApp, public CefBrowserProcessHandler, public CefRenderProcessHandler {
public:
FCHostApp();
// CefApp methods:
virtual CefRefPtr<CefBrowserProcessHandler> GetBrowserProcessHandler()
OVERRIDE {
......@@ -30,10 +32,9 @@ class FCHostApp : public CefApp, public CefBrowserProcessHandler, public CefRend
std::filesystem::path GetLocalStorePath();
static int main(const CefMainArgs& args, CefCommandLine* commandLine);
int main(const CefMainArgs& args, CefCommandLine* commandLine);
private:
FCHostApp();
// Include the default reference counting implementation.
IMPLEMENT_REFCOUNTING(FCHostApp);
};
......@@ -43,11 +43,15 @@ int XIOErrorHandlerImpl(Display* display) {
int main(int argc, char* argv[]) {
// Provide CEF with command-line arguments.
CefMainArgs main_args(argc, argv);
// It will create the first browser instance in OnContextInitialized() after
// CEF has initialized.
CefRefPtr<FCHostApp> app(new FCHostApp);
// CEF applications have multiple sub-processes (render, plugin, GPU, etc)
// that share the same executable. This function checks the command-line and,
// if this is a sub-process, executes the appropriate logic.
int exit_code = CefExecuteProcess(main_args, nullptr, nullptr);
int exit_code = CefExecuteProcess(main_args, app, nullptr);
if (exit_code >= 0) {
// The sub-process has completed so return here.
return exit_code;
......@@ -63,5 +67,5 @@ int main(int argc, char* argv[]) {
CefRefPtr<CefCommandLine> command_line = CefCommandLine::CreateCommandLine();
command_line->InitFromArgv(argc, argv);
return FCHostApp::main(main_args, command_line);
return app->main(main_args, command_line);
}
......@@ -31,10 +31,14 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
// Provide CEF with command-line arguments.
CefMainArgs main_args(hInstance);
// It will create the first browser instance in OnContextInitialized() after
// CEF has initialized.
CefRefPtr<FCHostApp> app(new FCHostApp);
// CEF applications have multiple sub-processes (render, plugin, GPU, etc)
// that share the same executable. This function checks the command-line and,
// if this is a sub-process, executes the appropriate logic.
int exit_code = CefExecuteProcess(main_args, nullptr, nullptr);
int exit_code = CefExecuteProcess(main_args, app, nullptr);
if (exit_code >= 0) {
// The sub-process has completed so return here.
return exit_code;
......@@ -43,5 +47,5 @@ int APIENTRY wWinMain(HINSTANCE hInstance,
CefRefPtr<CefCommandLine> command_line = CefCommandLine::CreateCommandLine();
command_line->InitFromString(lpCmdLine);
return FCHostApp::main(main_args, command_line);
return app->main(main_args, command_line);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment