Fix questionable code and memory leak.
This commit is contained in:
parent
101a600be6
commit
5b3d7962bb
|
@ -88,6 +88,9 @@ SCH_ITEM* SCH_EDIT_FRAME::LocateAndShowItem( const wxPoint& aPosition, const KIC
|
|||
break;
|
||||
|
||||
case SCH_SHEET_T:
|
||||
SendMessageToPCBNEW( item, nullptr );
|
||||
break;
|
||||
|
||||
case SCH_COMPONENT_T:
|
||||
component = (SCH_COMPONENT*) item;
|
||||
SendMessageToPCBNEW( item, component );
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include <lib_draw_item.h>
|
||||
#include <lib_pin.h>
|
||||
#include <sch_component.h>
|
||||
#include <sch_sheet.h>
|
||||
|
||||
|
||||
/**
|
||||
|
@ -110,36 +111,34 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
|
|||
}
|
||||
|
||||
|
||||
std::string FormatProbeItem( EDA_ITEM* aComponent, SCH_COMPONENT* aPart )
|
||||
std::string FormatProbeItem( EDA_ITEM* aItem, SCH_COMPONENT* aPart )
|
||||
{
|
||||
// Cross probing to Pcbnew if a pin or a component is found
|
||||
switch( aComponent->Type() )
|
||||
switch( aItem->Type() )
|
||||
{
|
||||
case SCH_FIELD_T:
|
||||
case LIB_FIELD_T:
|
||||
{
|
||||
if( !aPart )
|
||||
break;
|
||||
|
||||
return StrPrintf( "$PART: %s", TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
|
||||
}
|
||||
if( aPart )
|
||||
return StrPrintf( "$PART: %s",
|
||||
TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
|
||||
break;
|
||||
|
||||
case SCH_COMPONENT_T:
|
||||
aPart = (SCH_COMPONENT*) aComponent;
|
||||
aPart = (SCH_COMPONENT*) aItem;
|
||||
return StrPrintf( "$PART: %s", TO_UTF8( aPart->GetField( REFERENCE )->GetText() ) );
|
||||
|
||||
case SCH_SHEET_T:
|
||||
aPart = (SCH_COMPONENT*)aComponent;
|
||||
return StrPrintf( "$SHEET: %s", TO_UTF8( wxString::Format( wxT("%8.8lX"),
|
||||
(unsigned long) aPart->GetTimeStamp() ) ) );
|
||||
{
|
||||
SCH_SHEET* sheet = (SCH_SHEET*)aItem;
|
||||
return StrPrintf( "$SHEET: %8.8lX", (unsigned long) sheet->GetTimeStamp() );
|
||||
}
|
||||
|
||||
case LIB_PIN_T:
|
||||
{
|
||||
if( !aPart )
|
||||
break;
|
||||
|
||||
LIB_PIN* pin = (LIB_PIN*) aComponent;
|
||||
LIB_PIN* pin = (LIB_PIN*) aItem;
|
||||
|
||||
if( pin->GetNumber() )
|
||||
{
|
||||
|
@ -165,17 +164,14 @@ std::string FormatProbeItem( EDA_ITEM* aComponent, SCH_COMPONENT* aPart )
|
|||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* aComponent, SCH_COMPONENT* aPart )
|
||||
void SCH_EDIT_FRAME::SendMessageToPCBNEW( EDA_ITEM* aObjectToSync, SCH_COMPONENT* aLibItem )
|
||||
{
|
||||
#if 1
|
||||
wxASSERT( aComponent ); // fix the caller
|
||||
wxASSERT( aObjectToSync ); // fix the caller
|
||||
|
||||
#else // WTF?
|
||||
if( !aComponent ) // caller remains eternally stupid.
|
||||
if( !aObjectToSync )
|
||||
return;
|
||||
#endif
|
||||
|
||||
std::string packet = FormatProbeItem( aComponent, aPart );
|
||||
std::string packet = FormatProbeItem( aObjectToSync, aLibItem );
|
||||
|
||||
if( packet.size() )
|
||||
{
|
||||
|
|
|
@ -488,15 +488,17 @@ public:
|
|||
/**
|
||||
* Function SendMessageToPcbnew
|
||||
* send a remote to Pcbnew via a socket connection.
|
||||
* @param objectToSync Item to be located on board (footprint, pad or text)
|
||||
* @param LibItem Component in library if objectToSync is a sub item of a component
|
||||
* @param aObjectToSync = item to be located on board
|
||||
* (footprint, pad, text or schematic sheet)
|
||||
* @param aPart = component if objectToSync is a sub item of a symbol (like a pin)
|
||||
* <p>
|
||||
* Commands are
|
||||
* $PART: reference put cursor on footprint anchor
|
||||
* $PIN: number $PART: reference put cursor on the footprint pad
|
||||
* $SHEET: time_stamp select all footprints of components is the schematic sheet path
|
||||
* </p>
|
||||
*/
|
||||
void SendMessageToPCBNEW( EDA_ITEM* objectToSync, SCH_COMPONENT* LibItem );
|
||||
void SendMessageToPCBNEW( EDA_ITEM* aObjectToSync, SCH_COMPONENT* aPart );
|
||||
|
||||
/**
|
||||
* BuildNetListBase
|
||||
|
|
|
@ -45,7 +45,6 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
|
|||
char line[1024];
|
||||
wxString msg;
|
||||
wxString modName;
|
||||
wxString *sheetStamp;
|
||||
char* idcmd;
|
||||
char* text;
|
||||
MODULE* module = NULL;
|
||||
|
@ -81,11 +80,10 @@ void PCB_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline )
|
|||
else if( strcmp( idcmd, "$SHEET:" ) == 0 )
|
||||
{
|
||||
msg.Printf( _( "Selecting all from sheet '%s'" ), FROM_UTF8( text ) );
|
||||
sheetStamp = new wxString( FROM_UTF8( text ) );
|
||||
wxString sheetStamp( FROM_UTF8( text ) );
|
||||
SetStatusText( msg );
|
||||
GetToolManager()->RunAction( PCB_ACTIONS::selectOnSheet,
|
||||
true,
|
||||
static_cast<void*>( sheetStamp ) );
|
||||
GetToolManager()->RunAction( PCB_ACTIONS::selectOnSheet, true,
|
||||
static_cast<void*>( &sheetStamp ) );
|
||||
return;
|
||||
}
|
||||
else if( strcmp( idcmd, "$PIN:" ) == 0 )
|
||||
|
|
|
@ -95,18 +95,19 @@ TOOL_ACTION PCB_ACTIONS::selectOnSheet( "pcbnew.InteractiveSelection.SelectOnShe
|
|||
|
||||
TOOL_ACTION PCB_ACTIONS::selectSameSheet( "pcbnew.InteractiveSelection.SelectSameSheet",
|
||||
AS_GLOBAL, 'P',
|
||||
_( "Same Sheet" ), _( "Selects all modules and tracks in the same schematic sheet" ) );
|
||||
_( "Items in Same Hierarchical Sheet" ),
|
||||
_( "Selects all modules and tracks in the same schematic sheet" ) );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::find( "pcbnew.InteractiveSelection.Find",
|
||||
AS_GLOBAL, 0, //TOOL_ACTION::LegacyHotKey( HK_FIND_ITEM ), // handled by wxWidgets
|
||||
_( "Find Item" ), _( "Searches the document for an item" ), find_xpm );
|
||||
_( "Find Item" ),_( "Searches the document for an item" ), find_xpm );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::findMove( "pcbnew.InteractiveSelection.FindMove",
|
||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_GET_AND_MOVE_FOOTPRINT ) );
|
||||
|
||||
TOOL_ACTION PCB_ACTIONS::filterSelection( "pcbnew.InteractiveSelection.FilterSelection",
|
||||
AS_GLOBAL, MD_SHIFT + 'F',
|
||||
_( "Filter selection" ), _( "Filter the types of items in the selection" ),
|
||||
_( "Filter Selection" ), _( "Filter the types of items in the selection" ),
|
||||
nullptr );
|
||||
|
||||
|
||||
|
@ -775,6 +776,8 @@ int SELECTION_TOOL::selectNet( const TOOL_EVENT& aEvent )
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetpath )
|
||||
{
|
||||
auto modules = board()->m_Modules.GetFirst();
|
||||
|
@ -901,10 +904,13 @@ int SELECTION_TOOL::selectSameSheet( const TOOL_EVENT& aEvent )
|
|||
// this function currently only supports modules since they are only
|
||||
// on one sheet.
|
||||
auto item = m_selection.Front();
|
||||
|
||||
if( item->Type() != PCB_MODULE_T )
|
||||
return 0;
|
||||
|
||||
if( !item )
|
||||
return 0;
|
||||
|
||||
auto mod = dynamic_cast<MODULE*>( item );
|
||||
|
||||
clearSelection();
|
||||
|
|
Loading…
Reference in New Issue