Add a restarting flag to NativeInit/NativeShutdown.

Will be used externally.  Also cleanup some LogManager init/shutdown in
case these are called multiple times on Windows.
This commit is contained in:
Unknown W. Brackets 2017-04-15 16:30:37 -07:00
parent bf02f7d98b
commit 638a015ced
3 changed files with 27 additions and 3 deletions

View File

@ -1094,7 +1094,8 @@ void Config::Save() {
control->Delete("DPadRadius");
IniFile::Section *log = iniFile.GetOrCreateSection(logSectionName);
LogManager::GetInstance()->SaveConfig(log);
if (LogManager::GetInstance())
LogManager::GetInstance()->SaveConfig(log);
if (!iniFile.Save(iniFilename_.c_str())) {
ERROR_LOG(LOADER, "Error saving config - can't write ini %s", iniFilename_.c_str());

View File

@ -134,6 +134,7 @@ bool targetIsJailbroken;
bool g_TakeScreenshot;
static bool isOuya;
static bool resized = false;
static bool restarting = false;
struct PendingMessage {
std::string msg;
@ -361,8 +362,10 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
g_Config.appCacheDirectory = cache_dir;
}
if (!LogManager::GetInstance())
LogManager::Init();
#ifndef _WIN32
LogManager::Init();
logger = new AndroidLogger();
g_Config.AddSearchPath(user_data_path);
@ -532,6 +535,9 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
if (GetGPUBackend() == GPUBackend::OPENGL) {
gl_lost_manager_init();
}
// Must be done restarting by now.
restarting = false;
}
static UI::Style MakeStyle(uint32_t fg, uint32_t bg) {
@ -1051,6 +1057,14 @@ void NativeResized() {
resized = true;
}
void NativeSetRestarting() {
restarting = true;
}
bool NativeIsRestarting() {
return restarting;
}
void NativeShutdown() {
if (GetGPUBackend() == GPUBackend::OPENGL) {
gl_lost_manager_shutdown();
@ -1065,7 +1079,10 @@ void NativeShutdown() {
#endif
host = 0;
g_Config.Save();
LogManager::Shutdown();
// Avoid shutting this down when restaring core.
if (!restarting)
LogManager::Shutdown();
#ifdef ANDROID_NDK_PROFILER
moncleanup();

View File

@ -63,6 +63,12 @@ void NativeDeviceRestore();
// and only write dp_xres and dp_yres.
void NativeResized();
// Set a flag to indicate a restart. Reset after NativeInit().
void NativeSetRestarting();
// Retrieve current restarting flag.
bool NativeIsRestarting();
// Called ~sixty times a second, delivers the current input state.
// Main thread.
void NativeUpdate();