Commit e898427b authored by charras's avatar charras

eeschema: problem when attempting to load a non existing file

parent 59c9f72b
...@@ -80,6 +80,7 @@ bool WinEDA_App::OnInit() ...@@ -80,6 +80,7 @@ bool WinEDA_App::OnInit()
SetupServerFunction( RemoteCommand ); SetupServerFunction( RemoteCommand );
} }
ActiveScreen = m_SchematicFrame->GetScreen();
m_SchematicFrame->Zoom_Automatique( TRUE ); m_SchematicFrame->Zoom_Automatique( TRUE );
/* Load file specified in the command line. */ /* Load file specified in the command line. */
...@@ -93,7 +94,7 @@ bool WinEDA_App::OnInit() ...@@ -93,7 +94,7 @@ bool WinEDA_App::OnInit()
} }
else else
{ {
Read_Config( wxEmptyString, TRUE ); // Read config file ici si pas de fichier a charger Read_Config( wxEmptyString, TRUE ); // Read a default config file if no file to load
if( m_SchematicFrame->DrawPanel ) if( m_SchematicFrame->DrawPanel )
m_SchematicFrame->DrawPanel->Refresh( TRUE ); m_SchematicFrame->DrawPanel->Refresh( TRUE );
} }
......
...@@ -28,7 +28,7 @@ void WinEDA_SchematicFrame::Save_File( wxCommandEvent& event ) ...@@ -28,7 +28,7 @@ void WinEDA_SchematicFrame::Save_File( wxCommandEvent& event )
switch( id ) switch( id )
{ {
case ID_SAVE_PROJECT: /* Update Schematic File */ case ID_SAVE_PROJECT: /* Update Schematic File */
SaveProject( ); SaveProject();
break; break;
case ID_SAVE_ONE_SHEET: /* Update Schematic File */ case ID_SAVE_ONE_SHEET: /* Update Schematic File */
...@@ -89,23 +89,26 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe ...@@ -89,23 +89,26 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
TRUE TRUE
); );
if( FullFileName.IsEmpty() ) if( FullFileName.IsEmpty() )
return FALSE; return 0;
} }
if(g_RootSheet){ if( g_RootSheet )
SAFE_DELETE(g_RootSheet); {
SAFE_DELETE( g_RootSheet );
} }
CreateScreens(); CreateScreens();
screen = (SCH_SCREEN*)GetScreen(); ActiveScreen = GetScreen();
screen = (SCH_SCREEN*) GetScreen();
wxSetWorkingDirectory( wxPathOnly( FullFileName ) ); wxSetWorkingDirectory( wxPathOnly( FullFileName ) );
GetScreen()->m_FileName = FullFileName; GetScreen()->m_FileName = FullFileName;
g_RootSheet->SetFileName(FullFileName); g_RootSheet->SetFileName( FullFileName );
Affiche_Message( wxEmptyString ); Affiche_Message( wxEmptyString );
MsgPanel->EraseMsgBox(); MsgPanel->EraseMsgBox();
memset( &g_EESchemaVar, 0, sizeof(g_EESchemaVar) ); memset( &g_EESchemaVar, 0, sizeof(g_EESchemaVar) );
GetScreen()->ClrModify(); GetScreen()->ClrModify();
//m_CurrentSheet->m_AssociatedScreen->Pnext = NULL; should be by default //m_CurrentSheet->m_AssociatedScreen->Pnext = NULL; should be by default
if( IsNew ) if( IsNew )
...@@ -143,7 +146,8 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe ...@@ -143,7 +146,8 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
if( IsNew ) if( IsNew )
{ {
ReDrawPanel(); if( DrawPanel )
DrawPanel->Refresh( true );
return 1; return 1;
} }
...@@ -173,6 +177,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe ...@@ -173,6 +177,7 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
if( !wxFileExists( g_RootSheet->m_AssociatedScreen->m_FileName ) && !LibCacheExist ) // Nouveau projet prpbablement if( !wxFileExists( g_RootSheet->m_AssociatedScreen->m_FileName ) && !LibCacheExist ) // Nouveau projet prpbablement
{ {
Zoom_Automatique( FALSE );
msg.Printf( _( "File %s not found (new project ?)" ), msg.Printf( _( "File %s not found (new project ?)" ),
g_RootSheet->m_AssociatedScreen->m_FileName.GetData() ); g_RootSheet->m_AssociatedScreen->m_FileName.GetData() );
DisplayInfo( this, msg, 20 ); DisplayInfo( this, msg, 20 );
...@@ -180,40 +185,45 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe ...@@ -180,40 +185,45 @@ int WinEDA_SchematicFrame::LoadOneEEProject( const wxString& FileName, bool IsNe
} }
//load the project. //load the project.
SAFE_DELETE(g_RootSheet->m_AssociatedScreen); SAFE_DELETE( g_RootSheet->m_AssociatedScreen );
bool diag = g_RootSheet->Load(this); bool diag = g_RootSheet->Load( this );
/* Reaffichage ecran de base (ROOT) si necessaire */ /* Reaffichage ecran de base (ROOT) si necessaire */
ActiveScreen = GetScreen(); ActiveScreen = GetScreen();
Zoom_Automatique( FALSE ); Zoom_Automatique( FALSE );
SetSheetNumberAndCount(); SetSheetNumberAndCount();
DrawPanel->Refresh( TRUE ); DrawPanel->Refresh( true );
return diag; return diag;
} }
/**********************************************************/ /**********************************************************/
SCH_SCREEN * WinEDA_SchematicFrame::CreateNewScreen( SCH_SCREEN* WinEDA_SchematicFrame::CreateNewScreen(
SCH_SCREEN * OldScreen, int TimeStamp) SCH_SCREEN* OldScreen, int TimeStamp )
/**********************************************************/ /**********************************************************/
/* Routine de creation ( par allocation memoire ) d'un nouvel ecran /* Routine de creation ( par allocation memoire ) d'un nouvel ecran
cet ecran est en chainage arriere avec OldScreen * cet ecran est en chainage arriere avec OldScreen
la valeur TimeStamp est attribuee au parametre NewScreen->TimeStamp * la valeur TimeStamp est attribuee au parametre NewScreen->TimeStamp
*/ */
{ {
SCH_SCREEN * NewScreen; SCH_SCREEN* NewScreen;
NewScreen = new SCH_SCREEN(SCHEMATIC_FRAME); NewScreen = new SCH_SCREEN( SCHEMATIC_FRAME );
NewScreen->SetRefreshReq(); NewScreen->SetRefreshReq();
if(OldScreen) NewScreen->m_Company = OldScreen->m_Company; if( OldScreen )
NewScreen->m_Company = OldScreen->m_Company;
NewScreen->m_TimeStamp = TimeStamp; NewScreen->m_TimeStamp = TimeStamp;
NewScreen->Pback = OldScreen; NewScreen->Pback = OldScreen;
return(NewScreen); return NewScreen;
} }
/****************************************************/ /****************************************************/
void WinEDA_SchematicFrame::SaveProject( ) void WinEDA_SchematicFrame::SaveProject()
/****************************************************/ /****************************************************/
/* Saves the entire project and creates an archive for components /* Saves the entire project and creates an archive for components
...@@ -228,7 +238,7 @@ void WinEDA_SchematicFrame::SaveProject( ) ...@@ -228,7 +238,7 @@ void WinEDA_SchematicFrame::SaveProject( )
for( screen = ScreenList.GetFirst(); screen != NULL; for( screen = ScreenList.GetFirst(); screen != NULL;
screen = ScreenList.GetNext() ) screen = ScreenList.GetNext() )
{ {
D(printf("SaveEEFile, %s\n", CONV_TO_UTF8(screen->m_FileName) );) D( printf( "SaveEEFile, %s\n", CONV_TO_UTF8( screen->m_FileName ) ); )
SaveEEFile( screen, FILE_SAVE_AS ); SaveEEFile( screen, FILE_SAVE_AS );
} }
...@@ -250,29 +260,30 @@ int CountCmpNumber() ...@@ -250,29 +260,30 @@ int CountCmpNumber()
* powers non comprises */ * powers non comprises */
{ {
return g_RootSheet->ComponentCount(); return g_RootSheet->ComponentCount();
/*
BASE_SCREEN* Window;
EDA_BaseStruct* Phead;
int Nb = 0;
/*
* BASE_SCREEN* Window;
Window = ScreenSch; * EDA_BaseStruct* Phead;
while( Window ) * int Nb = 0;
{ *
for( Phead = Window->EEDrawList; Phead != NULL; Phead = Phead->Pnext ) *
{ *
if( Phead->Type() == TYPE_SCH_COMPONENT ) * Window = ScreenSch;
{ * while( Window )
DrawPartStruct* Cmp = (DrawPartStruct*) Phead; * {
if( Cmp->m_Field[VALUE].m_Text.GetChar( 0 ) != '#' ) * for( Phead = Window->EEDrawList; Phead != NULL; Phead = Phead->Pnext )
Nb++; * {
} * if( Phead->Type() == TYPE_SCH_COMPONENT )
} * {
* DrawPartStruct* Cmp = (DrawPartStruct*) Phead;
Window = (BASE_SCREEN*) Window->Pnext; * if( Cmp->m_Field[VALUE].m_Text.GetChar( 0 ) != '#' )
} * Nb++;
* }
return Nb; * }
*
* Window = (BASE_SCREEN*) Window->Pnext;
* }
*
* return Nb;
*/ */
} }
No preview for this file type
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment