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 )
{
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() )
pcb->DeleteMARKERs();
@ -233,7 +233,9 @@ void DIALOG_GLOBAL_DELETION::AcceptPcbDelete()
m_Parent->Compile_Ratsnest( NULL, true );
// 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() )
//pcb->GetRatsnest()->ProcessBoard();
if( m_Parent->IsGalCanvasActive() )
pcb->GetRatsnest()->ProcessBoard();
else
m_Parent->GetCanvas()->Refresh();
}

View File

@ -44,6 +44,8 @@
#include <class_track.h>
#include <class_zone.h>
#include <class_drawsegment.h>
#include <ratsnest_data.h>
#include <view/view.h>
#include <specctra.h>
@ -62,14 +64,6 @@ void PCB_EDIT_FRAME::ImportSpecctraDesign( wxCommandEvent& event )
void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
{
/*
if( GetScreen()->IsModify() )
{
if( !IsOK( this, _( "Board Modified: Continue ?" ) ) )
return;
}
*/
wxString fullFileName = GetBoard()->GetFileName();
wxString path;
wxString name;
@ -93,6 +87,13 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
if( fullFileName == wxEmptyString )
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;
LOCALE_IO toggle;
@ -116,18 +117,24 @@ void PCB_EDIT_FRAME::ImportSpecctraSession( wxCommandEvent& event )
OnModify();
GetBoard()->m_Status_Pcb = 0;
/* At this point we should call Compile_Ratsnest()
* but this could be time consumming.
* So if incorrect number of Connected and No connected pads is accepted
* until Compile_Ratsnest() is called (when track tool selected for instance)
* leave the next line commented
* Otherwise uncomment this line
*/
//Compile_Ratsnest( NULL, true );
Compile_Ratsnest( NULL, true );
GetBoard()->GetRatsnest()->ProcessBoard();
if( GetGalCanvas() ) // Update view:
{
auto view = GetGalCanvas()->GetView();
// 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." ) ) );
m_canvas->Refresh( true );
Refresh();
}
@ -488,14 +495,6 @@ void SPECCTRA_DB::FromSESSION( BOARD* aBoard ) throw( IO_ERROR )
PATH* path = (PATH*) wire->shape;
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 );
aBoard->Add( track );
}