Skip to content

Commit 31079f6

Browse files
Synchronize changes from 1.6 branch [ci skip]
25169ea Addendum to 1281716 - Makes "Quit" close the game instantly without last frame-hang, and avoids risk of ungraceful exit code 5359aeb Fix 3 issues: MTA freeze on quit, CEF crash on quit (non-user facing), and 'Quit' closing the game being slow to clear the last frame due to redundant blocking operation.
2 parents e797893 + 25169ea commit 31079f6

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

Client/cefweb/CWebCore.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <cef3/cef/include/cef_parser.h>
1818
#include "WebBrowserHelpers.h"
1919
#include "CWebApp.h"
20+
#include <algorithm>
21+
#include <ranges>
2022

2123
// #define CEF_ENABLE_SANDBOX
2224
#ifdef CEF_ENABLE_SANDBOX
@@ -39,12 +41,15 @@ CWebCore::CWebCore()
3941

4042
CWebCore::~CWebCore()
4143
{
42-
// Unregister schema factories
44+
std::ranges::for_each(m_WebViews, [](const auto& pWebView) {
45+
if (pWebView) [[likely]]
46+
pWebView->CloseBrowser();
47+
});
48+
m_WebViews.clear();
4349
CefClearSchemeHandlerFactories();
4450

45-
// Shutdown CEF
46-
CefShutdown();
47-
51+
// Don't call CefShutdown() here to avoid freeze.
52+
// TerminateProcess (during quit) is called before CCore destruction anyways.
4853
delete m_pRequestsGUI;
4954
delete m_pXmlConfig;
5055
}

Client/core/CCore.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,13 +1471,13 @@ void CCore::Quit(bool bInstantly)
14711471
// Destroy the client
14721472
CModManager::GetSingleton().Unload();
14731473

1474-
// Destroy ourself
1474+
// Use TerminateProcess before destroying CCore to ensure clean exit code
1475+
TerminateProcess(GetCurrentProcess(), 0);
1476+
1477+
// Destroy ourself (unreachable but kept for completeness)
14751478
delete CCore::GetSingletonPtr();
14761479

14771480
WatchDogCompletedSection("Q0");
1478-
1479-
// Use TerminateProcess for now as exiting the normal way crashes
1480-
TerminateProcess(GetCurrentProcess(), 0);
14811481
}
14821482
else
14831483
{

0 commit comments

Comments
 (0)