From 7688fdc94fa98e7c084c18fc687d1f568403a4e4 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 2 Feb 2021 01:05:48 +0000 Subject: [PATCH] Hack to prevent multiple simulation commands from stacking up. Can happen if someone hammers away on the probe and/or tune tools without ever mousing over the schematic in between. *May* fix the below bug. Fixes https://gitlab.com/kicad/code/kicad/issues/6876 --- common/tool/tool_event.cpp | 7 +++++++ include/tool/tool_event.h | 5 +++++ include/tool/tool_manager.h | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/common/tool/tool_event.cpp b/common/tool/tool_event.cpp index c9a1d4b4a4..ec640a0c4a 100644 --- a/common/tool/tool_event.cpp +++ b/common/tool/tool_event.cpp @@ -219,3 +219,10 @@ bool TOOL_EVENT::IsMoveTool() const return( m_commandStr.is_initialized() && m_commandStr.get().find( "InteractiveMove" ) != GetCommandStr()->npos ); } + + +bool TOOL_EVENT::IsSimulator() const +{ + return( m_commandStr.is_initialized() + && m_commandStr.get().find( "Simulation" ) != GetCommandStr()->npos ); +} \ No newline at end of file diff --git a/include/tool/tool_event.h b/include/tool/tool_event.h index 22f993fb9c..9337e57744 100644 --- a/include/tool/tool_event.h +++ b/include/tool/tool_event.h @@ -418,6 +418,11 @@ public: */ bool IsMoveTool() const; + /** + * Indicate if the event is from the simulator. + */ + bool IsSimulator() const; + /** * Return a non-standard parameter assigned to the event. Its meaning depends on the * target tool. diff --git a/include/tool/tool_manager.h b/include/tool/tool_manager.h index 06632b3d06..aac2248455 100644 --- a/include/tool/tool_manager.h +++ b/include/tool/tool_manager.h @@ -266,6 +266,11 @@ public: */ inline void PostEvent( const TOOL_EVENT& aEvent ) { + // Horrific hack, but it's a crash bug. Don't let inter-frame commands stack up + // waiting to be processed. + if( aEvent.IsSimulator() && m_eventQueue.back().IsSimulator() ) + m_eventQueue.pop_back(); + m_eventQueue.push_back( aEvent ); }