diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 64772d0211..821e6dd72f 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -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 - if( bs->Type() == SCH_SHEET_T ) + 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; } } diff --git a/eeschema/libeditframe.cpp b/eeschema/libeditframe.cpp index d344c9c040..bf0dec7dc7 100644 --- a/eeschema/libeditframe.cpp +++ b/eeschema/libeditframe.cpp @@ -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 ) diff --git a/eeschema/load_one_schematic_file.cpp b/eeschema/load_one_schematic_file.cpp index c174a7bf46..a55656e225 100644 --- a/eeschema/load_one_schematic_file.cpp +++ b/eeschema/load_one_schematic_file.cpp @@ -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(); diff --git a/eeschema/onleftclick.cpp b/eeschema/onleftclick.cpp index 668fdb3471..ec9cb6220d 100644 --- a/eeschema/onleftclick.cpp +++ b/eeschema/onleftclick.cpp @@ -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(); } diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 84921b791c..ff7734e4bc 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -276,10 +276,11 @@ void SCH_COMPONENT::ResolveAll( { for( int i = 0; i < aComponents.GetCount(); ++i ) { - SCH_COMPONENT* c = dynamic_cast( aComponents[i] ); - wxASSERT( c ); + SCH_COMPONENT* cmp = dynamic_cast( aComponents[i] ); + wxASSERT( cmp ); - c->Resolve( aLibs ); + if( cmp ) // cmp == NULL should not occur. + cmp->Resolve( aLibs ); } } diff --git a/include/plot_common.h b/include/plot_common.h index e0dd660e90..024bc996ed 100644 --- a/include/plot_common.h +++ b/include/plot_common.h @@ -673,6 +673,7 @@ public: { // Avoid non initialized variables: pageStreamHandle = streamLengthHandle = fontResDictHandle = 0; + pageTreeHandle = 0; } virtual PlotFormat GetPlotterType() const diff --git a/pcbnew/dialogs/dialog_netlist.cpp b/pcbnew/dialogs/dialog_netlist.cpp index ad6ab8653a..7a85aef537 100644 --- a/pcbnew/dialogs/dialog_netlist.cpp +++ b/pcbnew/dialogs/dialog_netlist.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include @@ -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 ); } diff --git a/pcbnew/netlist.cpp b/pcbnew/netlist.cpp index 592ce504a4..941e3bc7b7 100644 --- a/pcbnew/netlist.cpp +++ b/pcbnew/netlist.cpp @@ -136,8 +136,8 @@ void PCB_EDIT_FRAME::ReadPcbNetlist( const wxString& aNetlistFileName, // Rebuild the board connectivity: if( IsGalCanvasActive() ) board->GetRatsnest()->ProcessBoard(); - else - Compile_Ratsnest( NULL, true ); + + Compile_Ratsnest( NULL, true ); SetMsgPanel( board ); m_canvas->Refresh();