@@ -239,42 +239,50 @@ static bool TerminateFileLockingProcesses(const SString& absolutePath, const SSt
239
239
WString filePath (absolutePath);
240
240
std::vector<DWORD> processIds = GetProcessListUsingFile (filePath);
241
241
242
- if (processIds.empty ())
243
- return true ;
242
+ while (true )
243
+ {
244
+ if (processIds.empty ())
245
+ return true ;
244
246
245
- SString nameList;
247
+ SString nameList;
246
248
247
- for (DWORD processId : processIds)
248
- {
249
- if (!nameList.empty ())
250
- nameList += ' \n ' ;
249
+ for (DWORD processId : processIds)
250
+ {
251
+ if (!nameList.empty ())
252
+ nameList += ' \n ' ;
251
253
252
- SString processName = GetProcessFilename (processId);
254
+ SString processName = GetProcessFilename (processId);
253
255
254
- if (processName.empty ())
255
- processName = _ (" Unknown" );
256
+ if (processName.empty ())
257
+ processName = _ (" Unknown" );
256
258
257
- nameList += SString (" %s [%lu]" , processName.c_str (), processId);
258
- }
259
+ nameList += SString (" %s [%lu]" , processName.c_str (), processId);
260
+ }
259
261
260
- int decision = MessageBoxUTF8 (
261
- nullptr ,
262
- SString (_ (" The file '%s' is currently locked by %zu processes.\n\n Do you want to terminate the following processes and continue updating?\n\n %s" ),
263
- displayName.c_str (), processIds.size (), nameList.c_str ()),
264
- " MTA: San Andreas" , MB_YESNO | MB_ICONQUESTION | MB_TOPMOST);
262
+ int decision = MessageBoxUTF8 (
263
+ nullptr ,
264
+ SString (_ (" The file '%s' is currently locked by %zu processes.\n\n Do you want to terminate the following processes and continue updating?\n\n %s" ),
265
+ displayName.c_str (), processIds.size (), nameList.c_str ()),
266
+ " MTA: San Andreas" , MB_CANCELTRYCONTINUE | MB_ICONQUESTION | MB_TOPMOST);
265
267
266
- if (decision != IDYES)
267
- return false ;
268
+ processIds = GetProcessListUsingFile (filePath);
268
269
269
- for (DWORD processId : processIds)
270
- {
271
- if (!TerminateProcess (processId, 0 ))
270
+ if (processIds.empty ())
271
+ return true ;
272
+
273
+ if (decision == IDTRYAGAIN)
274
+ continue ;
275
+
276
+ if (decision != IDCONTINUE)
277
+ return false ;
278
+
279
+ for (DWORD processId : processIds)
272
280
{
273
- AddReportLog ( 5055 , SString ( " TerminateFileLockingProcesses: Failed to terminate process '%s' (%lu) " , GetProcessPathFilename ( processId), processId) );
281
+ TerminateProcess ( processId, 0 );
274
282
}
275
- }
276
283
277
- return GetProcessListUsingFile (filePath).empty ();
284
+ processIds = GetProcessListUsingFile (filePath);
285
+ }
278
286
}
279
287
280
288
/* *
0 commit comments