Fixes https://gitlab.com/kicad/code/kicad/-/issues/20958 (cherry picked from commit 116bd924c2)
116bd924c2