Merge lp:~davidmhewitt/pantheon-photos/temp-fix-crash into lp:~pantheon-photos/pantheon-photos/trunk

Proposed by David Hewitt
Status: Merged
Approved by: Danielle Foré
Approved revision: 3184
Merged at revision: 3182
Proposed branch: lp:~davidmhewitt/pantheon-photos/temp-fix-crash
Merge into: lp:~pantheon-photos/pantheon-photos/trunk
Diff against target: 142 lines (+21/-35)
2 files modified
src/events/Branch.vala (+2/-2)
src/sidebar/Branch.vala (+19/-33)
To merge this branch: bzr merge lp:~davidmhewitt/pantheon-photos/temp-fix-crash
Reviewer Review Type Date Requested Status
Danielle Foré Approve
Review via email: mp+321231@code.launchpad.net

Commit message

Switch to new comparators

Description of the change

Switch to new comparators to fix crash.

To post a comment you must log in.
3184. By David Hewitt

Removed unnecessary parts of code

Revision history for this message
Danielle Foré (danrabbit) wrote :

Can confirm that this fixes the crash

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/events/Branch.vala'
2--- src/events/Branch.vala 2017-01-12 18:13:48 +0000
3+++ src/events/Branch.vala 2017-03-28 22:34:40 +0000
4@@ -347,11 +347,11 @@
5 }
6
7 private void graft_event (Sidebar.Entry parent, Event event,
8- owned CompareDataFunc<Sidebar.Entry>? comparator = null) {
9+ owned CompareFunc<Sidebar.Entry>? comparator = null) {
10 Events.EventEntry entry = new Events.EventEntry (event);
11 entry_map.set (event, entry);
12
13- graft (parent, entry, (owned) comparator);
14+ graft (parent, entry, comparator);
15 }
16
17 private void reparent_event (Event event, Sidebar.Entry new_parent) {
18
19=== modified file 'src/sidebar/Branch.vala'
20--- src/sidebar/Branch.vala 2017-01-12 18:13:48 +0000
21+++ src/sidebar/Branch.vala 2017-03-28 22:34:40 +0000
22@@ -52,17 +52,17 @@
23
24 public Sidebar.Entry entry;
25 public weak Node? parent;
26- public CompareDataFunc<Sidebar.Entry> comparator;
27+ public CompareFunc<Sidebar.Entry> comparator;
28 public Gee.SortedSet<Node>? children = null;
29
30 public Node (Sidebar.Entry entry, Node? parent,
31- owned CompareDataFunc<Sidebar.Entry> comparator) {
32+ CompareFunc<Sidebar.Entry> comparator) {
33 this.entry = entry;
34 this.parent = parent;
35- this.comparator = (owned) comparator;
36+ this.comparator = comparator;
37 }
38
39- private static int comparator_wrapper (Node? a, Node? b) {
40+ private static int comparator_wrapper (Node a, Node b) {
41 if (a == b)
42 return 0;
43
44@@ -185,16 +185,16 @@
45 cb (this);
46 }
47
48- public void change_comparator (owned CompareDataFunc<Sidebar.Entry> comparator, bool recursive,
49+ public void change_comparator (CompareFunc<Sidebar.Entry> comparator, bool recursive,
50 ChildrenReorderedCallback cb) {
51- this.comparator = (owned) comparator;
52+ this.comparator = comparator;
53
54 // reorder children, but need to do manual recursion to set comparator
55 reorder_children (false, cb);
56
57 if (recursive) {
58 foreach (Node child in children)
59- child.change_comparator ((owned) comparator, true, cb);
60+ child.change_comparator (comparator, true, cb);
61 }
62 }
63 }
64@@ -202,7 +202,7 @@
65 private Node root;
66 private Options options;
67 private bool shown = true;
68- private CompareDataFunc<Sidebar.Entry> default_comparator;
69+ private CompareFunc<Sidebar.Entry> default_comparator;
70 private Gee.HashMap<Sidebar.Entry, Node> map = new Gee.HashMap<Sidebar.Entry, Node> ();
71
72 public signal void entry_added (Sidebar.Entry entry);
73@@ -218,18 +218,11 @@
74 public signal void show_branch (bool show);
75
76 public Branch (Sidebar.Entry root, Options options,
77- owned CompareDataFunc<Sidebar.Entry> default_comparator,
78- owned CompareDataFunc<Sidebar.Entry>? root_comparator = null) {
79- this.default_comparator = (owned) default_comparator;
80-
81- CompareDataFunc<Sidebar.Entry>? broken_ternary_workaround;
82-
83- if (root_comparator != null)
84- broken_ternary_workaround = (owned) root_comparator;
85- else
86- broken_ternary_workaround = (owned) default_comparator;
87-
88- this.root = new Node (root, null, (owned) broken_ternary_workaround);
89+ CompareFunc<Sidebar.Entry> default_comparator,
90+ CompareFunc<Sidebar.Entry>? root_comparator = null) {
91+
92+ this.default_comparator = default_comparator;
93+ this.root = new Node(root, null, (root_comparator != null) ? root_comparator : default_comparator);
94 this.options = options;
95
96 map.set (root, this.root);
97@@ -267,7 +260,7 @@
98 }
99
100 public void graft (Sidebar.Entry parent, Sidebar.Entry entry,
101- owned CompareDataFunc<Sidebar.Entry>? comparator = null) {
102+ CompareFunc<Sidebar.Entry>? comparator = null) {
103 assert (map.has_key (parent));
104 assert (!map.has_key (entry));
105
106@@ -276,14 +269,7 @@
107
108 Node parent_node = map.get (parent);
109
110- CompareDataFunc<Sidebar.Entry>? broken_ternary_workaround;
111-
112- if (comparator != null)
113- broken_ternary_workaround = (owned) comparator;
114- else
115- broken_ternary_workaround = (owned) default_comparator;
116-
117- Node entry_node = new Node (entry, parent_node, (owned) broken_ternary_workaround);
118+ Node entry_node = new Node(entry, parent_node, (comparator != null) ? comparator : default_comparator);
119
120 parent_node.add_child (entry_node);
121 map.set (entry, entry_node);
122@@ -360,16 +346,16 @@
123 entry_node.reorder_children (recursive, children_reordered_callback);
124 }
125
126- public void change_all_comparators (owned CompareDataFunc<Sidebar.Entry>? comparator) {
127- root.change_comparator ((owned) comparator, true, children_reordered_callback);
128+ public void change_all_comparators (CompareFunc<Sidebar.Entry>? comparator) {
129+ root.change_comparator (comparator, true, children_reordered_callback);
130 }
131
132 public void change_comparator (Sidebar.Entry entry, bool recursive,
133- owned CompareDataFunc<Sidebar.Entry>? comparator) {
134+ CompareFunc<Sidebar.Entry>? comparator) {
135 Node? entry_node = map.get (entry);
136 assert (entry_node != null);
137
138- entry_node.change_comparator ((owned) comparator, recursive, children_reordered_callback);
139+ entry_node.change_comparator (comparator, recursive, children_reordered_callback);
140 }
141
142 public int get_child_count (Sidebar.Entry parent) {

Subscribers

People subscribed via source and target branches

to all changes: