Cross probing: Trying to fix a crash, certainly due to a call to clear the HIGHLIGHTED flag of a structure that is not a EDA_ITEM.
Minor enhancement: use a specific message in cross probing to clear the HIGHLIGHTED flag.
This commit is contained in:
parent
26a337db18
commit
7ad21fefe5
|
@ -728,7 +728,7 @@ void CVPCB_MAINFRAME::SendMessageToEESCHEMA( bool aClearHighligntOnly )
|
|||
|
||||
// clear highlight of previously selected components (if any):
|
||||
// Selecting a non existing symbol clears any previously highlighted symbols
|
||||
std::string packet = "$PART: \"$DUMMY$\"";
|
||||
std::string packet = "$CLEAR: \"HIGHLIGHTED\"";
|
||||
|
||||
if( Kiface().IsSingle() )
|
||||
SendCommand( MSG_TO_SCH, packet.c_str() );
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
* \li \c \$PART: \c "reference" \c \$VAL: \c "value" Put cursor on component value.
|
||||
* \li \c \$PART: \c "reference" \c \$PAD: \c "pin name" Put cursor on the component pin.
|
||||
* \li \c \$NET: \c "netname" Highlight a specified net
|
||||
* \li \c \$CLEAR: \c "HIGHLIGHTED" Clear components highlight
|
||||
* <p>
|
||||
* @param cmdline = received command from Pcbnew
|
||||
*/
|
||||
|
@ -97,6 +98,14 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
|
|||
return;
|
||||
}
|
||||
|
||||
if( strcmp( idcmd, "$CLEAR:" ) == 0 )
|
||||
{
|
||||
if( text && strcmp( text, "HIGHLIGHTED" ) == 0 )
|
||||
GetCanvas()->GetView()->HighlightItem( nullptr, nullptr );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if( text == NULL )
|
||||
return;
|
||||
|
||||
|
|
|
@ -235,7 +235,7 @@ SCH_ITEM* SCH_EDIT_FRAME::FindComponentAndItem( const wxString& aReference,
|
|||
|
||||
SetStatusText( msg );
|
||||
|
||||
// highlight selection if foundItem is not null, or clear any highlight selection
|
||||
// highlight selection if foundItem is not null, or clear any highlighted selection
|
||||
GetCanvas()->GetView()->HighlightItem( foundItem, pin );
|
||||
GetCanvas()->Refresh();
|
||||
|
||||
|
|
|
@ -1975,6 +1975,7 @@ void SCH_COMPONENT::Plot( PLOTTER* aPlotter )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void SCH_COMPONENT::ClearHighlightedPins()
|
||||
{
|
||||
m_highlightedPins.clear();
|
||||
|
@ -1991,3 +1992,16 @@ bool SCH_COMPONENT::IsPinHighlighted( const LIB_PIN* aPin )
|
|||
{
|
||||
return m_highlightedPins.find( aPin->GetNumber() ) != m_highlightedPins.end();
|
||||
}
|
||||
|
||||
|
||||
void SCH_COMPONENT::ClearAllHighlightFlags()
|
||||
{
|
||||
ClearFlags( HIGHLIGHTED );
|
||||
|
||||
// Clear the HIGHLIGHTED flag of pins
|
||||
ClearHighlightedPins();
|
||||
|
||||
// Clear the HIGHLIGHTED flag of other items, currently only fields
|
||||
for( SCH_FIELD& each_field : m_Fields )
|
||||
each_field.ClearFlags( HIGHLIGHTED );
|
||||
}
|
||||
|
|
|
@ -329,6 +329,12 @@ public:
|
|||
*/
|
||||
void SetTimeStamp( timestamp_t aNewTimeStamp );
|
||||
|
||||
/**
|
||||
* Clear the HIGHLIGHTED flag of all items of the component
|
||||
* (fields, pins ...)
|
||||
*/
|
||||
void ClearAllHighlightFlags();
|
||||
|
||||
const EDA_RECT GetBoundingBox() const override;
|
||||
|
||||
/**
|
||||
|
|
|
@ -194,12 +194,19 @@ void SCH_VIEW::HighlightItem( EDA_ITEM *aItem, LIB_PIN* aPin )
|
|||
{
|
||||
for( auto item : *m_allItems )
|
||||
{
|
||||
auto eitem = static_cast<EDA_ITEM *>( item );
|
||||
// Not all view items can be highlighted, only EDA_ITEMs
|
||||
// So clear flag of only EDA_ITEMs.
|
||||
auto eitem = dynamic_cast<EDA_ITEM *>( item );
|
||||
|
||||
if( eitem )
|
||||
{
|
||||
eitem->ClearFlags( HIGHLIGHTED );
|
||||
|
||||
if( eitem->Type() == SCH_COMPONENT_T )
|
||||
{
|
||||
static_cast<SCH_COMPONENT*>( eitem )->ClearHighlightedPins();
|
||||
// Items inside a component (pins, fields can be highlighted.
|
||||
static_cast<SCH_COMPONENT*>( eitem )->ClearAllHighlightFlags();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -210,10 +217,8 @@ void SCH_VIEW::HighlightItem( EDA_ITEM *aItem, LIB_PIN* aPin )
|
|||
static_cast<SCH_COMPONENT*>( aItem )->HighlightPin( aPin );
|
||||
}
|
||||
else
|
||||
{
|
||||
aItem->SetFlags( HIGHLIGHTED );
|
||||
}
|
||||
}
|
||||
|
||||
// ugly but I guess OK for the moment...
|
||||
UpdateAllItems( ALL );
|
||||
|
|
|
@ -253,7 +253,7 @@ std::string FormatProbeItem( BOARD_ITEM* aItem )
|
|||
MODULE* module;
|
||||
|
||||
if( !aItem )
|
||||
return "$PART: \"UNUSED0\""; // dummy message clears highlight state
|
||||
return "$CLEAR: \"HIGHLIGHTED\""; // message to clear highlight state
|
||||
|
||||
switch( aItem->Type() )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue