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 )
}
/**
/** Function GetSettings
* Get application settings
*
* @param aReopenLastUsedDirectory = true to switch to last opened directory, false to use current CWD
* @return none
*/
void WinEDA_App::GetSettings()
void WinEDA_App::GetSettings(bool aReopenLastUsedDirectory)
{
wxASSERT( m_EDA_Config != NULL && m_EDA_CommonConfig != NULL );
......@@ -613,9 +613,12 @@ void WinEDA_App::GetSettings()
m_EDA_Config->Read( wxT( "ShowPageLimits" ), &g_ShowPageLimits );
if( m_EDA_Config->Read( wxT( "WorkingDir" ), &Line ) && wxDirExists( Line ) )
if( aReopenLastUsedDirectory )
{
wxSetWorkingDirectory( Line );
if( m_EDA_Config->Read( wxT( "WorkingDir" ), &Line ) && wxDirExists( Line ) )
{
wxSetWorkingDirectory( Line );
}
}
m_EDA_Config->Read( wxT( "BgColor" ), &g_DrawBgColor );
......
......@@ -43,7 +43,6 @@ bool WinEDA_App::OnInit()
{
wxFileName fn;
wxString msg;
wxString currCWD = wxGetCwd();
WinEDA_CvpcbFrame* frame = NULL;
InitEDA_Appl( wxT( "Cvpcb" ), APP_TYPE_CVPCB );
......@@ -54,17 +53,16 @@ bool WinEDA_App::OnInit()
return false;
}
GetSettings(); // read current setup
wxSetWorkingDirectory( currCWD ); // mofifie par GetSetting
if( argc > 1 )
{
wxLogDebug( wxT( "CvPcb opening file <%s>" ), argv[1] );
fn = argv[1];
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;
wxString Title = GetTitle() + wxT( " " ) + GetBuildVersion();
......
......@@ -869,25 +869,14 @@ static SCH_ITEM* CopyStruct( WinEDA_DrawPanel* panel,
switch( Struct->Type() )
{
case TYPE_SCH_COMPONENT:
{
( (SCH_COMPONENT*) Struct )->m_TimeStamp = GetTimeStamp();
( (SCH_COMPONENT*) Struct )->ClearAnnotation( NULL );
}
break;
case DRAW_SHEET_STRUCT_TYPE:
{
//DuplicateStruct calls GenCopy, which should handle
//m_AssociatedScreen 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.
//m_AssociatedScreen, m_TimeStamp and m_sRefCount properly.
break;
}
default:
;
......
......@@ -146,7 +146,9 @@ DrawSheetStruct* DrawSheetStruct::GenCopy()
newitem->m_FileName = m_FileName;
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_Label = NULL;
......
......@@ -151,7 +151,11 @@ bool WinEDA_App::OnInit()
/* init EESCHEMA */
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
* the main frame in order to
* display the real hotkeys in menus
......
......@@ -45,7 +45,11 @@ bool WinEDA_App::OnInit()
ScreenPcb->m_CurrentSheetDesc = &g_Sheet_GERBER;
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[];
wxGetApp().ReadCurrentSetupValues( ParamCfgList );
......
......@@ -115,7 +115,13 @@ public:
void InitOnLineHelp();
// 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 WriteProjectConfig( const wxString& local_config_filename,
......
......@@ -371,8 +371,9 @@ bool WinEDA_App::OnInit()
InitEDA_Appl( wxT( "KiCad" ), APP_TYPE_KICAD );
/* init kicad */
GetSettings(); // read current setup
// read current setup and reopen last directory if no filename to open in command line
bool reopenLastUsedDirectory = argc == 1;
GetSettings(reopenLastUsedDirectory);
/* Make nameless project translatable */
wxFileName namelessProject( wxGetCwd(), _( "noname" ), ProjectFileExtension );
......
......@@ -83,7 +83,10 @@ bool WinEDA_App::OnInit()
}
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 )
{
......
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