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 ...@@ -5,6 +5,15 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. 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> 2008-Mar-30 UPDATE Jonas Diemer <diemer-at-gmx.de>
================================================================================ ================================================================================
+eeschema +eeschema
......
...@@ -32,6 +32,37 @@ ...@@ -32,6 +32,37 @@
#include "wxstruct.h" #include "wxstruct.h"
#include "macros.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 // Path list for online help
static wxString s_HelpPathList[] = { static wxString s_HelpPathList[] = {
...@@ -43,7 +74,7 @@ static wxString s_HelpPathList[] = { ...@@ -43,7 +74,7 @@ static wxString s_HelpPathList[] = {
#else #else
wxT( "/usr/share/doc/kicad/help/" ), wxT( "/usr/share/doc/kicad/help/" ),
wxT( "/usr/local/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 #endif
wxT( "end_list" ) // End of list symbol, do not change wxT( "end_list" ) // End of list symbol, do not change
}; };
...@@ -51,19 +82,18 @@ static wxString s_HelpPathList[] = { ...@@ -51,19 +82,18 @@ static wxString s_HelpPathList[] = {
// Path list for kicad data files // Path list for kicad data files
static wxString s_KicadDataPathList[] = { static wxString s_KicadDataPathList[] = {
#ifdef __WINDOWS__ #ifdef __WINDOWS__
wxT( "c:/kicad/" ), // TODO: must be removed wxT( "c:/kicad/" ),
wxT( "d:/kicad/" ), // TODO: must be removed wxT( "d:/kicad/" ),
wxT( "c:/kicad/share/" ), wxT( "c:/kicad/share/" ),
wxT( "d:/kicad/share/" ), wxT( "d:/kicad/share/" ),
wxT( "c:/Program Files/kicad/" ), // TODO: must be removed wxT( "c:/Program Files/kicad/" ),
wxT( "d:/Program Files/kicad/" ), // TODO: must be removed wxT( "d:/Program Files/kicad/" ),
wxT( "c:/Program Files/kicad/share/" ), wxT( "c:/Program Files/kicad/share/" ),
wxT( "d:/Program Files/kicad/share/" ), wxT( "d:/Program Files/kicad/share/" ),
#else #else
wxT( "/usr/share/kicad/" ), wxT( "/usr/share/kicad/" ),
wxT( "/usr/local/share/kicad/" ), wxT( "/usr/local/share/kicad/" ),
wxT( "/usr/local/kicad/share/kicad/" ), // TODO: must be removed wxT( "/usr/local/kicad/" ), // default install for "universal tarballs" and build for a server
wxT( "/usr/local/kicad/" ), // TODO: must be removed
#endif #endif
wxT( "end_list" ) // End of list symbol, do not change wxT( "end_list" ) // End of list symbol, do not change
}; };
...@@ -124,6 +154,7 @@ wxString MakeReducedFileName( const wxString& fullfilename, ...@@ -124,6 +154,7 @@ wxString MakeReducedFileName( const wxString& fullfilename,
path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); path.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
#ifdef __WINDOWS__ #ifdef __WINDOWS__
// names are case insensitive under windows // names are case insensitive under windows
path.MakeLower(); path.MakeLower();
Cwd.MakeLower(); Cwd.MakeLower();
...@@ -182,7 +213,7 @@ wxString MakeFileName( const wxString& dir, ...@@ -182,7 +213,7 @@ wxString MakeFileName( const wxString& dir,
{ {
if( !wxIsAbsolutePath( shortname ) ) 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 */ { /* no absolute path in shortname, add dir to shortname */
fullfilename = dir; fullfilename = dir;
} }
...@@ -317,12 +348,13 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti ...@@ -317,12 +348,13 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti
wxSetWorkingDirectory( defaultpath ); wxSetWorkingDirectory( defaultpath );
#if 0 && defined(DEBUG) #if 0 && defined (DEBUG)
printf("defaultpath=\"%s\" defaultname=\"%s\" Ext=\"%s\" Mask=\"%s\" flag=%d keep_working_directory=%d\n", printf(
CONV_TO_UTF8(defaultpath), "defaultpath=\"%s\" defaultname=\"%s\" Ext=\"%s\" Mask=\"%s\" flag=%d keep_working_directory=%d\n",
CONV_TO_UTF8(defaultname), CONV_TO_UTF8( defaultpath ),
CONV_TO_UTF8(Ext), CONV_TO_UTF8( defaultname ),
CONV_TO_UTF8(Mask), CONV_TO_UTF8( Ext ),
CONV_TO_UTF8( Mask ),
flag, flag,
keep_working_directory keep_working_directory
); );
...@@ -333,7 +365,7 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti ...@@ -333,7 +365,7 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti
defaultname, defaultname,
Ext, Ext,
Mask, Mask,
flag,/* open mode wxFD_OPEN, wxFD_SAVE .. */ flag, /* open mode wxFD_OPEN, wxFD_SAVE .. */
Frame, Frame,
Pos.x, Pos.y ); Pos.x, Pos.y );
...@@ -347,6 +379,7 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti ...@@ -347,6 +379,7 @@ wxString EDA_FileSelector( const wxString& Title, /* Dialog ti
/********************************************************/ /********************************************************/
wxString FindKicadHelpPath() wxString FindKicadHelpPath()
/********************************************************/ /********************************************************/
/** Function FindKicadHelpPath /** Function FindKicadHelpPath
* Find an absolute path for KiCad "help" (or "help/<language>") * Find an absolute path for KiCad "help" (or "help/<language>")
* Find path kicad/doc/help/xx/ or kicad/doc/help/: * Find path kicad/doc/help/xx/ or kicad/doc/help/:
...@@ -371,6 +404,7 @@ wxString FindKicadHelpPath() ...@@ -371,6 +404,7 @@ wxString FindKicadHelpPath()
wxString FullPath, LangFullPath, tmp; wxString FullPath, LangFullPath, tmp;
wxString LocaleString; wxString LocaleString;
bool PathFound = FALSE; bool PathFound = FALSE;
/* find kicad/help/ */ /* find kicad/help/ */
tmp = g_EDA_Appl->m_BinDir; tmp = g_EDA_Appl->m_BinDir;
if( tmp.Last() == '/' ) if( tmp.Last() == '/' )
......
...@@ -372,8 +372,8 @@ bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* screen, DrawSheetPath* lis ...@@ -372,8 +372,8 @@ bool DrawSheetStruct::LocatePathOfScreen( SCH_SCREEN* screen, DrawSheetPath* lis
{ {
//search the existing hierarchy for an instance of screen "FileName". //search the existing hierarchy for an instance of screen "FileName".
//don't bother looking at the root sheet - it must be unique, //don't bother looking at the root sheet - it must be unique,
//no other references to its m_s otherwise there would be loops //no other references to its m_AssociatedScreen otherwise there would be loops
//in the heirarchy. //in the hierarchy.
//search the existing hierarchy for an instance of screen "FileName". //search the existing hierarchy for an instance of screen "FileName".
if( m_AssociatedScreen ) if( m_AssociatedScreen )
{ {
......
...@@ -300,16 +300,23 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event ) ...@@ -300,16 +300,23 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event )
} }
ChangeFileNameExt( FileName, g_SchExtBuffer ); ChangeFileNameExt( FileName, g_SchExtBuffer );
if ( (FileName != m_CurrentSheet->GetFileName()) )
/* 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 = _( "Changing a Filename can change all the schematic structure and cannot be undone" );
msg << wxT("\n"); msg << wxT( "\n" );
msg << _("Ok to continue renaming?"); msg << _( "Ok to continue renaming?" );
if( m_CurrentSheet->m_AssociatedScreen == 0 || IsOK( NULL, msg) ) 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 { //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. //without a valid associated filename to be read from.
m_Parent->GetScreen()->ClearUndoRedoList(); m_Parent->GetScreen()->ClearUndoRedoList();
m_CurrentSheet->ChangeFileName(m_Parent, FileName); m_CurrentSheet->ChangeFileName( m_Parent, FileName ); // set filename and the associated screen
} }
} }
......
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