Commit 0f54a686 authored by charras's avatar charras

Solved: eeschema crashes when create a new sheet. Added comments in...

Solved: eeschema crashes when create a new sheet. Added comments in gestfich.cpp to explain the default paths used by kicad to find help files and lib files
parent 8d9b8a98
......@@ -5,6 +5,15 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with
email address.
2008-Mar-30 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+eeschema
Solved: eeschema crashes when create a new sheet, using the default filename and enter it.
+all:
Added comments in gestfich.cpp to explain the default paths used by kicad to find help files and lib files
2008-Mar-30 UPDATE Jonas Diemer <diemer-at-gmx.de>
================================================================================
+eeschema
......
......@@ -32,6 +32,37 @@
#include "wxstruct.h"
#include "macros.h"
/* List of default paths used to locate help files and kicad library files.
*
* Under windows, kicad search its files from the binary path file (first argument when running "main")
* So for a standard install, default paths are not mandatory, but they exist, just in case.
* kicad is often installed in c:/Program Files/kicad or c:/kicad (or d: or e: ... )
* and the directory "share" has no meaning under windows.
*
* Under linux, the problem is more complex.
* In fact there are 3 cases:
* 1 - When released in a distribution:
* binaries are in /usr/bin, kicad libs in /usr/share/kicad/ and doc in /usr/share/doc/kicad/
* 2 - When compiled by an user:
* binaries also can be in /usr/local/bin, kicad libs in /usr/local/share/kicad/ and doc in /usr/local/share/doc/kicad/
* 3 - When in an "universal tarball" or build for a server:
* all files are in /usr/local/kicad
* This is mandatory when kicad is installed on a server (in a school for instance) because one can export /usr/local/kicad
* and obviously the others paths cannot be used
* (cannot be mounted by the client, because they are already used).
*
* in cases 1 and 2 kicad files cannot be found from the binary path.
* in case 3 kicad files can be found from the binary path only if this is a kicad binary file which is launched.
* But if an user creates a symbolic link to the actual binary file to run kicad, the binary path is not good
* and the defaults paths must be used
*
* Note:
* kicad uses first the bin path lo locace kicad tree.
* if not found kicad uses the environment variable KICAD to find its files
* and at last kicad uses the default paths.
* So we can export (linux and windows) the variable KICAD:
* like export KICAD=/my_path/kicad if /my_path/kicad is not a default path
*/
// Path list for online help
static wxString s_HelpPathList[] = {
......@@ -43,29 +74,28 @@ static wxString s_HelpPathList[] = {
#else
wxT( "/usr/share/doc/kicad/help/" ),
wxT( "/usr/local/share/doc/kicad/help/" ),
wxT( "/usr/local/kicad/share/doc/kicad/" ), // TODO: must be removed
wxT( "/usr/local/kicad/" ), // default install for "universal tarballs" and build for a server
#endif
wxT( "end_list" ) // End of list symbol, do not change
wxT( "end_list" ) // End of list symbol, do not change
};
// Path list for kicad data files
static wxString s_KicadDataPathList[] = {
#ifdef __WINDOWS__
wxT( "c:/kicad/" ), // TODO: must be removed
wxT( "d:/kicad/" ), // TODO: must be removed
wxT( "c:/kicad/" ),
wxT( "d:/kicad/" ),
wxT( "c:/kicad/share/" ),
wxT( "d:/kicad/share/" ),
wxT( "c:/Program Files/kicad/" ), // TODO: must be removed
wxT( "d:/Program Files/kicad/" ), // TODO: must be removed
wxT( "c:/Program Files/kicad/" ),
wxT( "d:/Program Files/kicad/" ),
wxT( "c:/Program Files/kicad/share/" ),
wxT( "d:/Program Files/kicad/share/" ),
#else
wxT( "/usr/share/kicad/" ),
wxT( "/usr/local/share/kicad/" ),
wxT( "/usr/local/kicad/share/kicad/" ), // TODO: must be removed
wxT( "/usr/local/kicad/" ), // TODO: must be removed
wxT( "/usr/local/kicad/" ), // default install for "universal tarballs" and build for a server
#endif
wxT( "end_list" ) // End of list symbol, do not change
wxT( "end_list" ) // End of list symbol, do not change
};
// Path list for kicad binary files
......@@ -73,20 +103,20 @@ static wxString s_KicadBinaryPathList[] = {
#ifdef __WINDOWS__
wxT( "c:/kicad/bin/" ),
wxT( "d:/kicad/bin/" ),
wxT( "c:/kicad/winexe/" ), // TODO: must be removed
wxT( "d:/kicad/winexe/" ), // TODO: must be removed
wxT( "c:/kicad/winexe/" ), // TODO: must be removed
wxT( "d:/kicad/winexe/" ), // TODO: must be removed
wxT( "c:/Program Files/kicad/bin/" ),
wxT( "d:/Program Files/kicad/bin/" ),
wxT( "c:/Program Files/kicad/winexe/" ), // TODO: must be removed
wxT( "d:/Program Files/kicad/winexe/" ), // TODO: must be removed
wxT( "c:/Program Files/kicad/winexe/" ), // TODO: must be removed
wxT( "d:/Program Files/kicad/winexe/" ), // TODO: must be removed
#else
wxT( "/usr/bin/" ),
wxT( "/usr/local/bin/" ),
wxT( "/usr/local/kicad/bin/" ),
wxT( "/usr/local/kicad/linux/" ), // TODO: must be removed
wxT( "/usr/local/kicad/linux-non_unicode/" ), // TODO: must be removed
wxT( "/usr/local/kicad/linux/" ), // TODO: must be removed
wxT( "/usr/local/kicad/linux-non_unicode/" ), // TODO: must be removed
#endif
wxT( "end_list" ) // End of list symbol, do not change
wxT( "end_list" ) // End of list symbol, do not change
};
extern WinEDA_App* g_EDA_Appl;
......@@ -124,6 +154,7 @@ wxString MakeReducedFileName( const wxString& fullfilename,
path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
#ifdef __WINDOWS__
// names are case insensitive under windows
path.MakeLower();
Cwd.MakeLower();
......@@ -182,14 +213,14 @@ wxString MakeFileName( const wxString& dir,
{
if( !wxIsAbsolutePath( shortname ) )
{
if( ! shortname.StartsWith(wxT("./")) && ! shortname.StartsWith(wxT("../")) )
if( !shortname.StartsWith( wxT( "./" ) ) && !shortname.StartsWith( wxT( "../" ) ) )
{ /* no absolute path in shortname, add dir to shortname */
fullfilename = dir;
}
}
}
fullfilename += shortname; // Add shortname to dir or use shortname only
fullfilename += shortname; // Add shortname to dir or use shortname only
fullfilename.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
......@@ -207,7 +238,7 @@ wxString MakeFileName( const wxString& dir,
fullfilename += ext;
break;
}
if( fullfilename.GetChar( ii ) == '.' ) /* extension exists, do nothing */
if( fullfilename.GetChar( ii ) == '.' ) /* extension exists, do nothing */
break;
}
......@@ -317,25 +348,26 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti
wxSetWorkingDirectory( defaultpath );
#if 0 && defined(DEBUG)
printf("defaultpath=\"%s\" defaultname=\"%s\" Ext=\"%s\" Mask=\"%s\" flag=%d keep_working_directory=%d\n",
CONV_TO_UTF8(defaultpath),
CONV_TO_UTF8(defaultname),
CONV_TO_UTF8(Ext),
CONV_TO_UTF8(Mask),
flag,
keep_working_directory
);
#if 0 && defined (DEBUG)
printf(
"defaultpath=\"%s\" defaultname=\"%s\" Ext=\"%s\" Mask=\"%s\" flag=%d keep_working_directory=%d\n",
CONV_TO_UTF8( defaultpath ),
CONV_TO_UTF8( defaultname ),
CONV_TO_UTF8( Ext ),
CONV_TO_UTF8( Mask ),
flag,
keep_working_directory
);
#endif
fullfilename = wxFileSelector( wxString( Title ),
defaultpath,
defaultname,
Ext,
Mask,
flag,/* open mode wxFD_OPEN, wxFD_SAVE .. */
Frame,
Pos.x, Pos.y );
defaultpath,
defaultname,
Ext,
Mask,
flag, /* open mode wxFD_OPEN, wxFD_SAVE .. */
Frame,
Pos.x, Pos.y );
if( keep_working_directory )
wxSetWorkingDirectory( curr_cwd );
......@@ -347,6 +379,7 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti
/********************************************************/
wxString FindKicadHelpPath()
/********************************************************/
/** Function FindKicadHelpPath
* Find an absolute path for KiCad "help" (or "help/<language>")
* Find path kicad/doc/help/xx/ or kicad/doc/help/:
......@@ -371,6 +404,7 @@ wxString FindKicadHelpPath()
wxString FullPath, LangFullPath, tmp;
wxString LocaleString;
bool PathFound = FALSE;
/* find kicad/help/ */
tmp = g_EDA_Appl->m_BinDir;
if( tmp.Last() == '/' )
......@@ -378,7 +412,7 @@ wxString FindKicadHelpPath()
FullPath = tmp.BeforeLast( '/' ); // cd ..
FullPath += wxT( "/help/" );
LocaleString = g_EDA_Appl->m_Locale->GetCanonicalName();
wxString path_tmp = FullPath;
#ifdef __WINDOWS__
path_tmp.MakeLower();
......@@ -576,7 +610,7 @@ wxString ReturnKicadDatasPath()
}
else // Chemin cherche par le chemin des executables
{
// le chemin est bindir../
// le chemin est bindir../
wxString tmp = g_EDA_Appl->m_BinDir;
#ifdef __WINDOWS__
tmp.MakeLower();
......@@ -643,14 +677,14 @@ wxString GetEditorName()
mask += wxT( ".exe" );
#endif
editorname = EDA_FileSelector( _( "Prefered Editor:" ),
wxEmptyString, /* Default path */
wxEmptyString, /* default filename */
wxEmptyString, /* default filename extension */
mask, /* filter for filename list */
NULL, /* parent frame */
wxFD_OPEN, /* wxFD_SAVE, wxFD_OPEN ..*/
TRUE /* true = keep the current path */
);
wxEmptyString, /* Default path */
wxEmptyString, /* default filename */
wxEmptyString, /* default filename extension */
mask, /* filter for filename list */
NULL, /* parent frame */
wxFD_OPEN, /* wxFD_SAVE, wxFD_OPEN ..*/
TRUE /* true = keep the current path */
);
}
if( ( !editorname.IsEmpty() ) && g_EDA_Appl->m_EDA_CommonConfig )
......
......@@ -372,8 +372,8 @@ bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* screen, DrawSheetPath* lis
{
//search the existing hierarchy for an instance of screen "FileName".
//don't bother looking at the root sheet - it must be unique,
//no other references to its m_s otherwise there would be loops
//in the heirarchy.
//no other references to its m_AssociatedScreen otherwise there would be loops
//in the hierarchy.
//search the existing hierarchy for an instance of screen "FileName".
if( m_AssociatedScreen )
{
......@@ -482,7 +482,7 @@ void DrawSheetStruct::SetFileName( const wxString& aFilename )
* Set a new filename and manage data and associated screen
* The main difficulty is the filename change in a complex hierarchy.
* - if new filename is not already used: change to the new name (and if an existing file is found, load it on request)
* - if new filename is already used (a complex hierarchy) : reference the sheet.
* - if new filename is already used (a complex hierarchy) : reference the sheet.
*/
bool DrawSheetStruct::ChangeFileName( WinEDA_SchematicFrame * aFrame, const wxString& aFileName )
......
......@@ -99,11 +99,11 @@ WinEDA_SheetPropertiesFrame::WinEDA_SheetPropertiesFrame( WinEDA_SchematicFrame*
AddUnitSymbol( *m_SheetNameTextSize );
PutValueInLocalUnits( *m_SheetNameSize, m_CurrentSheet->m_SheetNameSize,
m_Parent->m_InternalUnits );
m_Parent->m_InternalUnits );
AddUnitSymbol( *m_FileNameTextSize );
PutValueInLocalUnits( *m_FileNameSize, m_CurrentSheet->m_FileNameSize,
m_Parent->m_InternalUnits );
m_Parent->m_InternalUnits );
}
......@@ -163,55 +163,55 @@ void WinEDA_SheetPropertiesFrame::CreateControls()
itemBoxSizer3->Add( itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _(
"Filename:" ), wxDefaultPosition,
wxDefaultSize, 0 );
"Filename:" ), wxDefaultPosition,
wxDefaultSize, 0 );
itemBoxSizer4->Add( itemStaticText5,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 );
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 );
m_FileNameWin =
new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T( "" ), wxDefaultPosition, wxSize( 300,
-1 ),
wxTE_PROCESS_ENTER );
-1 ),
wxTE_PROCESS_ENTER );
itemBoxSizer4->Add( m_FileNameWin, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _(
"Sheetname:" ), wxDefaultPosition,
wxDefaultSize, 0 );
"Sheetname:" ), wxDefaultPosition,
wxDefaultSize, 0 );
itemBoxSizer4->Add( itemStaticText7,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 );
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 );
m_SheetNameWin =
new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T( "" ), wxDefaultPosition, wxSize( 300,
-1 ), 0 );
-1 ), 0 );
itemBoxSizer4->Add( m_SheetNameWin, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
wxBoxSizer* itemBoxSizer9 = new wxBoxSizer( wxVERTICAL );
itemBoxSizer3->Add( itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
m_FileNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _(
"Size" ), wxDefaultPosition, wxDefaultSize, 0 );
"Size" ), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add( m_FileNameTextSize,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 );
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 );
m_FileNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T(
"" ), wxDefaultPosition, wxDefaultSize, 0 );
"" ), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add( m_FileNameSize, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
m_SheetNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _(
"Size" ), wxDefaultPosition, wxDefaultSize, 0 );
"Size" ), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add( m_SheetNameTextSize,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 );
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 );
m_SheetNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL3, _T(
"" ), wxDefaultPosition, wxDefaultSize, 0 );
"" ), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add( m_SheetNameSize, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
itemBoxSizer2->Add( 5, 5, 1, wxGROW | wxALL, 5 );
......@@ -220,12 +220,12 @@ void WinEDA_SheetPropertiesFrame::CreateControls()
itemBoxSizer2->Add( itemBoxSizer15, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 );
wxButton* itemButton16 = new wxButton( itemDialog1, wxID_CANCEL, _(
"&Cancel" ), wxDefaultPosition, wxDefaultSize, 0 );
"&Cancel" ), wxDefaultPosition, wxDefaultSize, 0 );
itemButton16->SetForegroundColour( wxColour( 0, 0, 255 ) );
itemBoxSizer15->Add( itemButton16, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
wxButton* itemButton17 = new wxButton( itemDialog1, wxID_OK, _(
"&OK" ), wxDefaultPosition, wxDefaultSize, 0 );
"&OK" ), wxDefaultPosition, wxDefaultSize, 0 );
itemButton17->SetForegroundColour( wxColour( 196, 0, 0 ) );
itemBoxSizer15->Add( itemButton17, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
......@@ -300,29 +300,36 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event )
}
ChangeFileNameExt( FileName, g_SchExtBuffer );
if ( (FileName != m_CurrentSheet->GetFileName()) )
{
msg = _("Changing a Filename can change all the schematic structure and cannot be undone" );
msg << wxT("\n");
msg << _("Ok to continue renaming?");
if( m_CurrentSheet->m_AssociatedScreen == 0 || IsOK( NULL, msg) )
{ //do not prompt on a new sheet. in fact, we should not allow a sheet to be created
//without a valid associated filename to be read from.
m_Parent->GetScreen()->ClearUndoRedoList();
m_CurrentSheet->ChangeFileName(m_Parent, FileName);
}
}
/* m_CurrentSheet->m_AssociatedScreen must be a valide screen, and the sheet must have a valid associated filename,
* so we must call m_CurrentSheet->ChangeFileName to set a filename,
* AND always when a new sheet is created ( when m_CurrentSheet->m_AssociatedScreen is null ),
* to create or set an Associated Screen
*/
if( ( FileName != m_CurrentSheet->GetFileName() )
|| ( m_CurrentSheet->m_AssociatedScreen == NULL) )
{
msg = _( "Changing a Filename can change all the schematic structure and cannot be undone" );
msg << wxT( "\n" );
msg << _( "Ok to continue renaming?" );
if( m_CurrentSheet->m_AssociatedScreen == NULL || IsOK( NULL, msg ) )
{ //do not prompt on a new sheet. in fact, we should not allow a sheet to be created
//without a valid associated filename to be read from.
m_Parent->GetScreen()->ClearUndoRedoList();
m_CurrentSheet->ChangeFileName( m_Parent, FileName ); // set filename and the associated screen
}
}
msg = m_FileNameSize->GetValue();
m_CurrentSheet->m_FileNameSize =
ReturnValueFromString( g_UnitMetric,
msg, m_Parent->m_InternalUnits );
msg, m_Parent->m_InternalUnits );
m_CurrentSheet->m_SheetName = m_SheetNameWin->GetValue();
msg = m_SheetNameSize->GetValue();
m_CurrentSheet->m_SheetNameSize =
ReturnValueFromString( g_UnitMetric,
msg, m_Parent->m_InternalUnits );
msg, m_Parent->m_InternalUnits );
if( ( m_CurrentSheet->m_SheetName.IsEmpty() ) )
{
......@@ -422,8 +429,8 @@ void WinEDA_SchematicFrame::ReSizeSheet( DrawSheetStruct* Sheet, wxDC* DC )
while( sheetlabel )
{
s_SheetMindx = MAX( s_SheetMindx,
(int) ( (sheetlabel->GetLength() +
1) * sheetlabel->m_Size.x ) );
(int) ( (sheetlabel->GetLength() +
1) * sheetlabel->m_Size.x ) );
s_SheetMindy = MAX( s_SheetMindy, sheetlabel->m_Pos.y - Sheet->m_Pos.y );
sheetlabel = (DrawSheetLabelStruct*) sheetlabel->Pnext;
}
......@@ -475,9 +482,9 @@ static void DeplaceSheet( WinEDA_DrawPanel* panel, wxDC* DC, bool erase )
if( Sheet->m_Flags & IS_RESIZED )
{
Sheet->m_Size.x = MAX( s_SheetMindx,
screen->m_Curseur.x - Sheet->m_Pos.x );
screen->m_Curseur.x - Sheet->m_Pos.x );
Sheet->m_Size.y = MAX( s_SheetMindy,
screen->m_Curseur.y - Sheet->m_Pos.y );
screen->m_Curseur.y - Sheet->m_Pos.y );
SheetLabel = Sheet->m_Label;
while( SheetLabel )
{
......
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