[longomatch] Improve memory management a but for the stats GUI
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Improve memory management a but for the stats GUI
- Date: Sat, 4 Jan 2014 12:58:50 +0000 (UTC)
commit d4eed4dddc5fd6417f72b09bee8b8bb6786933fc
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Sat Jan 4 13:57:01 2014 +0100
Improve memory management a but for the stats GUI
Release pixbufs as soon as they are no longuer needed
LongoMatch.Core/Stats/ProjectStats.cs | 1 +
LongoMatch.GUI/Gui/Component/CoordinatesTagger.cs | 12 +++++++-----
.../Gui/Component/PlaysCoordinatesTagger.cs | 11 +++++++++++
LongoMatch.GUI/Gui/Component/Stats/GameViewer.cs | 10 ++++------
.../Gui/Component/Stats/PlayersViewer.cs | 4 ++--
LongoMatch.GUI/Gui/Component/Stats/Plotter.cs | 11 +++++++++++
LongoMatch.GUI/Gui/Dialog/StatsViewer.cs | 4 ++--
7 files changed, 38 insertions(+), 15 deletions(-)
---
diff --git a/LongoMatch.Core/Stats/ProjectStats.cs b/LongoMatch.Core/Stats/ProjectStats.cs
index 7f402fa..a334c43 100644
--- a/LongoMatch.Core/Stats/ProjectStats.cs
+++ b/LongoMatch.Core/Stats/ProjectStats.cs
@@ -56,6 +56,7 @@ namespace LongoMatch.Stats
Field.Dispose ();
if (Goal != null)
Goal.Dispose ();
+ catStats.Clear ();
}
public string ProjectName {
diff --git a/LongoMatch.GUI/Gui/Component/CoordinatesTagger.cs
b/LongoMatch.GUI/Gui/Component/CoordinatesTagger.cs
index 733d4e5..2f8ea75 100644
--- a/LongoMatch.GUI/Gui/Component/CoordinatesTagger.cs
+++ b/LongoMatch.GUI/Gui/Component/CoordinatesTagger.cs
@@ -55,11 +55,6 @@ namespace LongoMatch.Gui.Component
Sensitive = true;
}
- ~CoordinatesTagger() {
- if (source != null)
- source.Destroy();
- }
-
public new bool Sensitive {
get;
set;
@@ -193,6 +188,13 @@ namespace LongoMatch.Gui.Component
}
}
+ protected override void OnDestroyed ()
+ {
+ base.OnDestroyed ();
+ if (source != null)
+ source.Destroy();
+ }
+
protected virtual void OnDrawingareaButtonPressEvent(object o, Gtk.ButtonPressEventArgs args)
{
if (!Sensitive)
diff --git a/LongoMatch.GUI/Gui/Component/PlaysCoordinatesTagger.cs
b/LongoMatch.GUI/Gui/Component/PlaysCoordinatesTagger.cs
index 17c7287..722ad8a 100644
--- a/LongoMatch.GUI/Gui/Component/PlaysCoordinatesTagger.cs
+++ b/LongoMatch.GUI/Gui/Component/PlaysCoordinatesTagger.cs
@@ -186,6 +186,17 @@ namespace LongoMatch.Gui.Component
goal.Coordinates = coords;
goal.Visible = true;
}
+
+ protected override void OnDestroyed ()
+ {
+ base.OnDestroyed ();
+ if (fieldPixbuf != null)
+ fieldPixbuf.Dispose();
+ if (hFieldPixbuf != null)
+ hFieldPixbuf.Dispose();
+ if (goalPixbuf != null)
+ goalPixbuf.Dispose();
+ }
}
}
diff --git a/LongoMatch.GUI/Gui/Component/Stats/GameViewer.cs
b/LongoMatch.GUI/Gui/Component/Stats/GameViewer.cs
index c630d69..30bae1d 100644
--- a/LongoMatch.GUI/Gui/Component/Stats/GameViewer.cs
+++ b/LongoMatch.GUI/Gui/Component/Stats/GameViewer.cs
@@ -42,12 +42,10 @@ namespace LongoMatch.Gui.Component
this.Build ();
}
- public Project Project {
- set {
- stats = new ProjectStats (value);
- project = value;
- UpdateGui();
- }
+ public void LoadProject (Project project, ProjectStats stats) {
+ this.stats = stats;
+ this.project = project;
+ UpdateGui();
}
void UpdateSubcatsVisibility () {
diff --git a/LongoMatch.GUI/Gui/Component/Stats/PlayersViewer.cs
b/LongoMatch.GUI/Gui/Component/Stats/PlayersViewer.cs
index 6947c36..f645c05 100644
--- a/LongoMatch.GUI/Gui/Component/Stats/PlayersViewer.cs
+++ b/LongoMatch.GUI/Gui/Component/Stats/PlayersViewer.cs
@@ -46,11 +46,11 @@ namespace LongoMatch.Gui.Component.Stats
treeview1.EnableTreeLines = false;
}
- public void LoadProject (Project project) {
+ public void LoadProject (Project project, ProjectStats stats) {
TreeIter first;
store.Clear();
- pstats = new ProjectStats (project);
+ pstats = stats;
filter = new PlaysFilter (project);
filter.PlayersFilterEnabled = true;
pstats.Filter = filter;
diff --git a/LongoMatch.GUI/Gui/Component/Stats/Plotter.cs b/LongoMatch.GUI/Gui/Component/Stats/Plotter.cs
index 596c1d5..4345d90 100644
--- a/LongoMatch.GUI/Gui/Component/Stats/Plotter.cs
+++ b/LongoMatch.GUI/Gui/Component/Stats/Plotter.cs
@@ -207,6 +207,17 @@ namespace LongoMatch.Gui.Component.Stats
}
}
+ protected override void OnDestroyed ()
+ {
+ base.OnDestroyed ();
+ if (imageall != null)
+ imageall.Destroy();
+ if (imageaway != null)
+ imageaway.Destroy();
+ if (imagehome != null)
+ imagehome.Destroy();
+ }
+
protected enum GraphType {
Histogram,
Pie,
diff --git a/LongoMatch.GUI/Gui/Dialog/StatsViewer.cs b/LongoMatch.GUI/Gui/Dialog/StatsViewer.cs
index 18db526..97a596c 100644
--- a/LongoMatch.GUI/Gui/Dialog/StatsViewer.cs
+++ b/LongoMatch.GUI/Gui/Dialog/StatsViewer.cs
@@ -42,8 +42,8 @@ namespace LongoMatch.Gui.Dialog
stats.Dispose();
stats = new ProjectStats (project);
categoriesviewer.LoadStats (stats);
- playersviewer.LoadProject (project);
- gameviewer.Project = project;
+ playersviewer.LoadProject (project, stats);
+ gameviewer.LoadProject (project, stats);
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]