From e51316a932ef2440ac082e54af80d9a234d8b8ed Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 11 May 2024 12:53:04 +0200 Subject: [PATCH] Fix a 100% CPU core usage is some editing cases. In commit 7cb754dd a call to wxMilliSleep(50) was removed (because it created lag in editing) but this removal created a 100% CPU core usage. Using a much small sleep time (1ms) fixes these issues. Fixes https://gitlab.com/kicad/code/kicad/-/issues/17979 --- common/tool/tool_manager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index f4c9e83324..510c934ae4 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -363,7 +363,11 @@ bool TOOL_MANAGER::doRunAction( const TOOL_ACTION& aAction, bool aNow, const std while( synchronousControl == STS_RUNNING ) { - wxYield(); + wxYield(); // Needed to honor mouse (and other) events during editing + wxMilliSleep( 1 ); // Needed to avoid 100% use of one cpu core. + // The sleeping time must be must be small to avoid + // noticeable lag in mouse and editing events + // (1 to 5 ms is a good value) } retVal = synchronousControl != STS_CANCELLED;