Fix a few issues when importing a .ses specctra session file.

(potential crash due to missing update of ratsnet data, add missing traces in GAL mode)
This commit is contained in:
jean-pierre charras 2017-03-21 11:22:03 +01:00
parent 806e71b17e
commit 48f19c031a
3 changed files with 30 additions and 35 deletions

View File

@ -104,12 +104,6 @@ void DIALOG_FREEROUTE::OnExportButtonClick( wxCommandEvent& event )
void DIALOG_FREEROUTE::OnImportButtonClick( wxCommandEvent& event ) void DIALOG_FREEROUTE::OnImportButtonClick( wxCommandEvent& event )
{ {
m_Parent->ImportSpecctraSession( event ); m_Parent->ImportSpecctraSession( event );
/* Connectivity must be rebuild.
* because for large board it can take some time, this is made only on demand
*/
if( IsOK( this, _("Do you want to rebuild connectivity data ?" ) ) )
m_Parent->Compile_Ratsnest( NULL, true );
} }

View File

@ -224,7 +224,7 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
} }
} }
commit.Push( wxT( "Global delete" ) ); commit.Push( "Global delete" );
if( m_DelMarkers->GetValue() ) if( m_DelMarkers->GetValue() )
pcb->DeleteMARKERs(); pcb->DeleteMARKERs();
@ -233,7 +233,9 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
m_Parent->Compile_Ratsnest( NULL, true ); m_Parent->Compile_Ratsnest( NULL, true );
// There is a chance that some of tracks have changed their nets, so rebuild ratsnest from scratch // There is a chance that some of tracks have changed their nets, so rebuild ratsnest from scratch
// TODO necessary? if not, remove rn_data.h header as well if( m_Parent->IsGalCanvasActive() )
//if( m_Parent->IsGalCanvasActive() ) pcb->GetRatsnest()->ProcessBoard();
//pcb->GetRatsnest()->ProcessBoard(); else
m_Parent->GetCanvas()->Refresh();
} }

View File

@ -44,6 +44,8 @@
#include <class_track.h> #include <class_track.h>
#include <class_zone.h> #include <class_zone.h>
#include <class_drawsegment.h> #include <class_drawsegment.h>
#include <ratsnest_data.h>
#include <view/view.h>
#include <specctra.h> #include <specctra.h>
@ -62,14 +64,6 @@ void PCB_EDIT_FRAME::ImportSpecctraDesign( wxCommandEvent& event )
void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event ) void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
{ {
/*
if( GetScreen()->IsModify() )
{
if( !IsOK( this, _( "Board Modified: Continue ?" ) ) )
return;
}
*/
wxString fullFileName = GetBoard()->GetFileName(); wxString fullFileName = GetBoard()->GetFileName();
wxString path; wxString path;
wxString name; wxString name;
@ -93,6 +87,13 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
if( fullFileName == wxEmptyString ) if( fullFileName == wxEmptyString )
return; return;
SetCurItem( NULL );
// To avoid issues with undo/redo lists (dangling pointers)
// clear the lists
// todo: use undo/redo feature
GetScreen()->ClearUndoRedoList();
SPECCTRA_DB db; SPECCTRA_DB db;
LOCALE_IO toggle; LOCALE_IO toggle;
@ -116,18 +117,24 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
OnModify(); OnModify();
GetBoard()->m_Status_Pcb = 0; GetBoard()->m_Status_Pcb = 0;
/* At this point we should call Compile_Ratsnest() Compile_Ratsnest( NULL, true );
* but this could be time consumming. GetBoard()->GetRatsnest()->ProcessBoard();
* So if incorrect number of Connected and No connected pads is accepted
* until Compile_Ratsnest() is called (when track tool selected for instance) if( GetGalCanvas() ) // Update view:
* leave the next line commented {
* Otherwise uncomment this line auto view = GetGalCanvas()->GetView();
*/
//Compile_Ratsnest( NULL, true ); // Update footprint positions
view->RecacheAllItems();
// add imported tracks (previous tracks are removed, therfore all are new)
for( TRACK* track = GetBoard()->m_Track; track; track = track->Next() )
view->Add( track );
}
SetStatusText( wxString( _( "Session file imported and merged OK." ) ) ); SetStatusText( wxString( _( "Session file imported and merged OK." ) ) );
m_canvas->Refresh( true ); Refresh();
} }
@ -488,14 +495,6 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR )
PATH* path = (PATH*) wire->shape; PATH* path = (PATH*) wire->shape;
for( unsigned pt=0; pt<path->points.size()-1; ++pt ) for( unsigned pt=0; pt<path->points.size()-1; ++pt )
{ {
/* a debugging aid, may come in handy
if( path->points[pt].x == 547800
&& path->points[pt].y == -380250 )
{
int breakhere = 1;
}
*/
TRACK* track = makeTRACK( path, pt, netoutCode ); TRACK* track = makeTRACK( path, pt, netoutCode );
aBoard->Add( track ); aBoard->Add( track );
} }