From 7524cf676116e867936903860ada957733b9f87f Mon Sep 17 00:00:00 2001 From: MaxED <j.maxed@gmail.com> Date: Sun, 26 Jun 2016 00:48:10 +0000 Subject: [PATCH] Fixed: added some additional boilerplate to FileLockChecker.CheckFile. --- Source/Core/General/FileLockChecker.cs | 22 ++++++++++++++-------- Source/Core/General/MapManager.cs | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/Source/Core/General/FileLockChecker.cs b/Source/Core/General/FileLockChecker.cs index ec3e6f0d4..840fbe593 100644 --- a/Source/Core/General/FileLockChecker.cs +++ b/Source/Core/General/FileLockChecker.cs @@ -153,8 +153,7 @@ namespace CodeImp.DoomBuilder { result.Processes = new List<Process>((int)pnProcInfo); - // Enumerate all of the results and add them to the - // list to be returned + // Enumerate all of the results and add them to the list to be returned for(int i = 0; i < pnProcInfo; i++) { try @@ -175,22 +174,29 @@ namespace CodeImp.DoomBuilder foreach(Process process in result.Processes) { - result.Error += Path.GetFileName(process.MainModule.FileName) - + " (\"" + process.MainModule.FileName - + "\", started at " + process.StartTime + ")" - + Environment.NewLine + Environment.NewLine; + string processpath = string.Empty; + try + { + // All manner of exceptions are possible here... + processpath = process.MainModule.FileName; + }catch {} + + result.Error += process.ProcessName + + " (" + (!string.IsNullOrEmpty(processpath) ? "\"" + processpath + "\"" : "") + + ", started at " + process.StartTime + ")" + + Environment.NewLine; } } } else { - result.Error = "Error " + res + ". Could not list processes locking resource."; //mxd + result.Error = "Error " + res + ". Could not list processes locking the resource."; //mxd return result; } } else if(res != 0) { - result.Error = "Error " + res + ". Could not list processes locking resource. Failed to get size of result."; //mxd + result.Error = "Error " + res + ". Could not list processes locking resource. Failed to get result size."; //mxd return result; } } diff --git a/Source/Core/General/MapManager.cs b/Source/Core/General/MapManager.cs index 0f083b3f3..a0baba22b 100644 --- a/Source/Core/General/MapManager.cs +++ b/Source/Core/General/MapManager.cs @@ -830,7 +830,7 @@ namespace CodeImp.DoomBuilder { if(checkresult.Processes.Count > 0) { - string rest = "Press 'Retry' to close " + (checkresult.Processes.Count > 1 ? "all processes" : "the process") + string rest = Environment.NewLine + "Press 'Retry' to close " + (checkresult.Processes.Count > 1 ? "all processes" : "the process") + " and retry." + Environment.NewLine + "Press 'Cancel' to cancel saving."; if(General.ShowErrorMessage(checkresult.Error + rest, MessageBoxButtons.RetryCancel) == DialogResult.Retry) -- GitLab