Fix potential RuntimeError in gviz

self.layers dictionnary could change from another thread, thus changing
size during repaint iteration. Using a fixed range with the current
number of layers avoids iterating directly on the dictionnary.