Tool re-entrancy when placing vias and using measure tool
# Description
When working in PCB Editor it is very easy to crash it. After placing a via, unconnected track and measuring a distance, next attempt to place a via will crash PCB editor immediately, see in attached video.

I have confirmed (and recorded this video) on Windows 11 x64, others reported the same problem on Linux and macOS.
# Steps to reproduce
1. Start PCB Editor
2. Place a VIA
3. Place (short) unconnected track
4. Measure the distance between placed via and track
5. Attempt to switch to VIA tool will immediately crash KiCad.
# KiCad Version
```
Application: KiCad x64 on x64
Version: 8.0.0, release build
Libraries:
wxWidgets 3.2.4
FreeType 2.12.1
HarfBuzz 8.3.0
FontConfig 2.14.2
libcurl/8.5.0-DEV Schannel zlib/1.3
Platform: Windows 11 (Erzeugungsversion 22631), 64-bit Edition, 64 bit, Little endian, wxMSW
Build Info:
Date: Feb 23 2024 02:24:15
wxWidgets: 3.2.4 (wchar_t,wx containers)
Boost: 1.83.0
OCC: 7.7.1
Curl: 8.5.0-DEV
ngspice: 42
Compiler: Visual C++ 1936 without C++ ABI
Build settings:
```
issue