Commit e80d0750 authored by charras's avatar charras

make command-line invocation with relative paths work

parent 76fc4042
...@@ -589,12 +589,12 @@ void WinEDA_App::SetDefaultSearchPaths( void ) ...@@ -589,12 +589,12 @@ void WinEDA_App::SetDefaultSearchPaths( void )
} }
/** /** Function GetSettings
* Get application settings * Get application settings
* * @param aReopenLastUsedDirectory = true to switch to last opened directory, false to use current CWD
* @return none * @return none
*/ */
void WinEDA_App::GetSettings() void WinEDA_App::GetSettings(bool aReopenLastUsedDirectory)
{ {
wxASSERT( m_EDA_Config != NULL && m_EDA_CommonConfig != NULL ); wxASSERT( m_EDA_Config != NULL && m_EDA_CommonConfig != NULL );
...@@ -613,10 +613,13 @@ void WinEDA_App::GetSettings() ...@@ -613,10 +613,13 @@ void WinEDA_App::GetSettings()
m_EDA_Config->Read( wxT( "ShowPageLimits" ), &g_ShowPageLimits ); m_EDA_Config->Read( wxT( "ShowPageLimits" ), &g_ShowPageLimits );
if( aReopenLastUsedDirectory )
{
if( m_EDA_Config->Read( wxT( "WorkingDir" ), &Line ) && wxDirExists( Line ) ) if( m_EDA_Config->Read( wxT( "WorkingDir" ), &Line ) && wxDirExists( Line ) )
{ {
wxSetWorkingDirectory( Line ); wxSetWorkingDirectory( Line );
} }
}
m_EDA_Config->Read( wxT( "BgColor" ), &g_DrawBgColor ); m_EDA_Config->Read( wxT( "BgColor" ), &g_DrawBgColor );
} }
......
...@@ -43,7 +43,6 @@ bool WinEDA_App::OnInit() ...@@ -43,7 +43,6 @@ bool WinEDA_App::OnInit()
{ {
wxFileName fn; wxFileName fn;
wxString msg; wxString msg;
wxString currCWD = wxGetCwd();
WinEDA_CvpcbFrame* frame = NULL; WinEDA_CvpcbFrame* frame = NULL;
InitEDA_Appl( wxT( "Cvpcb" ), APP_TYPE_CVPCB ); InitEDA_Appl( wxT( "Cvpcb" ), APP_TYPE_CVPCB );
...@@ -54,17 +53,16 @@ bool WinEDA_App::OnInit() ...@@ -54,17 +53,16 @@ bool WinEDA_App::OnInit()
return false; return false;
} }
GetSettings(); // read current setup
wxSetWorkingDirectory( currCWD ); // mofifie par GetSetting
if( argc > 1 ) if( argc > 1 )
{ {
wxLogDebug( wxT( "CvPcb opening file <%s>" ), argv[1] );
fn = argv[1]; fn = argv[1];
wxSetWorkingDirectory( fn.GetPath() ); wxSetWorkingDirectory( fn.GetPath() );
} }
// read current setup and reopen last directory if no filename to open in command line
bool reopenLastUsedDirectory = argc == 1;
GetSettings(reopenLastUsedDirectory);
g_DrawBgColor = BLACK; g_DrawBgColor = BLACK;
wxString Title = GetTitle() + wxT( " " ) + GetBuildVersion(); wxString Title = GetTitle() + wxT( " " ) + GetBuildVersion();
......
...@@ -869,25 +869,14 @@ static SCH_ITEM* CopyStruct( WinEDA_DrawPanel* panel, ...@@ -869,25 +869,14 @@ static SCH_ITEM* CopyStruct( WinEDA_DrawPanel* panel,
switch( Struct->Type() ) switch( Struct->Type() )
{ {
case TYPE_SCH_COMPONENT: case TYPE_SCH_COMPONENT:
{
( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp(); ( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp();
( (SCH_COMPONENT*) Struct )->ClearAnnotation( NULL ); ( (SCH_COMPONENT*) Struct )->ClearAnnotation( NULL );
}
break; break;
case DRAW_SHEET_STRUCT_TYPE: case DRAW_SHEET_STRUCT_TYPE:
{
//DuplicateStruct calls GenCopy, which should handle //DuplicateStruct calls GenCopy, which should handle
//m_AssociatedScreen and m_sRefCount properly. //m_AssociatedScreen, m_TimeStamp and m_sRefCount properly.
DrawSheetStruct* sheet = (DrawSheetStruct*) Struct;
sheet->m_TimeStamp = GetTimeStamp();
//sheet->m_AssociatedScreen->m_UndoList = NULL;
//sheet->m_AssociatedScreen->m_RedoList = NULL;
//keep m_AssociatedScreen pointer & associated.
//sheet->m_Son = NULL; m_son is involved in undo and redo.
break; break;
}
default: default:
; ;
......
...@@ -146,7 +146,9 @@ DrawSheetStruct* DrawSheetStruct::GenCopy() ...@@ -146,7 +146,9 @@ DrawSheetStruct* DrawSheetStruct::GenCopy()
newitem->m_FileName = m_FileName; newitem->m_FileName = m_FileName;
newitem->m_FileNameSize = m_FileNameSize; newitem->m_FileNameSize = m_FileNameSize;
newitem->m_SheetName = m_SheetName; /* newitem->m_SheetName = m_SheetName; m_SheetName must be unique for all sub sheets in a given sheet
* so we no not duplicate sheet name
*/
newitem->m_SheetNameSize = m_SheetNameSize; newitem->m_SheetNameSize = m_SheetNameSize;
newitem->m_Label = NULL; newitem->m_Label = NULL;
......
...@@ -151,7 +151,11 @@ bool WinEDA_App::OnInit() ...@@ -151,7 +151,11 @@ bool WinEDA_App::OnInit()
/* init EESCHEMA */ /* init EESCHEMA */
SeedLayers(); SeedLayers();
GetSettings();
// read current setup and reopen last directory if no filename to open in command line
bool reopenLastUsedDirectory = argc == 1;
GetSettings(reopenLastUsedDirectory);
Read_Hotkey_Config( frame, false ); /* Must be called before creating Read_Hotkey_Config( frame, false ); /* Must be called before creating
* the main frame in order to * the main frame in order to
* display the real hotkeys in menus * display the real hotkeys in menus
......
...@@ -45,7 +45,11 @@ bool WinEDA_App::OnInit() ...@@ -45,7 +45,11 @@ bool WinEDA_App::OnInit()
ScreenPcb->m_CurrentSheetDesc = &g_Sheet_GERBER; ScreenPcb->m_CurrentSheetDesc = &g_Sheet_GERBER;
ActiveScreen = ScreenPcb; ActiveScreen = ScreenPcb;
GetSettings();
// read current setup and reopen last directory if no filename to open in command line
bool reopenLastUsedDirectory = argc == 1;
GetSettings(reopenLastUsedDirectory);
extern PARAM_CFG_BASE* ParamCfgList[]; extern PARAM_CFG_BASE* ParamCfgList[];
wxGetApp().ReadCurrentSetupValues( ParamCfgList ); wxGetApp().ReadCurrentSetupValues( ParamCfgList );
......
...@@ -115,7 +115,13 @@ public: ...@@ -115,7 +115,13 @@ public:
void InitOnLineHelp(); void InitOnLineHelp();
// Sauvegarde de configurations et options: // Sauvegarde de configurations et options:
void GetSettings(); /** Function GetSettings
* Get application settings
* @param aReopenLastUsedDirectory = true to switch to last opened directory, false to use current CWD
* @return none
*/
void GetSettings(bool aReopenLastUsedDirectory);
void SaveSettings(); void SaveSettings();
void WriteProjectConfig( const wxString& local_config_filename, void WriteProjectConfig( const wxString& local_config_filename,
......
...@@ -371,8 +371,9 @@ bool WinEDA_App::OnInit() ...@@ -371,8 +371,9 @@ bool WinEDA_App::OnInit()
InitEDA_Appl( wxT( "KiCad" ), APP_TYPE_KICAD ); InitEDA_Appl( wxT( "KiCad" ), APP_TYPE_KICAD );
/* init kicad */ // read current setup and reopen last directory if no filename to open in command line
GetSettings(); // read current setup bool reopenLastUsedDirectory = argc == 1;
GetSettings(reopenLastUsedDirectory);
/* Make nameless project translatable */ /* Make nameless project translatable */
wxFileName namelessProject( wxGetCwd(), _( "noname" ), ProjectFileExtension ); wxFileName namelessProject( wxGetCwd(), _( "noname" ), ProjectFileExtension );
......
...@@ -83,7 +83,10 @@ bool WinEDA_App::OnInit() ...@@ -83,7 +83,10 @@ bool WinEDA_App::OnInit()
} }
ScreenPcb = new PCB_SCREEN(); ScreenPcb = new PCB_SCREEN();
GetSettings();
// read current setup and reopen last directory if no filename to open in command line
bool reopenLastUsedDirectory = argc == 1;
GetSettings(reopenLastUsedDirectory);
if( argc > 1 ) if( argc > 1 )
{ {
......
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