mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Fix for the issue #311.
Children nodes that have no [apparent] parent should be adopted by the "_HEAD" i.e. the root of the whole tree.
This commit is contained in:
@@ -1642,14 +1642,22 @@ function UniReader:fillToc()
|
||||
end
|
||||
elseif (v.depth == prev_depth) then --> k and prev are siblings
|
||||
parent[k] = parent[prev]
|
||||
table.insert(self.toc_children[parent[k]], k)
|
||||
if not self.toc_children[parent[k]] then
|
||||
table.insert(self.toc_children[0],k)
|
||||
else
|
||||
table.insert(self.toc_children[parent[k]], k)
|
||||
end
|
||||
else --> k and prev must have a common (possibly virtual) ancestor
|
||||
local par = parent[prev]
|
||||
while (self.toc[par].depth > v.depth) do
|
||||
par = parent[par]
|
||||
end
|
||||
parent[k] = parent[par]
|
||||
table.insert(self.toc_children[parent[k]], k)
|
||||
if not self.toc_children[parent[k]] then
|
||||
table.insert(self.toc_children[0],k)
|
||||
else
|
||||
table.insert(self.toc_children[parent[k]], k)
|
||||
end
|
||||
end
|
||||
prev = k
|
||||
prev_depth = self.toc[prev].depth
|
||||
|
||||
Reference in New Issue
Block a user