Improve thumbnail building.
- Fix the threading logic and add locks where needed. The old code relied on timers working across QThreads, which they don't. It also relied on signals being delivered to all QThreads, which doesn't work if the thread in question does not have an event loop.
- Add incremental saving. This currently has little performance benefit except for very large datasets.