[gitg] Protect against empty lanes in lane collapsing



commit 3c6614d62c572f47af001036be0ef3edc5ab1e15
Author: Jesse van den Kieboom <jkieboom esri com>
Date:   Sun Sep 27 14:59:39 2015 +0200

    Protect against empty lanes in lane collapsing
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=748974.

 libgitg/gitg-lanes.vala |   44 +++++++++++++++++++++++---------------------
 1 files changed, 23 insertions(+), 21 deletions(-)
---
diff --git a/libgitg/gitg-lanes.vala b/libgitg/gitg-lanes.vala
index 9194958..2df2cb4 100644
--- a/libgitg/gitg-lanes.vala
+++ b/libgitg/gitg-lanes.vala
@@ -129,11 +129,9 @@ public class Lanes : Object
                reset();
        }
 
-       public void reset(Ggit.OId[]?           reserved = null,
+       public void reset(Ggit.OId[]?            reserved = null,
                          Gee.HashSet<Ggit.OId>? roots    = null)
        {
-               d_previous = new SList<weak Commit>();
-
                d_lanes = new Gee.LinkedList<LaneContainer>();
                d_roots = roots;
 
@@ -331,32 +329,36 @@ public class Lanes : Object
                {
                        var commit = item.data;
                        unowned SList<Lane> lns = commit.get_lanes();
-                       unowned Lane lane = lns.nth_data(index);
 
-                       if (item.next != null)
+                       if (lns != null)
                        {
-                               var newindex = lane.from.data;
-
-                               lns = commit.remove_lane(lane);
+                               unowned Lane lane = lns.nth_data(index);
 
-                               if (item.next.next != null)
+                               if (item.next != null)
                                {
-                                       update_merge_indices(lns, newindex, -1);
-                               }
+                                       var newindex = lane.from.data;
 
-                               var mylane = commit.mylane;
+                                       lns = commit.remove_lane(lane);
 
-                               if (mylane > index)
+                                       if (item.next.next != null)
+                                       {
+                                               update_merge_indices(lns, newindex, -1);
+                                       }
+
+                                       var mylane = commit.mylane;
+
+                                       if (mylane > index)
+                                       {
+                                               --commit.mylane;
+                                       }
+
+                                       index = newindex;
+                               }
+                               else
                                {
-                                       --commit.mylane;
+                                       lane.tag |= LaneTag.END;
+                                       lane.boundary_id = container.to;
                                }
-
-                               index = newindex;
-                       }
-                       else
-                       {
-                               lane.tag |= LaneTag.END;
-                               lane.boundary_id = container.to;
                        }
 
                        item = item.next;


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