[chronojump] Fixed crash on no duration defined on networks 3.1 tasks definition
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Fixed crash on no duration defined on networks 3.1 tasks definition
- Date: Wed, 1 Dec 2021 15:57:29 +0000 (UTC)
commit c85cf98a4e4109c71771b41cdf0fe638b8e5de88
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Dec 1 16:56:59 2021 +0100
Fixed crash on no duration defined on networks 3.1 tasks definition
src/json/compujumpOther.cs | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/src/json/compujumpOther.cs b/src/json/compujumpOther.cs
index c7ac9c249..9431eb383 100644
--- a/src/json/compujumpOther.cs
+++ b/src/json/compujumpOther.cs
@@ -85,12 +85,16 @@ public class TaskEncoder : Task
ExerciseId = jsonTask ["exercise_id"];
ExerciseName = jsonTask ["exercise_name"];
- string NrepsStr = jsonTask ["duration"]; //eg: "15 Repetitions"
- Match match = Regex.Match(NrepsStr, @"(\d+) Repetitions");
- //LogB.Information(string.Format("NrepsStr: {0}, match.Groups.Count: {1},
match.Groups[1].Value: {2}",
- // NrepsStr, match.Groups.Count, match.Groups[1].Value));
- if(match.Groups.Count == 2 && Util.IsNumber(match.Groups[1].Value, false))
- Nreps = Convert.ToInt32(match.Groups[1].Value);
+ if(jsonTask ["duration"] == null) //fix if duration is not defined
+ Nreps = -1;
+ else {
+ string NrepsStr = jsonTask ["duration"]; //eg: "15 Repetitions"
+ Match match = Regex.Match(NrepsStr, @"(\d+) Repetitions");
+ //LogB.Information(string.Format("NrepsStr: {0}, match.Groups.Count: {1},
match.Groups[1].Value: {2}",
+ // NrepsStr, match.Groups.Count, match.Groups[1].Value));
+ if(match.Groups.Count == 2 && Util.IsNumber(match.Groups[1].Value, false))
+ Nreps = Convert.ToInt32(match.Groups[1].Value);
+ }
Laterality = jsonTask ["laterality"];
Sets = jsonTask ["sets"];
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]