Commit 4537ac8c authored by charras's avatar charras

Fixed cvpcb crash (only when compiled in Debug version)

parent f7452ce1
...@@ -62,6 +62,12 @@ WinEDA_DisplayFrame::WinEDA_DisplayFrame( WinEDA_CvpcbFrame* father, ...@@ -62,6 +62,12 @@ WinEDA_DisplayFrame::WinEDA_DisplayFrame( WinEDA_CvpcbFrame* father,
SetBaseScreen( new PCB_SCREEN() ); SetBaseScreen( new PCB_SCREEN() );
LoadSettings(); LoadSettings();
// Initialize some display options
DisplayOpt.DisplayPadIsol = false; // Pad clearance has no meaning here
DisplayOpt.ShowTrackClearanceMode = 0; // tracks and vias clearance has no meaning here
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y ); SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
ReCreateHToolbar(); ReCreateHToolbar();
ReCreateVToolbar(); ReCreateVToolbar();
......
...@@ -119,7 +119,6 @@ found in the default search paths." ), ...@@ -119,7 +119,6 @@ found in the default search paths." ),
if( stricmp( Name, CONV_TO_UTF8( CmpName ) ) == 0 ) /* composant localise */ if( stricmp( Name, CONV_TO_UTF8( CmpName ) ) == 0 ) /* composant localise */
{ {
Module = new MODULE( GetBoard() ); Module = new MODULE( GetBoard() );
// Switch the locale to standard C (needed to print floating point numbers like 1.3) // Switch the locale to standard C (needed to print floating point numbers like 1.3)
SetLocaleTo_C_standard(); SetLocaleTo_C_standard();
Module->ReadDescr( file, &LineNum ); Module->ReadDescr( file, &LineNum );
......
...@@ -74,6 +74,10 @@ bool WinEDA_App::OnInit() ...@@ -74,6 +74,10 @@ bool WinEDA_App::OnInit()
frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() ); frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() );
frame->SetBoard( new BOARD( NULL, frame ) ); frame->SetBoard( new BOARD( NULL, frame ) );
// Initialize some display options
DisplayOpt.DisplayPadIsol = false; // Pad clearance has no meaning here
DisplayOpt.ShowTrackClearanceMode = 0; // tracks and vias clearance has no meaning here
SetTopWindow( frame ); // Set GerbView mainframe on top SetTopWindow( frame ); // Set GerbView mainframe on top
frame->Show( TRUE ); // Show GerbView mainframe frame->Show( TRUE ); // Show GerbView mainframe
frame->Zoom_Automatique( TRUE ); // Zoomfit drawing in frame frame->Zoom_Automatique( TRUE ); // Zoomfit drawing in frame
......
No preview for this file type
This diff is collapsed.
...@@ -74,8 +74,8 @@ int BOARD_CONNECTED_ITEM::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const ...@@ -74,8 +74,8 @@ int BOARD_CONNECTED_ITEM::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
{ {
NETCLASS* myclass = GetNetClass(); NETCLASS* myclass = GetNetClass();
wxASSERT( myclass ); // DO NOT use wxASSERT, because GetClearance is called inside an OnPaint event
// and a call to wxASSERT can crash the application.
if( myclass ) if( myclass )
{ {
// @todo : after GetNetClass() is reliably not returning NULL, remove the // @todo : after GetNetClass() is reliably not returning NULL, remove the
...@@ -84,18 +84,20 @@ int BOARD_CONNECTED_ITEM::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const ...@@ -84,18 +84,20 @@ int BOARD_CONNECTED_ITEM::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
if( aItem ) if( aItem )
{ {
NETCLASS* hisclass = aItem->GetNetClass(); NETCLASS* hisclass = aItem->GetNetClass();
wxASSERT( hisclass );
if( hisclass ) if( hisclass )
{ {
int hisClearance = hisclass->GetClearance(); int hisClearance = hisclass->GetClearance();
int myClearance = myclass->GetClearance(); int myClearance = myclass->GetClearance();
return max( hisClearance, myClearance ); return max( hisClearance, myClearance );
} }
else
wxLogWarning(wxT("BOARD_CONNECTED_ITEM::GetClearance(): NULL hisclass") );
} }
return myclass->GetClearance(); return myclass->GetClearance();
} }
else
wxLogWarning(wxT("BOARD_CONNECTED_ITEM::GetClearance(): NULL netclass") );
return 0; return 0;
} }
...@@ -105,20 +107,24 @@ NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const ...@@ -105,20 +107,24 @@ NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const
{ {
// It is important that this be implemented without any sequential searching. // It is important that this be implemented without any sequential searching.
// Simple array lookups should be fine, performance-wise. // Simple array lookups should be fine, performance-wise.
BOARD* board = GetBoard(); BOARD* board = GetBoard();
wxASSERT( board ); // DO NOT use wxASSERT, because GetNetClass is called inside an OnPaint event
// and a call to wxASSERT can crash the application.
if( board ) if( board )
{ {
NETINFO_ITEM* net = board->FindNet( GetNet() ); NETINFO_ITEM* net = board->FindNet( GetNet() );
wxASSERT( net );
if( net ) if( net )
{ {
NETCLASS* netclass = net->GetNetClass(); NETCLASS* netclass = net->GetNetClass();
wxASSERT( netclass ); if( netclass == NULL )
wxLogWarning(wxT("BOARD_CONNECTED_ITEM::GetNetClass(): NULL netclass") );
return netclass; return netclass;
} }
else
wxLogWarning(wxT("BOARD_CONNECTED_ITEM::GetNetClass(): NULL net") );
} }
else
wxLogWarning(wxT("BOARD_CONNECTED_ITEM::GetNetClass(): NULL board, type %d"), Type() );
return NULL; return NULL;
} }
...@@ -38,9 +38,6 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin ...@@ -38,9 +38,6 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
if( m_Flags & DO_NOT_DRAW ) if( m_Flags & DO_NOT_DRAW )
return; return;
wxASSERT( panel );
WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) panel->m_Parent; WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) panel->m_Parent;
PCB_SCREEN* screen = frame->GetScreen(); PCB_SCREEN* screen = frame->GetScreen();
if( frame->m_DisplayPadFill == FILLED ) if( frame->m_DisplayPadFill == FILLED )
...@@ -205,9 +202,14 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin ...@@ -205,9 +202,14 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
if( ( m_Masque_Layer & ALL_CU_LAYERS ) == 0 ) if( ( m_Masque_Layer & ALL_CU_LAYERS ) == 0 )
DisplayIsol = FALSE; DisplayIsol = FALSE;
SetAlpha(&color, 170); SetAlpha( &color, 170 );
int padClearance = GetClearance(); /* Get the pad clearance. This has a meaning only for Pcbnew.
* for Cvpcb (and Gerbview) GetClearance() creates debug errors because there is no
* net classes so a call to GetClearance() is made only when needed
* (never needed in Cvpcb nor in Gerbview)
*/
int padClearance = DisplayIsol ? GetClearance() : 0;
switch( GetShape() ) switch( GetShape() )
{ {
...@@ -423,7 +425,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin ...@@ -423,7 +425,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
wxPoint tpos = tpos0; wxPoint tpos = tpos0;
wxSize AreaSize; // size of text area, normalized to AreaSize.y < AreaSize.x wxSize AreaSize; // size of text area, normalized to AreaSize.y < AreaSize.x
int shortname_len = m_ShortNetname.Len(); int shortname_len = m_ShortNetname.Len();
if( ! display_netname ) if( !display_netname )
shortname_len = 0; shortname_len = 0;
if( GetShape() == PAD_CIRCLE ) if( GetShape() == PAD_CIRCLE )
angle = 0; angle = 0;
...@@ -466,11 +468,13 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin ...@@ -466,11 +468,13 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
#define CHAR_SIZE_MIN 5 #define CHAR_SIZE_MIN 5
if( screen->Scale( tsize ) >= CHAR_SIZE_MIN ) // Not drawable when size too small. if( screen->Scale( tsize ) >= CHAR_SIZE_MIN ) // Not drawable when size too small.
{ {
tsize = (int) (tsize * 0.8); // reserve room for marges and segments thickness tsize = (int) ( tsize * 0.8 ); // reserve room for marges and segments thickness
DrawGraphicText( panel, DC, tpos, DrawGraphicText( panel, DC, tpos,
WHITE, buffer, t_angle, wxSize( tsize, tsize ), WHITE, buffer, t_angle, wxSize( tsize,
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false, false, false ); tsize ),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false,
false, false );
} }
} }
...@@ -483,14 +487,14 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin ...@@ -483,14 +487,14 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
if( screen->Scale( tsize ) >= CHAR_SIZE_MIN ) // Not drawable in size too small. if( screen->Scale( tsize ) >= CHAR_SIZE_MIN ) // Not drawable in size too small.
{ {
if( !(!IsOnLayer( screen->m_Active_Layer )&& DisplayOpt.ContrastModeDisplay)){ if( !(!IsOnLayer( screen->m_Active_Layer )&& DisplayOpt.ContrastModeDisplay) )
{
tpos = tpos0; tpos = tpos0;
if ( display_padnum ) if( display_padnum )
tpos.y += AreaSize.y / 2; tpos.y += AreaSize.y / 2;
RotatePoint( &tpos, wxPoint( ux0, uy0 ), angle ); RotatePoint( &tpos, wxPoint( ux0, uy0 ), angle );
tsize = (int) (tsize * 0.8); // reserve room for marges and segments thickness tsize = (int) ( tsize * 0.8 ); // reserve room for marges and segments thickness
DrawGraphicText( panel, DC, tpos, DrawGraphicText( panel, DC, tpos,
WHITE, m_ShortNetname, t_angle, wxSize( tsize, tsize ), WHITE, m_ShortNetname, t_angle, wxSize( tsize, tsize ),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7,
......
...@@ -481,7 +481,9 @@ int CPolyLine::MakeKboolPoly( int aStart_contour, int aEnd_contour, std::vector< ...@@ -481,7 +481,9 @@ int CPolyLine::MakeKboolPoly( int aStart_contour, int aEnd_contour, std::vector<
} }
if( n_vertices != ivtx ) if( n_vertices != ivtx )
{
wxASSERT( 0 ); wxASSERT( 0 );
}
// close list added to the bool engine // close list added to the bool engine
booleng->EndPolygonAdd(); booleng->EndPolygonAdd();
...@@ -795,7 +797,9 @@ void CPolyLine::AppendCorner( int x, int y, int style, bool bDraw ) ...@@ -795,7 +797,9 @@ void CPolyLine::AppendCorner( int x, int y, int style, bool bDraw )
void CPolyLine::Close( int style, bool bDraw ) void CPolyLine::Close( int style, bool bDraw )
{ {
if( GetClosed() ) if( GetClosed() )
{
wxASSERT( 0 ); wxASSERT( 0 );
}
Undraw(); Undraw();
side_style[corner.size() - 1] = style; side_style[corner.size() - 1] = style;
corner[corner.size() - 1].end_contour = TRUE; corner[corner.size() - 1].end_contour = TRUE;
...@@ -1349,7 +1353,9 @@ void CPolyLine::Hatch() ...@@ -1349,7 +1353,9 @@ void CPolyLine::Hatch()
bool CPolyLine::TestPointInside( int px, int py ) bool CPolyLine::TestPointInside( int px, int py )
{ {
if( !GetClosed() ) if( !GetClosed() )
{
wxASSERT( 0 ); wxASSERT( 0 );
}
// define line passing through (x,y), with slope = 2/3; // define line passing through (x,y), with slope = 2/3;
// get intersection points // get intersection points
...@@ -1426,7 +1432,9 @@ bool CPolyLine::TestPointInsideContour( int icont, int px, int py ) ...@@ -1426,7 +1432,9 @@ bool CPolyLine::TestPointInsideContour( int icont, int px, int py )
if( icont >= GetNumContours() ) if( icont >= GetNumContours() )
return FALSE; return FALSE;
if( !GetClosed() ) if( !GetClosed() )
{
wxASSERT( 0 ); wxASSERT( 0 );
}
// define line passing through (x,y), with slope = 2/3; // define line passing through (x,y), with slope = 2/3;
// get intersection points // get intersection points
......
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