From d12310676d262c0d635eb90d4a62a418ce6a506c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 16 Apr 2022 16:54:21 +0300 Subject: also we shall remove garbage from the root folder after changing platform --- plugins/PluginUpdater/src/PluginUpdater.cpp | 3 +++ plugins/PluginUpdater/src/Utils.cpp | 25 +++++++++++++++---------- plugins/PluginUpdater/src/stdafx.h | 2 ++ 3 files changed, 20 insertions(+), 10 deletions(-) (limited to 'plugins') diff --git a/plugins/PluginUpdater/src/PluginUpdater.cpp b/plugins/PluginUpdater/src/PluginUpdater.cpp index 81b793e43e..cde00d9eb2 100644 --- a/plugins/PluginUpdater/src/PluginUpdater.cpp +++ b/plugins/PluginUpdater/src/PluginUpdater.cpp @@ -88,6 +88,9 @@ int CMPlugin::Load() m_impl.m_timer.Start(60 * 1000); InitTimer(0); + // just to be sure that no garbage remained after restart + DeleteFileW(InvertMirandaPlatform()); + g_plugin.setByte(DB_SETTING_NEED_RESTART, 0); uint32_t dwLen = GetTempPath(_countof(g_wszTempPath), g_wszTempPath); diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp index b39f3c7acf..298c46c0f9 100644 --- a/plugins/PluginUpdater/src/Utils.cpp +++ b/plugins/PluginUpdater/src/Utils.cpp @@ -324,17 +324,22 @@ char* StrToLower(char *str) ///////////////////////////////////////////////////////////////////////////////////////// +MFilePath InvertMirandaPlatform() +{ + MFilePath wszPath; + #ifdef _WIN64 + wszPath.Format(L"%s\\miranda32.exe", g_mirandaPath.get()); + #else + wszPath.Format(L"%s\\miranda64.exe", g_mirandaPath.get()); + #endif + return wszPath; +} + void DoRestart() { BOOL bRestartCurrentProfile = g_plugin.getBool("RestartCurrentProfile", true); - if (g_plugin.bChangePlatform) { - MFilePath mirstartpath; -#ifdef _WIN64 - mirstartpath.Format(L"%s\\miranda32.exe", g_mirandaPath.get()); -#else - mirstartpath.Format(L"%s\\miranda64.exe", g_mirandaPath.get()); -#endif - CallServiceSync(MS_SYSTEM_RESTART, bRestartCurrentProfile, (LPARAM)mirstartpath.c_str()); - } - else CallServiceSync(MS_SYSTEM_RESTART, bRestartCurrentProfile); + if (g_plugin.bChangePlatform) + CallServiceSync(MS_SYSTEM_RESTART, bRestartCurrentProfile, (LPARAM)InvertMirandaPlatform().c_str()); + else + CallServiceSync(MS_SYSTEM_RESTART, bRestartCurrentProfile); } diff --git a/plugins/PluginUpdater/src/stdafx.h b/plugins/PluginUpdater/src/stdafx.h index 9aaeef3415..b7085723f8 100644 --- a/plugins/PluginUpdater/src/stdafx.h +++ b/plugins/PluginUpdater/src/stdafx.h @@ -268,3 +268,5 @@ void RemoveBackupFolders(void); void RollbackChanges(TFileName &pwszBackupFolder); char* StrToLower(char *str); + +MFilePath InvertMirandaPlatform(); -- cgit v1.2.3