Make QSResourceManager thread safe

Fixes #1861