Fixes https://gitlab.com/kicad/code/kicad/issues/4769 (cherry picked from commit e26625fc99)
e26625fc99