GeneratorObjects: Fix potential race. See merge request !46528 (cherry picked from commit a5d2958c) a5176988 GeneratorObjects: Fix potential race.