[chronojump] Fixed crash on jumpEvolution graph on takeOff and takeOffWeight (no flight time)
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Fixed crash on jumpEvolution graph on takeOff and takeOffWeight (no flight time)
- Date: Mon, 9 Aug 2021 10:48:40 +0000 (UTC)
commit 85e726ca2ba1a19246fce3831d305c09b52a983e
Author: Xavier de Blas <xaviblas gmail com>
Date: Mon Aug 9 12:44:35 2021 +0200
Fixed crash on jumpEvolution graph on takeOff and takeOffWeight (no flight time)
src/constants.cs | 4 ++++
src/gui/app1/jumpsRunsEvolution.cs | 18 +++++++++++++++++-
src/gui/cairo/jumpsRunsEvolution.cs | 13 +++++++++++--
3 files changed, 32 insertions(+), 3 deletions(-)
---
diff --git a/src/constants.cs b/src/constants.cs
index d519ed40e..9bda72442 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -900,6 +900,10 @@ public class Constants
{
return Catalog.GetString("Error. File cannot be saved.");
}
+ public static string GraphCannot(string test)
+ {
+ return string.Format(Catalog.GetString("Sorry, this graph cannot be done with test {0}."),
test);
+ }
public static string ChronopicDefaultPortWindows = "COM?";
public static string ChronopicDefaultPortLinux = "/dev/ttyUSB?";
diff --git a/src/gui/app1/jumpsRunsEvolution.cs b/src/gui/app1/jumpsRunsEvolution.cs
index 49be013f9..6afe7271d 100644
--- a/src/gui/app1/jumpsRunsEvolution.cs
+++ b/src/gui/app1/jumpsRunsEvolution.cs
@@ -76,6 +76,7 @@ public partial class ChronoJumpWindow
private void jumpsEvolutionDo (bool calculateData)
{
+ // 1) exit, if problems
if(currentPerson == null || currentSession == null ||
drawingarea_jumps_evolution == null || drawingarea_jumps_evolution.GdkWindow
== null) //it happens at start on click on analyze
{
@@ -83,20 +84,35 @@ public partial class ChronoJumpWindow
return;
}
+ // 2) create jumpsEvolution, if needed
if(jumpsEvolution == null) {
jumpsEvolution = new JumpsEvolution();
calculateData = true;
}
+ // 3) get jump type
string jumpType = comboSelectJumpsEvolution.GetSelectedNameEnglish();
+ // 4) exit if test incompatible (takeOff and takeOffWeight have no flight time, so this graph
crashes)
+ if(jumpType == Constants.TakeOffName || jumpType == Constants.TakeOffWeightName)
+ {
+ new JumpsEvolutionGraph(drawingarea_jumps_evolution,
+ JumpsEvolutionGraph.Error.TESTINCOMPATIBLE, jumpType,
preferences.fontType.ToString());
+
+ button_jumps_evolution_save_image.Sensitive = false;
+ return;
+ }
+
+ // 5) calculateData
if(calculateData)
jumpsEvolution.Calculate(currentPerson.UniqueID, jumpType,
check_jumps_evolution_only_best_in_session.Active);
+ // 6) exit if no points, or do the graph
if(jumpsEvolution.Point_l.Count == 0)
{
//constructor for showing blank screen with a message
- new JumpsEvolutionGraph(drawingarea_jumps_evolution, jumpType,
preferences.fontType.ToString());
+ new JumpsEvolutionGraph(drawingarea_jumps_evolution,
+ JumpsEvolutionGraph.Error.NEEDJUMP, jumpType,
preferences.fontType.ToString());
//currentPerson.Name, jumpType, currentSession.DateShort);
button_jumps_evolution_save_image.Sensitive = false;
diff --git a/src/gui/cairo/jumpsRunsEvolution.cs b/src/gui/cairo/jumpsRunsEvolution.cs
index 947c67af9..c6ba9e07c 100644
--- a/src/gui/cairo/jumpsRunsEvolution.cs
+++ b/src/gui/cairo/jumpsRunsEvolution.cs
@@ -114,16 +114,25 @@ public abstract class EvolutionGraph : CairoXY
public class JumpsEvolutionGraph : EvolutionGraph
{
+ public enum Error { NEEDJUMP, TESTINCOMPATIBLE }
+
//constructor when there are no points
- public JumpsEvolutionGraph (DrawingArea area, string jumpType, string font)//, string title, string
jumpType, string date)
+ public JumpsEvolutionGraph (DrawingArea area, Error error, string jumpType, string font)//, string
title, string jumpType, string date)
{
this.area = area;
initGraph(font, .8);
g.SetFontSize(16);
+
+ string errorMessage = "";
+ if(error == Error.NEEDJUMP)
+ errorMessage = needToExecuteJumpsStr + " " + jumpType + ".";
+ else //(error == Error.TESTINCOMPATIBLE)
+ errorMessage = Constants.GraphCannot(jumpType);
+
printText(area.Allocation.Width /2, area.Allocation.Height /2, 24, textHeight,
- needToExecuteJumpsStr + " " + jumpType + ".", g, alignTypes.CENTER);
+ errorMessage, g, alignTypes.CENTER);
endGraphDisposing(g);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]