pcbnew: window freeze after operating PCB

Description

Open a pcb file, do anything casually, after few seconds the UI freezes. It's as if the window has lost its focus. If you opened other parts like Eeschema, they will get freezed too. The same will happen if you just want to edit a footprint and open the fp-editor without opening pcbnew. But it will be fine if you only open a Eeschema.

This bug did not appear in version 5.1.

Steps to reproduce

It's 100% reproducible in my computer.

KiCad Version

Application: KiCad (64-bit)

Version: (6.99.0-554-gd5a2059c21), release build

Libraries:
	wxWidgets 3.1.5
	FreeType 2.11.0

Platform: Windows 10 (build 19044), 64-bit edition, 64 bit, Little endian, wxMSW

	wxWidgets: 3.1.5 (wchar_t,wx containers)
	Boost: 1.76.0
	OCC: 7.5.0
	Curl: 7.78.0-DEV
	ngspice: 35
	Compiler: Visual C++ 1929 without C++ ABI

Build settings:
	KICAD_USE_OCC=ON
	KICAD_SPICE=ON