im.pidgin.pidgin: 7c8120b9ffde901cc436a514ac0daf37551a9755

datallah at pidgin.im datallah at pidgin.im
Mon Dec 17 21:35:44 EST 2007


-----------------------------------------------------------------
Revision: 7c8120b9ffde901cc436a514ac0daf37551a9755
Ancestor: b00f51f9bb505d4518268d3340d2a8fd0a200f9b
Author: datallah at pidgin.im
Date: 2007-12-18T02:26:44
Branch: im.pidgin.pidgin

Modified files:
        pidgin/win32/nsis/pidgin-installer.nsi
        pidgin/win32/winpidgin.c

ChangeLog: 

Allow the user to Retry if Pidgin is running when they start the installer. Fixes #4355

-------------- next part --------------
============================================================
--- pidgin/win32/nsis/pidgin-installer.nsi	76778028e4c6848e2e486db00fed161d4840ca15
+++ pidgin/win32/nsis/pidgin-installer.nsi	b953fafe5d8533a2f201e4a96aebb77dc624b20b
@@ -1154,11 +1154,21 @@ Function ${UN}RunCheck
 !macro RunCheckMacro UN
 Function ${UN}RunCheck
   Push $R0
-  System::Call 'kernel32::OpenMutex(i 2031617, b 0, t "pidgin_is_running") i .R0'
-  IntCmp $R0 0 done
-    MessageBox MB_OK|MB_ICONEXCLAMATION $(PIDGIN_IS_RUNNING) /SD IDOK
+  Push $R1
+
+  IntOp $R1 0 + 0
+  retry_runcheck:
+  ; Close the Handle (needed if we're retrying)
+  IntCmp $R1 0 +2
+    System::Call 'kernel32::CloseHandle(i $R1) i .R1'
+  System::Call 'kernel32::CreateMutexA(i 0, i 0, t "pidgin_is_running") i .R1 ?e'
+  Pop $R0
+  IntCmp $R0 0 +3 ;This could check for ERROR_ALREADY_EXISTS(183), but lets just assume
+    MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION $(PIDGIN_IS_RUNNING) /SD IDCANCEL IDRETRY retry_runcheck
     Abort
+
   done:
+  Pop $R1
   Pop $R0
 FunctionEnd
 !macroend
@@ -1169,10 +1179,16 @@ Function .onInit
   Push $R0
   Push $R1
   Push $R2
-  System::Call 'kernel32::CreateMutexA(i 0, i 0, t "pidgin_installer_running") i .r1 ?e'
+
+  IntOp $R1 0 + 0
+  retry_runcheck:
+  ; Close the Handle (needed if we're retrying)
+  IntCmp $R1 0 +2
+    System::Call 'kernel32::CloseHandle(i $R1) i .R1'
+  System::Call 'kernel32::CreateMutexA(i 0, i 0, t "pidgin_installer_running") i .R1 ?e'
   Pop $R0
-  StrCmp $R0 0 +3
-    MessageBox MB_OK|MB_ICONEXCLAMATION $(INSTALLER_IS_RUNNING) /SD IDOK
+  IntCmp $R0 0 +3 ;This could check for ERROR_ALREADY_EXISTS(183), but lets just assume
+    MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION $(INSTALLER_IS_RUNNING) /SD IDCANCEL IDRETRY retry_runcheck
     Abort
   Call RunCheck
   StrCpy $name "Pidgin ${PIDGIN_VERSION}"
============================================================
--- pidgin/win32/winpidgin.c	3d08c25d6780d60c2761f26ed3330237bbeb5140
+++ pidgin/win32/winpidgin.c	3e26e903dbc4521c7f735b0229330eb2a561bce7
@@ -445,11 +445,12 @@ static void winpidgin_set_locale() {
 #define PIDGIN_WM_FOCUS_REQUEST (WM_APP + 13)
 #define PIDGIN_WM_PROTOCOL_HANDLE (WM_APP + 14)
 
-static BOOL winpidgin_set_running() {
+static BOOL winpidgin_set_running(BOOL fail_if_running) {
 	HANDLE h;
 
 	if ((h = CreateMutex(NULL, FALSE, "pidgin_is_running"))) {
-		if (GetLastError() == ERROR_ALREADY_EXISTS) {
+		DWORD err = GetLastError();
+		if (err == ERROR_ALREADY_EXISTS && fail_if_running) {
 			HWND msg_win;
 
 			printf("An instance of Pidgin is already running.\n");
@@ -465,7 +466,8 @@ static BOOL winpidgin_set_running() {
 				NULL, MB_OK | MB_TOPMOST);
 
 			return FALSE;
-		}
+		} else
+			printf("Error (%d) accessing \"pidgin_is_running\" mutex.\n", err);
 	}
 	return TRUE;
 }
@@ -628,8 +630,8 @@ WinMain (struct HINSTANCE__ *hInstance, 
 
 	winpidgin_set_locale();
 	/* If help, version or multiple flag used, do not check Mutex */
-	if (!strstr(lpszCmdLine, "-h") && !strstr(lpszCmdLine, "-v") && !strstr(lpszCmdLine, "-m"))
-		if (!getenv("PIDGIN_MULTI_INST") && !winpidgin_set_running())
+	if (!strstr(lpszCmdLine, "-h") && !strstr(lpszCmdLine, "-v"))
+		if (!winpidgin_set_running(getenv("PIDGIN_MULTI_INST") == NULL && strstr(lpszCmdLine, "-m") == NULL))
 			return 0;
 
 	/* Now we are ready for Pidgin .. */


More information about the Commits mailing list