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