Cleanup problems with fighting event loops.
This commit is contained in:
parent
8049c07a34
commit
f9dd1324da
|
@ -131,7 +131,8 @@ public:
|
|||
/**
|
||||
* Constructor SCH_COLLECTOR
|
||||
*/
|
||||
SCH_COLLECTOR( const KICAD_T* aScanTypes = SCH_COLLECTOR::AllItems )
|
||||
SCH_COLLECTOR( const KICAD_T* aScanTypes = SCH_COLLECTOR::AllItems ) :
|
||||
m_MenuCancelled( false )
|
||||
{
|
||||
SetScanTypes( aScanTypes );
|
||||
}
|
||||
|
@ -193,6 +194,10 @@ public:
|
|||
* @return True if the collection is a draggable junction.
|
||||
*/
|
||||
bool IsDraggableJunction() const;
|
||||
|
||||
public:
|
||||
wxString m_MenuTitle; // The title of selection disambiguation menu (if needed)
|
||||
bool m_MenuCancelled; // Indicates selection disambiguation menu was cancelled
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -259,7 +259,11 @@ SCH_ITEM* SCH_SELECTION_TOOL::SelectPoint( const VECTOR2I& aWhere, const KICAD_T
|
|||
// If still more than one item we're going to have to ask the user.
|
||||
if( collector.GetCount() > 1 )
|
||||
{
|
||||
if( !doSelectionMenu( &collector, _( "Clarify Selection" ) ) )
|
||||
collector.m_MenuTitle = _( "Clarify Selection" );
|
||||
// Must call selectionMenu via RunAction() to avoid event-loop contention
|
||||
m_toolMgr->RunAction( SCH_ACTIONS::selectionMenu, true, &collector );
|
||||
|
||||
if( collector.m_MenuCancelled )
|
||||
{
|
||||
if( aSelectionCancelledFlag )
|
||||
*aSelectionCancelledFlag = true;
|
||||
|
@ -442,13 +446,14 @@ int SCH_SELECTION_TOOL::SelectionMenu( const TOOL_EVENT& aEvent )
|
|||
{
|
||||
SCH_COLLECTOR* collector = aEvent.Parameter<SCH_COLLECTOR*>();
|
||||
|
||||
doSelectionMenu( collector, wxEmptyString );
|
||||
if( !doSelectionMenu( collector ) )
|
||||
collector->m_MenuCancelled = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool SCH_SELECTION_TOOL::doSelectionMenu( SCH_COLLECTOR* aCollector, const wxString& aTitle )
|
||||
bool SCH_SELECTION_TOOL::doSelectionMenu( SCH_COLLECTOR* aCollector )
|
||||
{
|
||||
SCH_ITEM* current = nullptr;
|
||||
#if 1
|
||||
|
@ -471,7 +476,7 @@ bool SCH_SELECTION_TOOL::doSelectionMenu( SCH_COLLECTOR* aCollector, const wxStr
|
|||
m_frame->GetScreen()->SetCurItem( nullptr );
|
||||
int idx = m_frame->GetPopupMenuSelectionFromUser( selectMenu );
|
||||
|
||||
if( idx == wxNOT_FOUND )
|
||||
if( idx == wxID_NONE )
|
||||
{
|
||||
m_frame->GetScreen()->SetCurItem( nullptr );
|
||||
return false;
|
||||
|
@ -502,8 +507,8 @@ bool SCH_SELECTION_TOOL::doSelectionMenu( SCH_COLLECTOR* aCollector, const wxStr
|
|||
menu.Add( menuText, i + 1, item->GetMenuImage() );
|
||||
}
|
||||
|
||||
if( aTitle.Length() )
|
||||
menu.SetTitle( aTitle );
|
||||
if( aCollector->m_MenuTitle.Length() )
|
||||
menu.SetTitle( aCollector->m_MenuTitle );
|
||||
|
||||
menu.SetIcon( info_xpm );
|
||||
menu.DisplayTitle( true );
|
||||
|
|
|
@ -133,10 +133,9 @@ private:
|
|||
* Allows the selection of a single item from a list via pop-up menu. The items are
|
||||
* highlighted on the canvas when hovered in the menu. The collector is trimmed to
|
||||
* the picked item.
|
||||
* @param aTitle (optional) Allows the menu to be titled (ie: "Clarify Selection").
|
||||
* @return true if an item was picked
|
||||
*/
|
||||
bool doSelectionMenu( SCH_COLLECTOR* aItems, const wxString& aTitle );
|
||||
bool doSelectionMenu( SCH_COLLECTOR* aItems );
|
||||
|
||||
/**
|
||||
* Function clearSelection()
|
||||
|
|
Loading…
Reference in New Issue