Fixed cvpcb crash (only when compiled in Debug version)

This commit is contained in:
charras 2009-09-19 16:15:40 +00:00
parent f7452ce131
commit 4537ac8c99
8 changed files with 2565 additions and 2306 deletions

View File

@ -62,6 +62,12 @@ WinEDA_DisplayFrame::WinEDA_DisplayFrame( WinEDA_CvpcbFrame* father,
SetBaseScreen( new PCB_SCREEN() );
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 );
ReCreateHToolbar();
ReCreateVToolbar();

View File

@ -119,7 +119,6 @@ found in the default search paths." ),
if( stricmp( Name, CONV_TO_UTF8( CmpName ) ) == 0 ) /* composant localise */
{
Module = new MODULE( GetBoard() );
// Switch the locale to standard C (needed to print floating point numbers like 1.3)
SetLocaleTo_C_standard();
Module->ReadDescr( file, &LineNum );

View File

@ -74,6 +74,10 @@ bool WinEDA_App::OnInit()
frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() );
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
frame->Show( TRUE ); // Show GerbView mainframe
frame->Zoom_Automatique( TRUE ); // Zoomfit drawing in frame

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -74,8 +74,8 @@ int BOARD_CONNECTED_ITEM::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
{
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 )
{
// @todo : after GetNetClass() is reliably not returning NULL, remove the
@ -84,18 +84,20 @@ int BOARD_CONNECTED_ITEM::GetClearance( BOARD_CONNECTED_ITEM* aItem ) const
if( aItem )
{
NETCLASS* hisclass = aItem->GetNetClass();
wxASSERT( hisclass );
if( hisclass )
{
int hisClearance = hisclass->GetClearance();
int myClearance = myclass->GetClearance();
return max( hisClearance, myClearance );
}
else
wxLogWarning(wxT("BOARD_CONNECTED_ITEM::GetClearance(): NULL hisclass") );
}
return myclass->GetClearance();
}
else
wxLogWarning(wxT("BOARD_CONNECTED_ITEM::GetClearance(): NULL netclass") );
return 0;
}
@ -105,20 +107,24 @@ NETCLASS* BOARD_CONNECTED_ITEM::GetNetClass() const
{
// It is important that this be implemented without any sequential searching.
// Simple array lookups should be fine, performance-wise.
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 )
{
NETINFO_ITEM* net = board->FindNet( GetNet() );
wxASSERT( net );
if( net )
{
NETCLASS* netclass = net->GetNetClass();
wxASSERT( netclass );
if( netclass == NULL )
wxLogWarning(wxT("BOARD_CONNECTED_ITEM::GetNetClass(): NULL 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;
}

View File

@ -38,9 +38,6 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
if( m_Flags & DO_NOT_DRAW )
return;
wxASSERT( panel );
WinEDA_BasePcbFrame* frame = (WinEDA_BasePcbFrame*) panel->m_Parent;
PCB_SCREEN* screen = frame->GetScreen();
if( frame->m_DisplayPadFill == FILLED )
@ -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 )
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() )
{
@ -423,7 +425,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
wxPoint tpos = tpos0;
wxSize AreaSize; // size of text area, normalized to AreaSize.y < AreaSize.x
int shortname_len = m_ShortNetname.Len();
if( ! display_netname )
if( !display_netname )
shortname_len = 0;
if( GetShape() == PAD_CIRCLE )
angle = 0;
@ -455,7 +457,7 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
#define MIN_CHAR_COUNT 3
wxString buffer;
int tsize;
int tsize;
if( display_padnum )
{
ReturnStringPadName( buffer );
@ -464,13 +466,15 @@ void D_PAD::Draw( WinEDA_DrawPanel* panel, wxDC* DC, int draw_mode, const wxPoin
tsize = min( AreaSize.y, AreaSize.x / numpad_len );
#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,
WHITE, buffer, t_angle, wxSize( tsize, tsize ),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false, false, false );
WHITE, buffer, t_angle, wxSize( tsize,
tsize ),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7, false,
false, false );
}
}
@ -483,18 +487,18 @@ 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( !(!IsOnLayer( screen->m_Active_Layer )&& DisplayOpt.ContrastModeDisplay)){
if( !(!IsOnLayer( screen->m_Active_Layer )&& DisplayOpt.ContrastModeDisplay) )
{
tpos = tpos0;
if( display_padnum )
tpos.y += AreaSize.y / 2;
RotatePoint( &tpos, wxPoint( ux0, uy0 ), angle );
tpos = tpos0;
if ( display_padnum )
tpos.y += AreaSize.y / 2;
RotatePoint( &tpos, wxPoint( ux0, uy0 ), angle );
tsize = (int) (tsize * 0.8); // reserve room for marges and segments thickness
DrawGraphicText( panel, DC, tpos,
WHITE, m_ShortNetname, t_angle, wxSize( tsize, tsize ),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7,
false, false );
}
tsize = (int) ( tsize * 0.8 ); // reserve room for marges and segments thickness
DrawGraphicText( panel, DC, tpos,
WHITE, m_ShortNetname, t_angle, wxSize( tsize, tsize ),
GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, tsize / 7,
false, false );
}
}
}

View File

@ -481,7 +481,9 @@ int CPolyLine::MakeKboolPoly( int aStart_contour, int aEnd_contour, std::vector<
}
if( n_vertices != ivtx )
{
wxASSERT( 0 );
}
// close list added to the bool engine
booleng->EndPolygonAdd();
@ -795,7 +797,9 @@ void CPolyLine::AppendCorner( int x, int y, int style, bool bDraw )
void CPolyLine::Close( int style, bool bDraw )
{
if( GetClosed() )
{
wxASSERT( 0 );
}
Undraw();
side_style[corner.size() - 1] = style;
corner[corner.size() - 1].end_contour = TRUE;
@ -1349,7 +1353,9 @@ void CPolyLine::Hatch()
bool CPolyLine::TestPointInside( int px, int py )
{
if( !GetClosed() )
{
wxASSERT( 0 );
}
// define line passing through (x,y), with slope = 2/3;
// get intersection points
@ -1426,7 +1432,9 @@ bool CPolyLine::TestPointInsideContour( int icont, int px, int py )
if( icont >= GetNumContours() )
return FALSE;
if( !GetClosed() )
{
wxASSERT( 0 );
}
// define line passing through (x,y), with slope = 2/3;
// get intersection points