From 86b82de0ec0aa933bf8101cef55597e19d78d6a8 Mon Sep 17 00:00:00 2001
From: George Hazan <ghazan@miranda.im>
Date: Sat, 16 Apr 2022 15:02:19 +0300
Subject: =?UTF-8?q?fixes=20#3008=20(=D0=9D=D0=B5=D0=B4=D0=BE=D1=80=D0=B0?=
 =?UTF-8?q?=D0=B1=D0=BE=D1=82=D0=BA=D0=B0=20=D0=BF=D1=80=D0=B8=20=D1=81?=
 =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B5=20=D1=80=D0=B0=D0=B7=D1=80=D1=8F=D0=B4?=
 =?UTF-8?q?=D0=BD=D0=BE=D1=81=D1=82=D0=B8=20=D0=BF=D1=80=D0=B8=D0=BB=D0=BE?=
 =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 plugins/PluginUpdater/src/DlgUpdate.cpp     | 11 -----------
 plugins/PluginUpdater/src/Notifications.cpp |  2 +-
 plugins/PluginUpdater/src/Utils.cpp         | 19 +++++++++++++++++++
 plugins/PluginUpdater/src/stdafx.h          |  2 ++
 plugins/PluginUpdater/src/version.h         |  2 +-
 5 files changed, 23 insertions(+), 13 deletions(-)

(limited to 'plugins/PluginUpdater')

diff --git a/plugins/PluginUpdater/src/DlgUpdate.cpp b/plugins/PluginUpdater/src/DlgUpdate.cpp
index d9c0401a21..8f626876fa 100644
--- a/plugins/PluginUpdater/src/DlgUpdate.cpp
+++ b/plugins/PluginUpdater/src/DlgUpdate.cpp
@@ -148,17 +148,6 @@ LBL_Error:
 			}
 
 		pDlg->Close();
-		BOOL bRestartCurrentProfile = g_plugin.getBool("RestartCurrentProfile", true);
-		if (g_plugin.bChangePlatform) {
-			TFileName mirstartpath;
-#ifdef _WIN64
-			mir_snwprintf(mirstartpath, L"%s\\miranda32.exe", wszMirandaPath.get());
-#else
-			mir_snwprintf(mirstartpath, L"%s\\miranda64.exe", wszMirandaPath.get());
-#endif
-			CallServiceSync(MS_SYSTEM_RESTART, bRestartCurrentProfile, (LPARAM)mirstartpath);
-		}
-		else CallServiceSync(MS_SYSTEM_RESTART, bRestartCurrentProfile);
 	}
 
 	void ResizeVert(int yy)
diff --git a/plugins/PluginUpdater/src/Notifications.cpp b/plugins/PluginUpdater/src/Notifications.cpp
index 24471f507d..e9724717dd 100644
--- a/plugins/PluginUpdater/src/Notifications.cpp
+++ b/plugins/PluginUpdater/src/Notifications.cpp
@@ -74,7 +74,7 @@ void CALLBACK RestartPrompt(void *)
 			return;
 	}
 
-	CallService(MS_SYSTEM_RESTART, g_plugin.getBool("RestartCurrentProfile", true), 0);
+	DoRestart();
 }
 
 static LRESULT CALLBACK PopupDlgProcRestart(HWND hPopup, UINT uMsg, WPARAM wParam, LPARAM lParam)
diff --git a/plugins/PluginUpdater/src/Utils.cpp b/plugins/PluginUpdater/src/Utils.cpp
index b0d7be149b..f1636511d8 100644
--- a/plugins/PluginUpdater/src/Utils.cpp
+++ b/plugins/PluginUpdater/src/Utils.cpp
@@ -322,3 +322,22 @@ char* StrToLower(char *str)
 
 	return str;
 }
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+void DoRestart()
+{
+	BOOL bRestartCurrentProfile = g_plugin.getBool("RestartCurrentProfile", true);
+	if (g_plugin.bChangePlatform) {
+		VARSW wszMirandaPath(L"%miranda_path%");
+
+		MFilePath mirstartpath;
+#ifdef _WIN64
+		mirstartpath.Format(L"%s\\miranda32.exe", wszMirandaPath.get());
+#else
+		mirstartpath.Format(L"%s\\miranda64.exe", wszMirandaPath.get());
+#endif
+		CallServiceSync(MS_SYSTEM_RESTART, bRestartCurrentProfile, (LPARAM)mirstartpath.c_str());
+	}
+	else CallServiceSync(MS_SYSTEM_RESTART, bRestartCurrentProfile);
+}
diff --git a/plugins/PluginUpdater/src/stdafx.h b/plugins/PluginUpdater/src/stdafx.h
index 7c8e2dd1f9..c12ec6e08a 100644
--- a/plugins/PluginUpdater/src/stdafx.h
+++ b/plugins/PluginUpdater/src/stdafx.h
@@ -241,6 +241,8 @@ void  InitEvents();
 void  InitListNew();
 void  UnloadListNew();
 
+void  DoRestart(void);
+
 void  CALLBACK RestartPrompt(void *);
 void  CALLBACK CheckUpdateOnStartup(void);
 
diff --git a/plugins/PluginUpdater/src/version.h b/plugins/PluginUpdater/src/version.h
index 4b4e1339cd..dc65e6a1bc 100644
--- a/plugins/PluginUpdater/src/version.h
+++ b/plugins/PluginUpdater/src/version.h
@@ -1,7 +1,7 @@
 #define __MAJOR_VERSION           0
 #define __MINOR_VERSION           2
 #define __RELEASE_NUM             1
-#define __BUILD_NUM               1
+#define __BUILD_NUM               2
 
 #include <stdver.h>
 
-- 
cgit v1.2.3