Fix for a race condition when starting painting