ViewerGL: fix potential infinite loop