From b6674e3bcbac5a0ddb09e9e41178719dbeb0b2f7 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 23 Apr 2019 10:56:57 +0100 Subject: [PATCH] Prevent segfault when running selection disambiguation menu. --- eeschema/sch_base_frame.cpp | 5 +++++ eeschema/tools/sch_selection_tool.cpp | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/eeschema/sch_base_frame.cpp b/eeschema/sch_base_frame.cpp index a27a316fc2..958bacc142 100644 --- a/eeschema/sch_base_frame.cpp +++ b/eeschema/sch_base_frame.cpp @@ -119,6 +119,11 @@ void SCH_BASE_FRAME::setupTools() // Register tools m_actions->RegisterAllTools( m_toolManager ); m_toolManager->InitTools(); + + // Run the selection tool, it is supposed to be always active + // JEY TODO: enable when we move event loop over to modern toolset... + //m_toolManager->InvokeTool( "eeschema.InteractiveSelection" ); + GetCanvas()->SetEventDispatcher( m_toolDispatcher ); } diff --git a/eeschema/tools/sch_selection_tool.cpp b/eeschema/tools/sch_selection_tool.cpp index d8c3464a34..2215f75e57 100644 --- a/eeschema/tools/sch_selection_tool.cpp +++ b/eeschema/tools/sch_selection_tool.cpp @@ -433,6 +433,28 @@ bool SCH_SELECTION_TOOL::doSelectionMenu( SCH_COLLECTOR* aCollector, const wxStr menu.SetIcon( info_xpm ); menu.DisplayTitle( true ); + +#if 1 + // JEY TODO: use wxWidgets event loop for showing menu until we move over to modern toolset event loop + m_frame->GetCanvas()->SetAbortRequest( true ); // Changed to false if an item is selected + m_frame->PopupMenu( &menu ); + + if( m_frame->GetCanvas()->GetAbortRequest() ) + { + m_frame->GetScreen()->SetCurItem( nullptr ); + return false; + } + + m_frame->GetCanvas()->MoveCursorToCrossHair(); + current = m_frame->GetScreen()->GetCurItem(); + + toggleSelection( current ); + + aCollector->Empty(); + aCollector->Append( current ); + return true; + +#endif SetContextMenu( &menu, CMENU_NOW ); while( OPT_TOOL_EVENT evt = Wait() )