From 19124ceee8e2199ec03cde07f92c6649c31f0caf Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sun, 4 Oct 2015 13:46:56 +0200 Subject: [PATCH] Fix crash when exporting vrml (see bug Bug #1502549) when there is a Glu error. Enhancement: dialog_footprint_wizard_list remembers now its size. --- pcbnew/dialogs/dialog_export_vrml_base.cpp | 6 +--- pcbnew/dialogs/dialog_export_vrml_base.fbp | 4 +-- pcbnew/dialogs/dialog_export_vrml_base.h | 4 +-- .../dialogs/dialog_footprint_wizard_list.cpp | 34 +++++++++++++++---- pcbnew/dialogs/dialog_footprint_wizard_list.h | 6 ++-- utils/idftools/vrml_layer.cpp | 9 +++-- 6 files changed, 42 insertions(+), 21 deletions(-) diff --git a/pcbnew/dialogs/dialog_export_vrml_base.cpp b/pcbnew/dialogs/dialog_export_vrml_base.cpp index e04f19b461..05ec56bcd5 100644 --- a/pcbnew/dialogs/dialog_export_vrml_base.cpp +++ b/pcbnew/dialogs/dialog_export_vrml_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) +// C++ code generated with wxFormBuilder (version Jun 17 2015) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -150,15 +150,11 @@ DIALOG_EXPORT_3DFILE_BASE::DIALOG_EXPORT_3DFILE_BASE( wxWindow* parent, wxWindow // Connect Events m_filePicker->Connect( wxEVT_COMMAND_FILEPICKER_CHANGED, wxFileDirPickerEventHandler( DIALOG_EXPORT_3DFILE_BASE::OnFileChanged ), NULL, this ); - m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXPORT_3DFILE_BASE::OnCancelClick ), NULL, this ); - m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXPORT_3DFILE_BASE::OnOkClick ), NULL, this ); } DIALOG_EXPORT_3DFILE_BASE::~DIALOG_EXPORT_3DFILE_BASE() { // Disconnect Events m_filePicker->Disconnect( wxEVT_COMMAND_FILEPICKER_CHANGED, wxFileDirPickerEventHandler( DIALOG_EXPORT_3DFILE_BASE::OnFileChanged ), NULL, this ); - m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXPORT_3DFILE_BASE::OnCancelClick ), NULL, this ); - m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EXPORT_3DFILE_BASE::OnOkClick ), NULL, this ); } diff --git a/pcbnew/dialogs/dialog_export_vrml_base.fbp b/pcbnew/dialogs/dialog_export_vrml_base.fbp index ab8d857882..b9a987e8d2 100644 --- a/pcbnew/dialogs/dialog_export_vrml_base.fbp +++ b/pcbnew/dialogs/dialog_export_vrml_base.fbp @@ -1662,11 +1662,11 @@ m_sdbSizer1 protected - OnCancelClick + - OnOkClick + diff --git a/pcbnew/dialogs/dialog_export_vrml_base.h b/pcbnew/dialogs/dialog_export_vrml_base.h index 8d7ee7b9c1..674ebb3178 100644 --- a/pcbnew/dialogs/dialog_export_vrml_base.h +++ b/pcbnew/dialogs/dialog_export_vrml_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Jun 5 2014) +// C++ code generated with wxFormBuilder (version Jun 17 2015) // http://www.wxformbuilder.org/ // // PLEASE DO "NOT" EDIT THIS FILE! @@ -69,8 +69,6 @@ class DIALOG_EXPORT_3DFILE_BASE : public DIALOG_SHIM // Virtual event handlers, overide them in your derived class virtual void OnFileChanged( wxFileDirPickerEvent& event ) { event.Skip(); } - virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } - virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); } public: diff --git a/pcbnew/dialogs/dialog_footprint_wizard_list.cpp b/pcbnew/dialogs/dialog_footprint_wizard_list.cpp index d012c2abdb..c4293d8bdb 100644 --- a/pcbnew/dialogs/dialog_footprint_wizard_list.cpp +++ b/pcbnew/dialogs/dialog_footprint_wizard_list.cpp @@ -30,24 +30,26 @@ #include #include -#include +#include #include #include #define ROW_NAME 0 #define ROW_DESCR 1 - +#define FPWIZARTDLIST_HEIGHT_KEY wxT( "FpWizardListHeight" ) +#define FPWIZARTDLIST_WIDTH_KEY wxT( "FpWizardListWidth" ) DIALOG_FOOTPRINT_WIZARD_LIST::DIALOG_FOOTPRINT_WIZARD_LIST( wxWindow* aParent ) : DIALOG_FOOTPRINT_WIZARD_LIST_BASE( aParent ) { int n_wizards = FOOTPRINT_WIZARDS::GetWizardsCount(); + m_config = Kiface().KifaceSettings(); // Current wizard selection, empty or first - m_FootprintWizard = NULL; + m_footprintWizard = NULL; if( n_wizards ) - m_FootprintWizard = FOOTPRINT_WIZARDS::GetWizard( 0 ); + m_footprintWizard = FOOTPRINT_WIZARDS::GetWizard( 0 ); // Choose selection mode and insert the needed rows @@ -71,20 +73,38 @@ DIALOG_FOOTPRINT_WIZARD_LIST::DIALOG_FOOTPRINT_WIZARD_LIST( wxWindow* aParent ) m_footprintWizardsGrid->ClearSelection(); m_footprintWizardsGrid->SelectRow( 0, false ); - GetSizer()->SetSizeHints( this ); + if( m_config ) + { + wxSize size; + m_config->Read( FPWIZARTDLIST_WIDTH_KEY, &size.x, -1 ); + m_config->Read( FPWIZARTDLIST_HEIGHT_KEY, &size.y, -1 ); + SetSize( size ); + } + Center(); } +DIALOG_FOOTPRINT_WIZARD_LIST::~DIALOG_FOOTPRINT_WIZARD_LIST() +{ + if( m_config && !IsIconized() ) + { + m_config->Write( FPWIZARTDLIST_WIDTH_KEY, GetSize().x ); + m_config->Write( FPWIZARTDLIST_HEIGHT_KEY, GetSize().y ); + } +} + + + void DIALOG_FOOTPRINT_WIZARD_LIST::OnCellWizardClick( wxGridEvent& event ) { int click_row = event.GetRow(); - m_FootprintWizard = FOOTPRINT_WIZARDS::GetWizard( click_row ); + m_footprintWizard = FOOTPRINT_WIZARDS::GetWizard( click_row ); m_footprintWizardsGrid->SelectRow( event.GetRow(), false ); } FOOTPRINT_WIZARD* DIALOG_FOOTPRINT_WIZARD_LIST::GetWizard() { - return m_FootprintWizard; + return m_footprintWizard; } diff --git a/pcbnew/dialogs/dialog_footprint_wizard_list.h b/pcbnew/dialogs/dialog_footprint_wizard_list.h index 397d224556..255d8067fe 100644 --- a/pcbnew/dialogs/dialog_footprint_wizard_list.h +++ b/pcbnew/dialogs/dialog_footprint_wizard_list.h @@ -31,10 +31,12 @@ class DIALOG_FOOTPRINT_WIZARD_LIST: public DIALOG_FOOTPRINT_WIZARD_LIST_BASE { private: - FOOTPRINT_WIZARD *m_FootprintWizard; + FOOTPRINT_WIZARD* m_footprintWizard; ///< The selected python script wizard + wxConfigBase* m_config; public: - DIALOG_FOOTPRINT_WIZARD_LIST( wxWindow * parent ); + DIALOG_FOOTPRINT_WIZARD_LIST( wxWindow * aParent ); + ~DIALOG_FOOTPRINT_WIZARD_LIST(); FOOTPRINT_WIZARD* GetWizard(); diff --git a/utils/idftools/vrml_layer.cpp b/utils/idftools/vrml_layer.cpp index 8db5fae3a6..5974371660 100644 --- a/utils/idftools/vrml_layer.cpp +++ b/utils/idftools/vrml_layer.cpp @@ -1499,8 +1499,13 @@ void VRML_LAYER::glEnd( void ) // set the error message void VRML_LAYER::SetGLError( GLenum errorID ) { - error = ""; - error = (const char*)gluGetString( errorID ); + const char * msg = (const char*)gluErrorString( errorID ); + + // If errorID is an illegal id, gluErrorString returns NULL + if( msg ) + error = msg; + else + error.clear(); if( error.empty() ) {