Commit 29ed370a authored by CHARRAS's avatar CHARRAS

Fixed: problem which could crash eeschema when a schematic file in a hierarchy was not found

parent 879e1b5b
...@@ -68,9 +68,9 @@ IMPLEMENT_DYNAMIC_CLASS( WinEDA_SheetPropertiesFrame, wxDialog ) ...@@ -68,9 +68,9 @@ IMPLEMENT_DYNAMIC_CLASS( WinEDA_SheetPropertiesFrame, wxDialog )
BEGIN_EVENT_TABLE( WinEDA_SheetPropertiesFrame, wxDialog ) BEGIN_EVENT_TABLE( WinEDA_SheetPropertiesFrame, wxDialog )
////@begin WinEDA_SheetPropertiesFrame event table entries ////@begin WinEDA_SheetPropertiesFrame event table entries
EVT_BUTTON( wxID_CANCEL, WinEDA_SheetPropertiesFrame::OnCancelClick ) EVT_BUTTON( wxID_CANCEL, WinEDA_SheetPropertiesFrame::OnCancelClick )
EVT_BUTTON( wxID_OK, WinEDA_SheetPropertiesFrame::OnOkClick ) EVT_BUTTON( wxID_OK, WinEDA_SheetPropertiesFrame::OnOkClick )
////@end WinEDA_SheetPropertiesFrame event table entries ////@end WinEDA_SheetPropertiesFrame event table entries
...@@ -115,24 +115,26 @@ bool WinEDA_SheetPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const ...@@ -115,24 +115,26 @@ bool WinEDA_SheetPropertiesFrame::Create( wxWindow* parent, wxWindowID id, const
const wxPoint& pos, const wxSize& size, long style ) const wxPoint& pos, const wxSize& size, long style )
{ {
////@begin WinEDA_SheetPropertiesFrame member initialisation ////@begin WinEDA_SheetPropertiesFrame member initialisation
m_FileNameWin = NULL; m_FileNameWin = NULL;
m_SheetNameWin = NULL; m_SheetNameWin = NULL;
m_FileNameTextSize = NULL; m_FileNameTextSize = NULL;
m_FileNameSize = NULL; m_FileNameSize = NULL;
m_SheetNameTextSize = NULL; m_SheetNameTextSize = NULL;
m_SheetNameSize = NULL; m_SheetNameSize = NULL;
////@end WinEDA_SheetPropertiesFrame member initialisation ////@end WinEDA_SheetPropertiesFrame member initialisation
////@begin WinEDA_SheetPropertiesFrame creation ////@begin WinEDA_SheetPropertiesFrame creation
SetExtraStyle(wxWS_EX_BLOCK_EVENTS); SetExtraStyle( wxWS_EX_BLOCK_EVENTS );
wxDialog::Create( parent, id, caption, pos, size, style ); wxDialog::Create( parent, id, caption, pos, size, style );
CreateControls(); CreateControls();
if (GetSizer()) if( GetSizer() )
{ {
GetSizer()->SetSizeHints(this); GetSizer()->SetSizeHints( this );
} }
Centre(); Centre();
////@end WinEDA_SheetPropertiesFrame creation ////@end WinEDA_SheetPropertiesFrame creation
return true; return true;
} }
...@@ -151,60 +153,85 @@ void WinEDA_SheetPropertiesFrame::CreateControls() ...@@ -151,60 +153,85 @@ void WinEDA_SheetPropertiesFrame::CreateControls()
WinEDA_SheetPropertiesFrame* itemDialog1 = this; WinEDA_SheetPropertiesFrame* itemDialog1 = this;
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL); wxBoxSizer* itemBoxSizer2 = new wxBoxSizer( wxVERTICAL );
itemDialog1->SetSizer(itemBoxSizer2); itemDialog1->SetSizer( itemBoxSizer2 );
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* itemBoxSizer3 = new wxBoxSizer( wxHORIZONTAL );
itemBoxSizer2->Add(itemBoxSizer3, 0, wxGROW|wxALL, 5); itemBoxSizer2->Add( itemBoxSizer3, 0, wxGROW | wxALL, 5 );
wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxVERTICAL); wxBoxSizer* itemBoxSizer4 = new wxBoxSizer( wxVERTICAL );
itemBoxSizer3->Add(itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); itemBoxSizer3->Add( itemBoxSizer4, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _("Filename:"), wxDefaultPosition, wxDefaultSize, 0 ); wxStaticText* itemStaticText5 = new wxStaticText( itemDialog1, wxID_STATIC, _(
itemBoxSizer4->Add(itemStaticText5, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); "Filename:" ), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer4->Add( itemStaticText5,
m_FileNameWin = new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T(""), wxDefaultPosition, wxSize(300, -1), wxTE_PROCESS_ENTER ); 0,
itemBoxSizer4->Add(m_FileNameWin, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 );
wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _("Sheetname:"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer4->Add(itemStaticText7, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); m_FileNameWin =
new wxTextCtrl( itemDialog1, ID_TEXTCTRL1, _T( "" ), wxDefaultPosition, wxSize( 300,
m_SheetNameWin = new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T(""), wxDefaultPosition, wxSize(300, -1), 0 ); -1 ), wxTE_PROCESS_ENTER );
itemBoxSizer4->Add(m_SheetNameWin, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); itemBoxSizer4->Add( m_FileNameWin, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
wxBoxSizer* itemBoxSizer9 = new wxBoxSizer(wxVERTICAL); wxStaticText* itemStaticText7 = new wxStaticText( itemDialog1, wxID_STATIC, _(
itemBoxSizer3->Add(itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); "Sheetname:" ), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer4->Add( itemStaticText7,
m_FileNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _("Size"), wxDefaultPosition, wxDefaultSize, 0 ); 0,
itemBoxSizer9->Add(m_FileNameTextSize, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 );
m_FileNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add(m_FileNameSize, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); m_SheetNameWin =
new wxTextCtrl( itemDialog1, ID_TEXTCTRL, _T( "" ), wxDefaultPosition, wxSize( 300,
m_SheetNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _("Size"), wxDefaultPosition, wxDefaultSize, 0 ); -1 ), 0 );
itemBoxSizer9->Add(m_SheetNameTextSize, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxTOP|wxADJUST_MINSIZE, 5); itemBoxSizer4->Add( m_SheetNameWin, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
m_SheetNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL3, _T(""), wxDefaultPosition, wxDefaultSize, 0 ); wxBoxSizer* itemBoxSizer9 = new wxBoxSizer( wxVERTICAL );
itemBoxSizer9->Add(m_SheetNameSize, 0, wxALIGN_LEFT|wxLEFT|wxRIGHT|wxBOTTOM, 5); itemBoxSizer3->Add( itemBoxSizer9, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
itemBoxSizer2->Add(5, 5, 1, wxGROW|wxALL, 5); m_FileNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _(
"Size" ), wxDefaultPosition, wxDefaultSize, 0 );
wxBoxSizer* itemBoxSizer15 = new wxBoxSizer(wxHORIZONTAL); itemBoxSizer9->Add( m_FileNameTextSize,
itemBoxSizer2->Add(itemBoxSizer15, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5); 0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
wxButton* itemButton16 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 ); 5 );
itemButton16->SetForegroundColour(wxColour(0, 0, 255));
itemBoxSizer15->Add(itemButton16, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); m_FileNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL2, _T(
"" ), wxDefaultPosition, wxDefaultSize, 0 );
wxButton* itemButton17 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 ); itemBoxSizer9->Add( m_FileNameSize, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
itemButton17->SetForegroundColour(wxColour(196, 0, 0));
itemBoxSizer15->Add(itemButton17, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5); m_SheetNameTextSize = new wxStaticText( itemDialog1, wxID_STATIC, _(
"Size" ), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add( m_SheetNameTextSize,
0,
wxALIGN_LEFT | wxLEFT | wxRIGHT | wxTOP | wxADJUST_MINSIZE,
5 );
m_SheetNameSize = new wxTextCtrl( itemDialog1, ID_TEXTCTRL3, _T(
"" ), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer9->Add( m_SheetNameSize, 0, wxALIGN_LEFT | wxLEFT | wxRIGHT | wxBOTTOM, 5 );
itemBoxSizer2->Add( 5, 5, 1, wxGROW | wxALL, 5 );
wxBoxSizer* itemBoxSizer15 = new wxBoxSizer( wxHORIZONTAL );
itemBoxSizer2->Add( itemBoxSizer15, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5 );
wxButton* itemButton16 = new wxButton( itemDialog1, wxID_CANCEL, _(
"&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 );
itemButton17->SetForegroundColour( wxColour( 196, 0, 0 ) );
itemBoxSizer15->Add( itemButton17, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
// Set validators // Set validators
m_SheetNameWin->SetValidator( wxTextValidator(wxFILTER_NONE, & m_CurrentSheet->m_SheetName) ); m_SheetNameWin->SetValidator( wxTextValidator( wxFILTER_NONE, &m_CurrentSheet->m_SheetName ) );
////@end WinEDA_SheetPropertiesFrame content construction ////@end WinEDA_SheetPropertiesFrame content construction
m_FileNameWin->SetValue( m_CurrentSheet->GetFileName()); m_FileNameWin->SetValue( m_CurrentSheet->GetFileName() );
} }
...@@ -226,8 +253,9 @@ wxBitmap WinEDA_SheetPropertiesFrame::GetBitmapResource( const wxString& name ) ...@@ -226,8 +253,9 @@ wxBitmap WinEDA_SheetPropertiesFrame::GetBitmapResource( const wxString& name )
{ {
// Bitmap retrieval // Bitmap retrieval
////@begin WinEDA_SheetPropertiesFrame bitmap retrieval ////@begin WinEDA_SheetPropertiesFrame bitmap retrieval
wxUnusedVar(name); wxUnusedVar( name );
return wxNullBitmap; return wxNullBitmap;
////@end WinEDA_SheetPropertiesFrame bitmap retrieval ////@end WinEDA_SheetPropertiesFrame bitmap retrieval
} }
...@@ -240,8 +268,9 @@ wxIcon WinEDA_SheetPropertiesFrame::GetIconResource( const wxString& name ) ...@@ -240,8 +268,9 @@ wxIcon WinEDA_SheetPropertiesFrame::GetIconResource( const wxString& name )
{ {
// Icon retrieval // Icon retrieval
////@begin WinEDA_SheetPropertiesFrame icon retrieval ////@begin WinEDA_SheetPropertiesFrame icon retrieval
wxUnusedVar(name); wxUnusedVar( name );
return wxNullIcon; return wxNullIcon;
////@end WinEDA_SheetPropertiesFrame icon retrieval ////@end WinEDA_SheetPropertiesFrame icon retrieval
} }
...@@ -264,9 +293,11 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event ) ...@@ -264,9 +293,11 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event )
ChangeFileNameExt( FileName, g_SchExtBuffer ); ChangeFileNameExt( FileName, g_SchExtBuffer );
if( m_CurrentSheet->GetFileName() != FileName ) if( (m_CurrentSheet->GetFileName() != FileName)
|| (m_CurrentSheet->m_Flags & IS_NEW)
|| !m_CurrentSheet->m_AssociatedScreen )
{ {
m_CurrentSheet->SetFileName(FileName); m_CurrentSheet->SetFileName( FileName );
if( wxFileExists( FileName ) ) //do we reload the data from the existing file if( wxFileExists( FileName ) ) //do we reload the data from the existing file
{ {
...@@ -309,9 +340,9 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event ) ...@@ -309,9 +340,9 @@ void WinEDA_SheetPropertiesFrame::SheetPropertiesAccept( wxCommandEvent& event )
msg, m_Parent->m_InternalUnits ); msg, m_Parent->m_InternalUnits );
if( ( m_CurrentSheet->m_SheetName.IsEmpty() ) ) if( ( m_CurrentSheet->m_SheetName.IsEmpty() ) )
{ {
m_CurrentSheet->m_SheetName.Printf( wxT("Sheet%8.8lX"), GetTimeStamp() ); m_CurrentSheet->m_SheetName.Printf( wxT( "Sheet%8.8lX" ), GetTimeStamp() );
} }
EndModal( TRUE ); EndModal( TRUE );
...@@ -362,7 +393,7 @@ DrawSheetStruct* WinEDA_SchematicFrame::CreateSheet( wxDC* DC ) ...@@ -362,7 +393,7 @@ DrawSheetStruct* WinEDA_SchematicFrame::CreateSheet( wxDC* DC )
s_SheetMindy = SHEET_MIN_HEIGHT; s_SheetMindy = SHEET_MIN_HEIGHT;
//need to check if this is being added to the EEDrawList. //need to check if this is being added to the EEDrawList.
//also need to update the heirarchy, if we are adding //also need to update the hierarchy, if we are adding
// a sheet to a screen that already has multiple instances (!) // a sheet to a screen that already has multiple instances (!)
GetScreen()->SetCurItem( Sheet ); GetScreen()->SetCurItem( Sheet );
......
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