Fix infinite frame selection loop (Bug#15025).