From 65f375eaac96febadf374899c677fd9933ff7624 Mon Sep 17 00:00:00 2001 From: Johan Kiviniemi Date: Sun, 29 Dec 2013 01:36:36 +0200 Subject: [PATCH] Add debugging code to RendertileSet counts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There seems to be something wrong with count caching. Calculate the count by iterating and log an error when that count doesn’t equal the precalculated one. --- overviewer_core/tileset.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/overviewer_core/tileset.py b/overviewer_core/tileset.py index bedbdd8..39b7c3c 100644 --- a/overviewer_core/tileset.py +++ b/overviewer_core/tileset.py @@ -1480,14 +1480,28 @@ class RendertileSet(object): """Returns the total number of render-tiles in this set. """ - return self.num_tiles + # XXX There seems to be something wrong with the num_tiles calculation. + # Calculate the number of tiles by iteration and emit a warning if it + # does not match. + from itertools import imap + num = sum(imap(lambda _: 1, self.iterate())) + if num != self.num_tiles: + logging.error("Please report this to the developers: RendertileSet num_tiles=%r, count=%r, children=%r", self.num_tiles, num, self.children) + return num def count_all(self): """Returns the total number of render-tiles plus implicitly marked upper-tiles in this set """ - return self.num_tiles_all + # XXX There seems to be something wrong with the num_tiles calculation. + # Calculate the number of tiles by iteration and emit a warning if it + # does not match. + from itertools import imap + num = sum(imap(lambda _: 1, self.posttraversal())) + if num != self.num_tiles_all: + logging.error("Please report this to the developers: RendertileSet num_tiles_all=%r, count_all=%r, children=%r", self.num_tiles, num, self.children) + return num def distance_sort(children, (off_x, off_y)): order = []