From 00ee6c7b3bc1f99e7666c8c11854b6199194b15e Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Thu, 25 Apr 2013 09:05:33 +0200 Subject: [PATCH] Pcbnew, dialog SVG export: Fix Pcbnew crash when opening the dialog. --- 3d-viewer/3d_draw_basic_functions.cpp | 2 +- pcbnew/dialogs/dialog_SVG_print.cpp | 10 +++++----- pcbnew/dialogs/dialog_SVG_print_base.cpp | 5 ++++- pcbnew/dialogs/dialog_SVG_print_base.h | 4 +++- pcbnew/hotkeys_board_editor.cpp | 14 ++++++++------ 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/3d-viewer/3d_draw_basic_functions.cpp b/3d-viewer/3d_draw_basic_functions.cpp index 854866213f..635d3c66e1 100644 --- a/3d-viewer/3d_draw_basic_functions.cpp +++ b/3d-viewer/3d_draw_basic_functions.cpp @@ -217,7 +217,7 @@ void Draw3D_SolidHorizontalPolyPolygons( const std::vector& aPolysList, /* draw the solid polygon found in aPolysList - * The first polygonj is the main polygon, others are holes + * The first polygon is the main polygon, others are holes * See Draw3D_SolidHorizontalPolyPolygons for more info */ void Draw3D_SolidHorizontalPolygonWithHoles( const std::vector& aPolysList, diff --git a/pcbnew/dialogs/dialog_SVG_print.cpp b/pcbnew/dialogs/dialog_SVG_print.cpp index 39eab85e9d..0a962d35c5 100644 --- a/pcbnew/dialogs/dialog_SVG_print.cpp +++ b/pcbnew/dialogs/dialog_SVG_print.cpp @@ -118,11 +118,11 @@ void DIALOG_SVG_PRINT::initDialog() // (Front or Top to Back or Bottom) DECLARE_LAYERS_ORDER_LIST( layersOrder ); - for( LAYER_NUM layer_idx = FIRST_LAYER; layer_idx < NB_LAYERS; ++layer_idx ) + for( LAYER_NUM layer_idx = FIRST_LAYER; layer_idx < NB_PCB_LAYERS; ++layer_idx ) { layer = layersOrder[layer_idx]; - wxASSERT( layer < NB_LAYERS ); + wxASSERT( layer < NB_PCB_LAYERS ); if( m_boxSelectLayer[layer] == NULL ) continue; @@ -148,7 +148,7 @@ void DIALOG_SVG_PRINT::initDialog() { wxString layerKey; - for( LAYER_NUM layer = FIRST_LAYER; layer < NB_LAYERS; ++layer ) + for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer ) { bool option; @@ -237,7 +237,7 @@ void DIALOG_SVG_PRINT::ExportSVGFile( bool aOnlyOneFile ) // Build layers mask LAYER_MSK printMaskLayer = NO_LAYERS; - for( LAYER_NUM layer = FIRST_LAYER; layer < NB_LAYERS; ++layer ) + for( LAYER_NUM layer = FIRST_LAYER; layer < NB_PCB_LAYERS; ++layer ) { if( m_boxSelectLayer[layer] && m_boxSelectLayer[layer]->GetValue() ) printMaskLayer |= GetLayerMask( layer ); @@ -363,7 +363,7 @@ void DIALOG_SVG_PRINT::OnCloseWindow( wxCloseEvent& event ) wxString layerKey; - for( LAYER_NUM layer = FIRST_LAYER; layerSetMaxLength( 0 ); m_outputDirectoryName->SetToolTip( _("Enter a filename if you do not want to use default file names\nCan be used only when printing the current sheet") ); m_outputDirectoryName->SetMinSize( wxSize( 450,-1 ) ); @@ -64,6 +65,7 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c sbOptionsSizer->Add( m_TextPenWidth, 0, wxRIGHT|wxLEFT, 5 ); m_DialogDefaultPenSize = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + m_DialogDefaultPenSize->SetMaxLength( 0 ); sbOptionsSizer->Add( m_DialogDefaultPenSize, 0, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); wxString m_ModeColorOptionChoices[] = { _("Color"), _("Black and white") }; @@ -118,6 +120,7 @@ DIALOG_SVG_PRINT_base::DIALOG_SVG_PRINT_base( wxWindow* parent, wxWindowID id, c bMainSizer->Add( m_staticText2, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); m_messagesBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE ); + m_messagesBox->SetMaxLength( 0 ); m_messagesBox->SetMinSize( wxSize( -1,100 ) ); bMainSizer->Add( m_messagesBox, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 ); diff --git a/pcbnew/dialogs/dialog_SVG_print_base.h b/pcbnew/dialogs/dialog_SVG_print_base.h index bc56d76fb2..aa3e893d69 100644 --- a/pcbnew/dialogs/dialog_SVG_print_base.h +++ b/pcbnew/dialogs/dialog_SVG_print_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Apr 10 2012) +// C++ code generated with wxFormBuilder (version Oct 8 2012) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -11,6 +11,8 @@ #include #include #include +class DIALOG_SHIM; + #include "dialog_shim.h" #include #include diff --git a/pcbnew/hotkeys_board_editor.cpp b/pcbnew/hotkeys_board_editor.cpp index f1ef2fa000..0a155643f4 100644 --- a/pcbnew/hotkeys_board_editor.cpp +++ b/pcbnew/hotkeys_board_editor.cpp @@ -170,8 +170,10 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit if( GetCanvas()->IsMouseCaptured() ) GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false ); - GetBoard()->SetTrackWidthIndex( ( GetBoard()->GetTrackWidthIndex() + 1 ) % - GetBoard()->m_TrackWidthList.size() ); + if( GetBoard()->GetTrackWidthIndex() < GetBoard()->m_TrackWidthList.size() - 1) + GetBoard()->SetTrackWidthIndex( GetBoard()->GetTrackWidthIndex() + 1 ); + else + GetBoard()->SetTrackWidthIndex( 0 ); if( GetCanvas()->IsMouseCaptured() ) GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false ); @@ -182,10 +184,10 @@ void PCB_EDIT_FRAME::OnHotKey( wxDC* aDC, int aHotkeyCode, const wxPoint& aPosit if( GetCanvas()->IsMouseCaptured() ) GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false ); - if( GetBoard()->GetTrackWidthIndex() == 0 ) - GetBoard()->SetTrackWidthIndex( GetBoard()->m_TrackWidthList.size() ); - - GetBoard()->SetTrackWidthIndex( GetBoard()->GetTrackWidthIndex() - 1 ); + if( GetBoard()->GetTrackWidthIndex() <= 0 ) + GetBoard()->SetTrackWidthIndex( GetBoard()->m_TrackWidthList.size() -1 ); + else + GetBoard()->SetTrackWidthIndex( GetBoard()->GetTrackWidthIndex() - 1 ); if( GetCanvas()->IsMouseCaptured() ) GetCanvas()->CallMouseCapture( aDC, wxDefaultPosition, false );