Eeschema: fix bug #142970 (broken append sheet function)
Fix a few minor coverity warnings.
This commit is contained in:
parent
035b231b62
commit
c586d9735e
|
@ -359,19 +359,60 @@ bool SCH_EDIT_FRAME::AppendOneEEProject()
|
|||
|
||||
wxLogDebug( wxT( "Importing schematic " ) + fullFileName );
|
||||
|
||||
// Keep trace of the last item in list.
|
||||
// New items will be loaded after this one.
|
||||
SCH_ITEM* bs = screen->GetDrawItems();
|
||||
|
||||
if( bs )
|
||||
while( bs->Next() )
|
||||
bs = bs->Next();
|
||||
|
||||
// load the project
|
||||
bool success = LoadOneEEFile( screen, fullFileName, true );
|
||||
|
||||
if( success )
|
||||
{
|
||||
// load sub-sheets
|
||||
EDA_ITEM* bs = screen->GetDrawItems();
|
||||
// the new loaded items need cleaning to avoid duplicate parameters
|
||||
// which should be unique (ref and time stamp).
|
||||
// Clear ref and set a new time stamp for new items
|
||||
if( bs == NULL )
|
||||
bs = screen->GetDrawItems();
|
||||
else
|
||||
bs = bs->Next();
|
||||
|
||||
while( bs )
|
||||
{
|
||||
// do not append hierarchical sheets
|
||||
SCH_ITEM* nextbs = bs->Next();
|
||||
|
||||
// To avoid issues with the current hieratchy,
|
||||
// do not load included sheets files and give new filenames
|
||||
// and new sheet names.
|
||||
// There are many tricky cases (loops, creation of complex hierarchies
|
||||
// with duplicate file names, duplicate sheet names...)
|
||||
// So the included sheets names are renamed if existing,
|
||||
// and filenames are just renamed to avoid loops and
|
||||
// creation of complex hierarchies.
|
||||
// If someone want to change it for a better append function, remember
|
||||
// these cases need work to avoid issues.
|
||||
if( bs->Type() == SCH_SHEET_T )
|
||||
{
|
||||
screen->Remove( (SCH_SHEET*) bs );
|
||||
SCH_SHEET * sheet = (SCH_SHEET *) bs;
|
||||
time_t newtimestamp = GetNewTimeStamp();
|
||||
sheet->SetTimeStamp( newtimestamp );
|
||||
|
||||
// Check for existing subsheet name in the current sheet
|
||||
wxString tmp = sheet->GetName();
|
||||
sheet->SetName( wxEmptyString );
|
||||
const SCH_SHEET* subsheet = GetScreen()->GetSheet( tmp );
|
||||
|
||||
if( subsheet )
|
||||
sheet->SetName( wxString::Format( wxT( "Sheet%8.8lX" ), (long) newtimestamp ) );
|
||||
else
|
||||
sheet->SetName( tmp );
|
||||
|
||||
sheet->SetFileName( wxString::Format( wxT( "file%8.8lX.sch" ), (long) newtimestamp ) );
|
||||
sheet->SetScreen( new SCH_SCREEN( &Kiway() ) );
|
||||
sheet->GetScreen()->SetFileName( sheet->GetFileName() );
|
||||
}
|
||||
// clear annotation and init new time stamp for the new components
|
||||
else if( bs->Type() == SCH_COMPONENT_T )
|
||||
|
@ -383,7 +424,7 @@ bool SCH_EDIT_FRAME::AppendOneEEProject()
|
|||
bs->ClearFlags();
|
||||
}
|
||||
|
||||
bs = bs->Next();
|
||||
bs = nextbs;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1191,9 +1191,6 @@ LIB_ITEM* LIB_EDIT_FRAME::LocateItemUsingCursor( const wxPoint& aPosition,
|
|||
|
||||
LIB_ITEM* item = locateItem( aPosition, aFilterList );
|
||||
|
||||
if( item == NULL )
|
||||
return NULL;
|
||||
|
||||
wxPoint pos = GetNearestGridPosition( aPosition );
|
||||
|
||||
if( item == NULL && aPosition != pos )
|
||||
|
|
|
@ -148,7 +148,7 @@ again." );
|
|||
// EELAYER i j
|
||||
// and the last line is
|
||||
// EELAYER END
|
||||
// Skip all lines until end end of header EELAYER END is found
|
||||
// Skip all lines until the end of header "EELAYER END" is found
|
||||
while( reader.ReadLine() )
|
||||
{
|
||||
line = reader.Line();
|
||||
|
|
|
@ -112,16 +112,13 @@ void SCH_EDIT_FRAME::OnLeftClick( wxDC* aDC, const wxPoint& aPosition )
|
|||
|
||||
item = LocateAndShowItem( aPosition, SCH_COLLECTOR::SheetsOnly );
|
||||
|
||||
if( item )
|
||||
if( item ) // The user has clicked on a sheet: this is an enter sheet command
|
||||
{
|
||||
m_CurrentSheet->Push( (SCH_SHEET*) item );
|
||||
DisplayCurrentSheet();
|
||||
}
|
||||
else
|
||||
{
|
||||
wxCHECK_RET( m_CurrentSheet->Last() != g_RootSheet,
|
||||
wxT( "Cannot leave root sheet. Bad Programmer!" ) );
|
||||
|
||||
else if( m_CurrentSheet->Last() != g_RootSheet )
|
||||
{ // The user has clicked ouside a sheet:this is an leave sheet command
|
||||
m_CurrentSheet->Pop();
|
||||
DisplayCurrentSheet();
|
||||
}
|
||||
|
|
|
@ -276,10 +276,11 @@ void SCH_COMPONENT::ResolveAll(
|
|||
{
|
||||
for( int i = 0; i < aComponents.GetCount(); ++i )
|
||||
{
|
||||
SCH_COMPONENT* c = dynamic_cast<SCH_COMPONENT*>( aComponents[i] );
|
||||
wxASSERT( c );
|
||||
SCH_COMPONENT* cmp = dynamic_cast<SCH_COMPONENT*>( aComponents[i] );
|
||||
wxASSERT( cmp );
|
||||
|
||||
c->Resolve( aLibs );
|
||||
if( cmp ) // cmp == NULL should not occur.
|
||||
cmp->Resolve( aLibs );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -673,6 +673,7 @@ public:
|
|||
{
|
||||
// Avoid non initialized variables:
|
||||
pageStreamHandle = streamLengthHandle = fontResDictHandle = 0;
|
||||
pageTreeHandle = 0;
|
||||
}
|
||||
|
||||
virtual PlotFormat GetPlotterType() const
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include <class_board_design_settings.h>
|
||||
#include <class_board.h>
|
||||
#include <class_module.h>
|
||||
#include <ratsnest_data.h>
|
||||
#include <wildcards_and_files_ext.h>
|
||||
|
||||
#include <dialog_netlist.h>
|
||||
|
@ -331,6 +332,10 @@ void DIALOG_NETLIST::OnTestFootprintsClick( wxCommandEvent& event )
|
|||
|
||||
void DIALOG_NETLIST::OnCompileRatsnestClick( wxCommandEvent& event )
|
||||
{
|
||||
// Rebuild the board connectivity:
|
||||
if( m_parent->IsGalCanvasActive() )
|
||||
m_parent->GetBoard()->GetRatsnest()->ProcessBoard();
|
||||
|
||||
m_parent->Compile_Ratsnest( m_dc, true );
|
||||
}
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName,
|
|||
// Rebuild the board connectivity:
|
||||
if( IsGalCanvasActive() )
|
||||
board->GetRatsnest()->ProcessBoard();
|
||||
else
|
||||
|
||||
Compile_Ratsnest( NULL, true );
|
||||
|
||||
SetMsgPanel( board );
|
||||
|
|
Loading…
Reference in New Issue