Browse Source

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.
pull/13/head
jean-pierre charras 7 years ago
parent
commit
7ad21fefe5
  1. 2
      cvpcb/cvpcb_mainframe.cpp
  2. 9
      eeschema/cross-probing.cpp
  3. 2
      eeschema/find.cpp
  4. 14
      eeschema/sch_component.cpp
  5. 6
      eeschema/sch_component.h
  6. 17
      eeschema/sch_view.cpp
  7. 2
      pcbnew/cross-probing.cpp

2
cvpcb/cvpcb_mainframe.cpp

@ -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() );

9
eeschema/cross-probing.cpp

@ -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;

2
eeschema/find.cpp

@ -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();

14
eeschema/sch_component.cpp

@ -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 );
}

6
eeschema/sch_component.h

@ -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;
/**

17
eeschema/sch_view.cpp

@ -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 );
eitem->ClearFlags( HIGHLIGHTED );
// 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->Type() == SCH_COMPONENT_T )
if( eitem )
{
static_cast<SCH_COMPONENT*>( eitem )->ClearHighlightedPins();
eitem->ClearFlags( HIGHLIGHTED );
if( eitem->Type() == SCH_COMPONENT_T )
{
// Items inside a component (pins, fields can be highlighted.
static_cast<SCH_COMPONENT*>( eitem )->ClearAllHighlightFlags();
}
}
}
}
@ -210,9 +217,7 @@ 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...

2
pcbnew/cross-probing.cpp

@ -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…
Cancel
Save