Fix for locking issues in redmine/6334

Not thread-safe.  If you're sure it can only ever be called from main thread, that's fine; but are you sure ?