Commit ae3c3b6c authored by charras's avatar charras

pcbnew: solved a bug which crashes pcbnew when creating a new module with no reference.

parent 52340497
No preview for this file type
This diff is collapsed.
...@@ -706,10 +706,10 @@ int WinEDA_BasePcbFrame::Save_1_Module( const wxString& LibName, ...@@ -706,10 +706,10 @@ int WinEDA_BasePcbFrame::Save_1_Module( const wxString& LibName,
MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, const wxString& module_name ) MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, const wxString& module_name )
/************************************************************************************/ /************************************************************************************/
/* Creation d'un module : On place d'office les 2ers textes : /* Create a new module or footprint : A new module is tartted with 2 texts :
* 1er = type REF: nom du module * First = REFERENCE
* 2eme = type VALEUR: "VAL**" * Second = VALUE: "VAL**"
* Le module est insere en debut de liste des modules * the new module is added on begining of the linked list of modules
*/ */
{ {
...@@ -717,7 +717,7 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, const wxString& module_n ...@@ -717,7 +717,7 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, const wxString& module_n
wxString Line; wxString Line;
wxPoint newpos; wxPoint newpos;
/* Demande du nom du nouveau module */ /* Ask fo the new module reference */
if( module_name.IsEmpty() ) if( module_name.IsEmpty() )
{ {
if( Get_Message( _( "Module Reference:" ), _("Create module"), Line, this ) != 0 ) if( Get_Message( _( "Module Reference:" ), _("Create module"), Line, this ) != 0 )
...@@ -728,6 +728,7 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, const wxString& module_n ...@@ -728,6 +728,7 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, const wxString& module_n
Line.Trim( TRUE ); Line.Trim( TRUE );
Line.Trim( FALSE ); Line.Trim( FALSE );
// Creates the new module and add it to te bigenning of the linked list of modules
Module = new MODULE( m_Pcb ); Module = new MODULE( m_Pcb );
Module->Pnext = m_Pcb->m_Modules; Module->Pnext = m_Pcb->m_Modules;
...@@ -738,28 +739,26 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, const wxString& module_n ...@@ -738,28 +739,26 @@ MODULE* WinEDA_BasePcbFrame::Create_1_Module( wxDC* DC, const wxString& module_n
} }
m_Pcb->m_Modules = Module; m_Pcb->m_Modules = Module;
/* Creation du module : On place d'office les 2 textes ref et val : /* Update parameters: position, timestamp ... */
* 1er = type REF: nom du module
* 2eme = type VALEUR: "VAL**" */
/* Mise a jour des caract du nouveau module */
newpos = GetScreen()->m_Curseur; newpos = GetScreen()->m_Curseur;
Module->SetPosition( newpos ); Module->SetPosition( newpos );
Module->m_LastEdit_Time = time( NULL ); Module->m_LastEdit_Time = time( NULL );
/* Mise a jour du nom de Librairie (reference libr) */ /* Update its name in lib */
Module->m_LibRef = Line; Module->m_LibRef = Line;
/* Mise a jour de la reference: */ /* Update reference: */
Module->m_Reference->m_Text = Line; Module->m_Reference->m_Text = Line;
Module->m_Reference->SetWidth( ModuleTextWidth ); Module->m_Reference->SetWidth( ModuleTextWidth );
Module->m_Reference->m_Size = ModuleTextSize; Module->m_Reference->m_Size = ModuleTextSize;
/* mise a jour de la valeurs */ /* Set the value field to a default value */
Module->m_Value->m_Text = wxT( "VAL**" ); Module->m_Value->m_Text = wxT( "VAL**" );
Module->m_Value->SetWidth( ModuleTextWidth ); Module->m_Value->SetWidth( ModuleTextWidth );
Module->m_Value->m_Size = ModuleTextSize; Module->m_Value->m_Size = ModuleTextSize;
Module->SetPosition( wxPoint(0, 0) );
Module->Display_Infos( this ); Module->Display_Infos( this );
return Module; return Module;
} }
......
...@@ -215,12 +215,13 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event ) ...@@ -215,12 +215,13 @@ void WinEDA_ModuleEditFrame::Process_Special_Functions( wxCommandEvent& event )
GetScreen()->m_Curseur = wxPoint( 0, 0 ); GetScreen()->m_Curseur = wxPoint( 0, 0 );
MODULE* module = Create_1_Module( &dc, wxEmptyString ); MODULE* module = Create_1_Module( &dc, wxEmptyString );
wxASSERT( module ); if ( module ) // i.e. if create module command not aborted
module->SetPosition( wxPoint(0, 0) ); {
module->SetPosition( wxPoint(0, 0) );
if( m_Pcb->m_Modules ) if( m_Pcb->m_Modules )
m_Pcb->m_Modules->m_Flags = 0; m_Pcb->m_Modules->m_Flags = 0;
Zoom_Automatique( TRUE ); Zoom_Automatique( TRUE );
}
} }
break; break;
......
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