[chronojump] Disposing after button_press graph, if not it hangs on win/mac
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Disposing after button_press graph, if not it hangs on win/mac
- Date: Fri, 4 Sep 2020 09:59:17 +0000 (UTC)
commit b7d2a49299dd56e4f0630a52e446adc7f26ad61e
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Sep 4 11:58:48 2020 +0200
Disposing after button_press graph, if not it hangs on win/mac
src/gui/cairo/jumpsDjOptimalFall.cs | 4 ++--
src/gui/cairo/jumpsEvolution.cs | 4 ++--
src/gui/cairo/jumpsRjFatigue.cs | 4 ++--
src/gui/cairo/jumpsWeightFVProfile.cs | 4 ++--
src/gui/cairo/xy.cs | 14 ++++++++++++--
5 files changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/src/gui/cairo/jumpsDjOptimalFall.cs b/src/gui/cairo/jumpsDjOptimalFall.cs
index a9a64da8..30cd8c73 100644
--- a/src/gui/cairo/jumpsDjOptimalFall.cs
+++ b/src/gui/cairo/jumpsDjOptimalFall.cs
@@ -39,7 +39,7 @@ public class JumpsDjOptimalFallGraph : CairoXY
printText(area.Allocation.Width /2, area.Allocation.Height /2, 24, textHeight,
needToExecuteJumpsStr + " " + jumpType + ".", g, alignTypes.CENTER);
- endGraph();
+ endGraphDisposing();
}
//regular constructor
@@ -103,7 +103,7 @@ public class JumpsDjOptimalFallGraph : CairoXY
}
writeTitle();
- endGraph();
+ endGraphDisposing();
}
protected override void writeTitle()
diff --git a/src/gui/cairo/jumpsEvolution.cs b/src/gui/cairo/jumpsEvolution.cs
index d98a27af..c38735a3 100644
--- a/src/gui/cairo/jumpsEvolution.cs
+++ b/src/gui/cairo/jumpsEvolution.cs
@@ -38,7 +38,7 @@ public class JumpsEvolutionGraph : CairoXY
printText(area.Allocation.Width /2, area.Allocation.Height /2, 24, textHeight,
needToExecuteJumpsStr + " " + jumpType + ".", g, alignTypes.CENTER);
- endGraph();
+ endGraphDisposing();
}
//regular constructor
@@ -77,7 +77,7 @@ public class JumpsEvolutionGraph : CairoXY
writeTitle();
- endGraph();
+ endGraphDisposing();
}
//here X is year, add/subtract third of a year
diff --git a/src/gui/cairo/jumpsRjFatigue.cs b/src/gui/cairo/jumpsRjFatigue.cs
index 316d2424..f540b394 100644
--- a/src/gui/cairo/jumpsRjFatigue.cs
+++ b/src/gui/cairo/jumpsRjFatigue.cs
@@ -40,7 +40,7 @@ public class JumpsRjFatigueGraph : CairoXY
//printText(area.Allocation.Width /2, area.Allocation.Height /2, 24, textHeight,
// string.Format("Need to execute jumps: {0}.", jumpType), g, true);
- endGraph();
+ endGraphDisposing();
}
public JumpsRjFatigueGraph (
List<PointF> point_l, double slope, double intercept,
@@ -91,7 +91,7 @@ public class JumpsRjFatigueGraph : CairoXY
writeTitle();
- endGraph();
+ endGraphDisposing();
}
//here X is year, add/subtract third of a year
diff --git a/src/gui/cairo/jumpsWeightFVProfile.cs b/src/gui/cairo/jumpsWeightFVProfile.cs
index 903badd0..dca7f4a2 100644
--- a/src/gui/cairo/jumpsWeightFVProfile.cs
+++ b/src/gui/cairo/jumpsWeightFVProfile.cs
@@ -47,7 +47,7 @@ public class JumpsWeightFVProfileGraph : CairoXY
plotError();
- endGraph();
+ endGraphDisposing();
}
//regular constructor
@@ -162,7 +162,7 @@ public class JumpsWeightFVProfileGraph : CairoXY
if(errorMessage != ErrorAtStart.ALLOK)
plotError();
- endGraph();
+ endGraphDisposing();
}
protected override void writeTitle()
diff --git a/src/gui/cairo/xy.cs b/src/gui/cairo/xy.cs
index bc30e1b8..a99d3583 100644
--- a/src/gui/cairo/xy.cs
+++ b/src/gui/cairo/xy.cs
@@ -530,7 +530,11 @@ public abstract class CairoXY
4*pointsRadius, 4*pointsRadius);
g.Stroke();
g.Color = black;
- LogB.Information("writeCoordinatesOfMouseClick done!");
+ LogB.Information("writeCoordinatesOfMouseClick done! disposing");
+
+ endGraphDisposing();
+
+ LogB.Information("writeCoordinatesOfMouseClick disposed!");
}
/*
@@ -568,7 +572,13 @@ public abstract class CairoXY
writeTextAtRight(line +2, string.Format("- {0}: {1} {2}", yVariable,
Util.TrimDecimals(pClosest.Y, 2), yUnits), false);
}
- protected void endGraph()
+ /*
+ need to dispose because Cairo does not clean ok on win and mac:
+ Don’t forget to manually dispose the Context and the target Surface at the end of the expose
event. Automatic garbage collecting is not yet 100% working in Cairo.
+ https://www.mono-project.com/docs/tools+libraries/libraries/Mono.Cairo/
+ eg. on Linux can do the writeCoordinatesOfMouseClick() without disposing, but on win and mac
does not work, so dispose always.
+ */
+ protected void endGraphDisposing()
{
g.GetTarget().Dispose ();
g.Dispose ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]