It's enough to call net::Init/Shutdown in NativeInit/Shutdown. Remove other calls.

This commit is contained in:
Henrik Rydgård 2017-03-06 10:51:28 +01:00
parent 7b0a942905
commit a1941d8a81
7 changed files with 21 additions and 41 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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;

View File

@ -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");
}

View File

@ -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

View File

@ -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;
}

View File

@ -101,8 +101,6 @@ static GraphicsContext *graphicsContext;
memset(&input_state, 0, sizeof(input_state));
net::Init();
iosCanUseJit = true;
targetIsJailbroken = false;
NSArray *jailPath = [NSArray arrayWithObjects: