mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 23:10:38 +00:00
Windows: Simplify host shutdown.
The whole nativeHost/oldHost thing is unnecessary. This also fixes gl lost holder mismatches.
This commit is contained in:
parent
ccd9a17235
commit
90f3ae14e0
@ -181,8 +181,6 @@ void ConsoleListener::UpdateHandle()
|
||||
void ConsoleListener::Close()
|
||||
{
|
||||
#if defined(USING_WIN_UI)
|
||||
if (hConsole == NULL)
|
||||
return;
|
||||
|
||||
if (--refCount <= 0)
|
||||
{
|
||||
@ -209,8 +207,10 @@ void ConsoleListener::Close()
|
||||
refCount = 0;
|
||||
}
|
||||
|
||||
FreeConsole();
|
||||
hConsole = NULL;
|
||||
if (hConsole != NULL) {
|
||||
FreeConsole();
|
||||
hConsole = NULL;
|
||||
}
|
||||
#else
|
||||
fflush(NULL);
|
||||
#endif
|
||||
|
@ -331,7 +331,9 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
|
||||
VFSRegister("", new DirectoryAssetReader(savegame_dir));
|
||||
|
||||
#if (defined(MOBILE_DEVICE) || !defined(USING_QT_UI)) && !PPSSPP_PLATFORM(UWP)
|
||||
host = new NativeHost();
|
||||
if (host == nullptr) {
|
||||
host = new NativeHost();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
@ -526,7 +528,9 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
|
||||
#if !defined(MOBILE_DEVICE) && defined(USING_QT_UI)
|
||||
MainWindow* mainWindow = new MainWindow(0,fs);
|
||||
mainWindow->show();
|
||||
host = new QtHost(mainWindow);
|
||||
if (host == nullptr) {
|
||||
host = new QtHost(mainWindow);
|
||||
}
|
||||
#endif
|
||||
|
||||
// We do this here, instead of in NativeInitGraphics, because the display may be reset.
|
||||
@ -1066,18 +1070,19 @@ bool NativeIsRestarting() {
|
||||
}
|
||||
|
||||
void NativeShutdown() {
|
||||
screenManager->shutdown();
|
||||
delete screenManager;
|
||||
screenManager = nullptr;
|
||||
|
||||
host->ShutdownGraphics();
|
||||
if (GetGPUBackend() == GPUBackend::OPENGL) {
|
||||
gl_lost_manager_shutdown();
|
||||
}
|
||||
|
||||
screenManager->shutdown();
|
||||
delete screenManager;
|
||||
screenManager = 0;
|
||||
|
||||
#if !PPSSPP_PLATFORM(UWP)
|
||||
delete host;
|
||||
host = nullptr;
|
||||
#endif
|
||||
host = 0;
|
||||
g_Config.Save();
|
||||
|
||||
// Avoid shutting this down when restaring core.
|
||||
|
@ -77,7 +77,7 @@ void EmuThread_Stop()
|
||||
CloseHandle(emuThread);
|
||||
emuThread = 0;
|
||||
}
|
||||
host->UpdateUI();
|
||||
PostMessage(MainWindow::GetHWND(), MainWindow::WM_USER_UPDATE_UI, 0, 0);
|
||||
}
|
||||
|
||||
bool EmuThread_Ready()
|
||||
@ -91,10 +91,6 @@ unsigned int WINAPI TheThread(void *)
|
||||
|
||||
setCurrentThreadName("Emu"); // And graphics...
|
||||
|
||||
// Native overwrites host. Can't allow that.
|
||||
|
||||
Host *oldHost = host;
|
||||
|
||||
// Convert the command-line arguments to Unicode, then to proper UTF-8
|
||||
// (the benefit being that we don't have to pollute the UI project with win32 ifdefs and lots of Convert<whatever>To<whatever>).
|
||||
// This avoids issues with PPSSPP inadvertently destroying paths with Unicode glyphs
|
||||
@ -115,9 +111,6 @@ unsigned int WINAPI TheThread(void *)
|
||||
bool performingRestart = NativeIsRestarting();
|
||||
NativeInit(static_cast<int>(args.size()), &args[0], "1234", "1234", nullptr);
|
||||
|
||||
Host *nativeHost = host;
|
||||
host = oldHost;
|
||||
|
||||
host->UpdateUI();
|
||||
|
||||
GraphicsContext *graphicsContext;
|
||||
@ -204,12 +197,7 @@ shutdown:
|
||||
_InterlockedExchange(&emuThreadReady, THREAD_SHUTDOWN);
|
||||
|
||||
NativeShutdownGraphics();
|
||||
|
||||
host->ShutdownSound();
|
||||
host = nativeHost;
|
||||
NativeShutdown();
|
||||
host = oldHost;
|
||||
host->ShutdownGraphics();
|
||||
|
||||
_InterlockedExchange(&emuThreadReady, THREAD_END);
|
||||
|
||||
|
@ -200,6 +200,10 @@ int main(int argc, const char* argv[])
|
||||
{
|
||||
PROFILE_INIT();
|
||||
|
||||
#ifdef _DEBUG
|
||||
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID_NDK_PROFILER
|
||||
setenv("CPUPROFILE_FREQUENCY", "500", 1);
|
||||
setenv("CPUPROFILE", "/sdcard/gmon.out", 1);
|
||||
@ -433,8 +437,12 @@ int main(int argc, const char* argv[])
|
||||
|
||||
host->ShutdownGraphics();
|
||||
delete host;
|
||||
host = NULL;
|
||||
headlessHost = NULL;
|
||||
host = nullptr;
|
||||
headlessHost = nullptr;
|
||||
|
||||
VFSShutdown();
|
||||
LogManager::Shutdown();
|
||||
delete printfLogger;
|
||||
|
||||
#ifdef ANDROID_NDK_PROFILER
|
||||
moncleanup();
|
||||
|
Loading…
Reference in New Issue
Block a user