[longomatch] Handle the case of a NULL Dashboard



commit 7ebff65f3359bca511032692ad9f91960e4e7d31
Author: Jorge Zapata <jorgeluis zapata gmail com>
Date:   Mon Apr 13 15:55:30 2015 +0200

    Handle the case of a NULL Dashboard

 LongoMatch.Core/Store/Project.cs            |   21 +++++++++++++--------
 LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs |   11 +++++++----
 2 files changed, 20 insertions(+), 12 deletions(-)
---
diff --git a/LongoMatch.Core/Store/Project.cs b/LongoMatch.Core/Store/Project.cs
index 9b44eff..89113d0 100644
--- a/LongoMatch.Core/Store/Project.cs
+++ b/LongoMatch.Core/Store/Project.cs
@@ -300,15 +300,20 @@ namespace LongoMatch.Core.Store
 
                public void UpdateEventTypesAndTimers ()
                {
-                       IEnumerable<EventType> dashboardtypes, timelinetypes;
-                       /* Timers */
-                       IEnumerable<Timer> timers = Dashboard.List.OfType<TimerButton> ().Select (b => 
b.Timer);
-                       Timers.AddRange (timers.Except (Timers));
+                       IEnumerable<EventType> dashboardtypes = new List<EventType> ();
+                       IEnumerable<EventType> timelinetypes;
+
+                       if (Dashboard != null) {
+                               /* Timers */
+                               IEnumerable<Timer> timers = Dashboard.List.OfType<TimerButton> ().Select (b 
=> b.Timer);
+                               Timers.AddRange (timers.Except (Timers));
                        
-                       /* Update event types list that changes when the user adds or remove a
-                        * a new button to the dashboard or after importing a project with events
-                        * tagged with a different dashboard */
-                       dashboardtypes = Dashboard.List.OfType<EventButton> ().Select (b => b.EventType);
+                               /* Update event types list that changes when the user adds or remove a
+                                * a new button to the dashboard or after importing a project with events
+                                * tagged with a different dashboard */
+                               dashboardtypes = Dashboard.List.OfType<EventButton> ().Select (b => 
b.EventType);
+                       }
+
                        /* Remove event types that have no events and are not in the dashboard anymore */
                        foreach (EventType evt in EventTypes.Except (dashboardtypes).ToList ()) {
                                if (evt == SubstitutionsEventType) {
diff --git a/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs b/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
index b3517b3..21c1e17 100644
--- a/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
+++ b/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
@@ -238,10 +238,13 @@ namespace LongoMatch.Gui.Panel
                        }
 
                        // FIXME In case the project provides a dashboard, use it, otherwise, enable the 
combobox
-                       // we can not set the dashboard to null otherwise a lot of segv happen
-                       tagscombobox.Visible = false;
-                       analysislabel.Visible = false;
-                       analysisTemplate = project.Dashboard;
+                       if (project.Dashboard != null) {
+                               tagscombobox.Visible = false;
+                               analysislabel.Visible = false;
+                               analysisTemplate = project.Dashboard;
+                       } else {
+                               project.Dashboard = analysisTemplate;
+                       }
                        mediafilesetselection1.Visible = true;
                        mediafilesetselection1.FileSet = project.Description.FileSet;
                }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]