Skip to content

Commit 3e025c7

Browse files
committed
Fix for kivy#515 - dependency graph issue
Old for removing redundant dependency graphs had a bug in it where graph[i] was compared against itself and then removed (as it appears equal to itself). This caused kivy#515. I've rearranged the loop in the function for removing redundant graphs to avoid this
1 parent 015f000 commit 3e025c7

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

pythonforandroid/toolchain.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -575,15 +575,22 @@ def __init__(self):
575575
def remove_redundant_graphs(self):
576576
'''Removes possible graphs if they are equivalent to others.'''
577577
graphs = self.graphs
578-
initial_num_graphs = len(graphs)
579578
# Walk the list backwards so that popping elements doesn't
580-
# mess up indexing
581-
for i in range(len(graphs) - 1):
582-
graph = graphs[initial_num_graphs - 1 - i]
583-
for j in range(1, len(graphs)):
584-
comparison_graph = graphs[initial_num_graphs - 1 - j]
579+
# mess up indexing.
580+
581+
# n.b. no need to test graph 0 as it will have been tested against
582+
# all others by the time we get to it
583+
for i in range(len(graphs) - 1, 0, -1):
584+
graph = graphs[i]
585+
586+
#test graph i against all graphs 0 to i-1
587+
for j in range(0, i):
588+
comparison_graph = graphs[j]
589+
585590
if set(comparison_graph.keys()) == set(graph.keys()):
586-
graphs.pop(initial_num_graphs - 1 - i)
591+
#graph[i] == graph[j]
592+
#so remove graph[i] and continue on to testing graph[i-1]
593+
graphs.pop(i)
587594
break
588595

589596
def add(self, dependent, dependency):

0 commit comments

Comments
 (0)