Fixes https://gitlab.com/kicad/code/kicad/issues/13016 (cherry picked from commit 8260f0ee13)
8260f0ee13