[chronojump] Fixed potential crash on foreach in RunPhaseTimeList
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Fixed potential crash on foreach in RunPhaseTimeList
- Date: Tue, 3 Apr 2018 13:14:55 +0000 (UTC)
commit 8cf8b9c7e8aff270a08907ef028503525db5fdfc
Author: Xavier de Blas <xaviblas gmail com>
Date: Tue Apr 3 15:14:09 2018 +0200
Fixed potential crash on foreach in RunPhaseTimeList
src/execute/runObjects.cs | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/src/execute/runObjects.cs b/src/execute/runObjects.cs
index a30a017..ad92888 100644
--- a/src/execute/runObjects.cs
+++ b/src/execute/runObjects.cs
@@ -323,7 +323,12 @@ public class RunPhaseTimeList
public override string ToString()
{
string str = "";
- foreach(PhaseTime pt in listPhaseTime)
+
+ //This is problematic (Collection was modified; enumeration operation may not execute) if
other thread is changing it:
+ //foreach(PhaseTime pt in listPhaseTime)
+ //solution:
+ List<PhaseTime> listPhaseTimeShallowCloned = new List<PhaseTime>(listPhaseTime);
+ foreach(PhaseTime pt in listPhaseTimeShallowCloned)
str += pt.ToString();
return str;
@@ -334,7 +339,12 @@ public class RunPhaseTimeList
List<string> list_in = new List<string>();
int currentMS = 0;
int startInMS = -1;
- foreach(PhaseTime pt in listPhaseTime)
+
+ //This is problematic (Collection was modified; enumeration operation may not execute) if
other thread is changing it:
+ //foreach(PhaseTime pt in listPhaseTime)
+ //solution:
+ List<PhaseTime> listPhaseTimeShallowCloned = new List<PhaseTime>(listPhaseTime);
+ foreach(PhaseTime pt in listPhaseTimeShallowCloned)
{
if(pt.IsContact)
startInMS = currentMS;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]