From a1941d8a8109469e14f0276ee18fd1efacfe62f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 6 Mar 2017 10:51:28 +0100 Subject: [PATCH] It's enough to call net::Init/Shutdown in NativeInit/Shutdown. Remove other calls. --- Core/HLE/sceNet.cpp | 13 ------------- UI/NativeApp.cpp | 15 ++++++++------- Windows/main.cpp | 24 +++++++++++++----------- android/jni/app-android.cpp | 3 --- ext/native/base/PCMain.cpp | 3 --- ext/native/base/QtMain.cpp | 2 -- ios/ViewController.mm | 2 -- 7 files changed, 21 insertions(+), 41 deletions(-) diff --git a/Core/HLE/sceNet.cpp b/Core/HLE/sceNet.cpp index 002eb03be..d2f4d0c13 100644 --- a/Core/HLE/sceNet.cpp +++ b/Core/HLE/sceNet.cpp @@ -55,26 +55,13 @@ static void __ResetInitNetLib() { void __NetInit() { portOffset = g_Config.iPortOffset; - //net::Init(); -#ifdef _MSC_VER - WSADATA data; - int iResult = WSAStartup(MAKEWORD(2, 2), &data); - if (iResult != NOERROR){ - ERROR_LOG(SCENET, "WSA Failed"); - } -#endif __ResetInitNetLib(); } void __NetShutdown() { __ResetInitNetLib(); - //net::Shutdown(); -#ifdef _MSC_VER - WSACleanup(); -#endif } - static void __UpdateApctlHandlers(int oldState, int newState, int flag, int error) { u32 args[5] = { 0, 0, 0, 0, 0 }; args[0] = oldState; diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 8f0e84068..7acf62fcb 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -48,6 +48,7 @@ #include "file/vfs.h" #include "file/zip_read.h" #include "net/http_client.h" +#include "net/resolve.h" #include "gfx_es2/draw_text.h" #include "gfx_es2/gpu_features.h" #include "gfx/gl_lost_manager.h" @@ -299,6 +300,8 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch monstartup("ppsspp_jni.so"); #endif + net::Init(); + InitFastMath(cpu_info.bNEON); SetupAudioFormats(); @@ -1038,9 +1041,8 @@ void NativeShutdown() { delete host; host = 0; g_Config.Save(); -#ifndef _WIN32 LogManager::Shutdown(); -#endif + #ifdef ANDROID_NDK_PROFILER moncleanup(); #endif @@ -1048,16 +1050,15 @@ void NativeShutdown() { ILOG("NativeShutdown called"); System_SendMessage("finish", ""); + + net::Shutdown(); + // This means that the activity has been completely destroyed. PPSSPP does not // boot up correctly with "dirty" global variables currently, so we hack around that // by simply exiting. -#ifdef __ANDROID__ +#if PPSSPP_PLATFORM(ANDROID) exit(0); #endif - -#if defined(_WIN32) && !PPSSPP_PLATFORM(UWP) - RemoveFontResourceEx(L"assets/Roboto-Condensed.ttf", FR_PRIVATE, NULL); -#endif } void NativePermissionStatus(SystemPermission permission, PermissionStatus status) { diff --git a/Windows/main.cpp b/Windows/main.cpp index d020ac26b..43dbc5e64 100644 --- a/Windows/main.cpp +++ b/Windows/main.cpp @@ -295,7 +295,15 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin setCurrentThreadName("Main"); CoInitializeEx(NULL, COINIT_MULTITHREADED); - net::Init(); + + // Windows, API init stuff + INITCOMMONCONTROLSEX comm; + comm.dwSize = sizeof(comm); + comm.dwICC = ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES | ICC_TAB_CLASSES; + InitCommonControlsEx(&comm); + + EnableCrashingOnCrashes(); + #ifdef _DEBUG _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); #endif @@ -306,8 +314,6 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin _set_FMA3_enable(0); #endif - EnableCrashingOnCrashes(); - #ifndef _DEBUG bool showLog = false; #else @@ -434,12 +440,8 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin if (debugLogLevel) LogManager::GetInstance()->SetAllLogLevels(LogTypes::LDEBUG); - // Windows, API init stuff - INITCOMMONCONTROLSEX comm; - comm.dwSize = sizeof(comm); - comm.dwICC = ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES | ICC_TAB_CLASSES; - InitCommonControlsEx(&comm); - timeBeginPeriod(1); + timeBeginPeriod(1); // TODO: Evaluate if this makes sense to keep. + MainWindow::Init(_hInstance); g_hPopupMenus = LoadMenu(_hInstance, (LPCWSTR)IDR_POPUPMENUS); @@ -521,6 +523,8 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin VFSShutdown(); InputDevice::StopPolling(); + + // The emuthread calls NativeShutdown when shutting down. EmuThread_Stop(); MainWindow::DestroyDebugWindows(); @@ -528,14 +532,12 @@ int WINAPI WinMain(HINSTANCE _hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLin timeEndPeriod(1); delete host; - g_Config.Save(); LogManager::Shutdown(); if (g_Config.bRestartRequired) { W32Util::ExitAndRestart(); } - net::Shutdown(); CoUninitialize(); return 0; diff --git a/android/jni/app-android.cpp b/android/jni/app-android.cpp index b6bda7652..8853a00e1 100644 --- a/android/jni/app-android.cpp +++ b/android/jni/app-android.cpp @@ -542,8 +542,6 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init std::string version; bool landscape; - net::Init(); - // Unfortunately, on the Samsung Galaxy S7, this isn't in /proc/cpuinfo. // We also can't read it from __system_property_get. if (buildBoard == "universal8890") { @@ -611,7 +609,6 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_shutdown(JNIEnv *, jclass) { ILOG("NativeApp.shutdown() -- begin"); NativeShutdown(); VFSShutdown(); - net::Shutdown(); ILOG("NativeApp.shutdown() -- end"); } diff --git a/ext/native/base/PCMain.cpp b/ext/native/base/PCMain.cpp index 9e54c8287..d17134d27 100644 --- a/ext/native/base/PCMain.cpp +++ b/ext/native/base/PCMain.cpp @@ -428,8 +428,6 @@ int main(int argc, char *argv[]) { bool landscape; NativeGetAppInfo(&app_name, &app_name_nice, &landscape, &version); - net::Init(); - bool joystick_enabled = true; if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_GAMECONTROLLER | SDL_INIT_AUDIO) < 0) { joystick_enabled = false; @@ -930,7 +928,6 @@ int main(int argc, char *argv[]) { #endif SDL_GL_DeleteContext(glContext); SDL_Quit(); - net::Shutdown(); #if PPSSPP_PLATFORM(RPI) bcm_host_deinit(); #endif diff --git a/ext/native/base/QtMain.cpp b/ext/native/base/QtMain.cpp index cf4ea3c88..6e52e46fa 100644 --- a/ext/native/base/QtMain.cpp +++ b/ext/native/base/QtMain.cpp @@ -443,7 +443,6 @@ int main(int argc, char *argv[]) pixel_yres = res.height(); g_dpi_scale = CalculateDPIScale(); dp_xres = (int)(pixel_xres * g_dpi_scale); dp_yres = (int)(pixel_yres * g_dpi_scale); - net::Init(); std::string savegame_dir = "."; std::string assets_dir = "."; #if QT_VERSION > QT_VERSION_CHECK(5, 0, 0) @@ -469,7 +468,6 @@ int main(int argc, char *argv[]) SDL_CloseAudio(); #endif NativeShutdown(); - net::Shutdown(); return ret; } diff --git a/ios/ViewController.mm b/ios/ViewController.mm index 769aa9d68..9ac8df610 100644 --- a/ios/ViewController.mm +++ b/ios/ViewController.mm @@ -101,8 +101,6 @@ static GraphicsContext *graphicsContext; memset(&input_state, 0, sizeof(input_state)); - net::Init(); - iosCanUseJit = true; targetIsJailbroken = false; NSArray *jailPath = [NSArray arrayWithObjects: