Fixup memory lifespan of GAL options for the settings preview canvas

The canvas keeps a reference to the settings object, so we
can't pass one from the stack because it runs into lifetime
issues.

Also cleanup some loop-iterator problems.

Fixes https://gitlab.com/kicad/code/kicad/issues/6338
This commit is contained in:
Ian McInerney 2020-12-01 01:10:58 +00:00
parent 7f6be05d9d
commit aa09418a14
4 changed files with 8 additions and 6 deletions

View File

@ -79,14 +79,13 @@ PANEL_EESCHEMA_COLOR_SETTINGS::PANEL_EESCHEMA_COLOR_SETTINGS( SCH_BASE_FRAME* aF
createSwatches(); createSwatches();
KIGFX::GAL_DISPLAY_OPTIONS options; m_galDisplayOptions.ReadConfig( *common_settings, app_settings->m_Window, this );
options.ReadConfig( *common_settings, app_settings->m_Window, this ); m_galDisplayOptions.m_forceDisplayCursor = false;
options.m_forceDisplayCursor = false;
auto type = static_cast<EDA_DRAW_PANEL_GAL::GAL_TYPE>( app_settings->m_Graphics.canvas_type ); auto type = static_cast<EDA_DRAW_PANEL_GAL::GAL_TYPE>( app_settings->m_Graphics.canvas_type );
m_preview = new SCH_PREVIEW_PANEL( this, wxID_ANY, wxDefaultPosition, wxSize( -1, -1 ), m_preview = new SCH_PREVIEW_PANEL( this, wxID_ANY, wxDefaultPosition, wxSize( -1, -1 ),
options, type ); m_galDisplayOptions, type );
m_preview->SetStealsFocus( false ); m_preview->SetStealsFocus( false );
m_preview->ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER ); m_preview->ShowScrollbars( wxSHOW_SB_NEVER, wxSHOW_SB_NEVER );
m_preview->GetGAL()->SetAxesEnabled( false ); m_preview->GetGAL()->SetAxesEnabled( false );

View File

@ -22,6 +22,7 @@
#define PANEL_EESCHEMA_COLOR_SETTINGS_H_ #define PANEL_EESCHEMA_COLOR_SETTINGS_H_
#include <gal/color4d.h> #include <gal/color4d.h>
#include <gal/gal_display_options.h>
#include <layers_id_colors_and_visibility.h> #include <layers_id_colors_and_visibility.h>
#include <panel_color_settings.h> #include <panel_color_settings.h>
@ -69,6 +70,8 @@ private:
KIGFX::WS_PROXY_VIEW_ITEM* m_ws; KIGFX::WS_PROXY_VIEW_ITEM* m_ws;
std::vector<EDA_ITEM*> m_previewItems; std::vector<EDA_ITEM*> m_previewItems;
KIGFX::GAL_DISPLAY_OPTIONS m_galDisplayOptions;
private: private:
void createPreviewItems(); void createPreviewItems();
void createSwatches(); void createSwatches();

View File

@ -752,7 +752,7 @@ void CADSTAR_SCH_ARCHIVE_LOADER::loadNets()
} }
// Now we can load the wires // Now we can load the wires
for( const VECTOR2I pt : wireChain.CPoints() ) for( const VECTOR2I& pt : wireChain.CPoints() )
{ {
if( firstPt ) if( firstPt )
{ {

View File

@ -915,7 +915,7 @@ bool BOARD_NETLIST_UPDATER::UpdateNetlist( NETLIST& aNetlist )
if( m_isDryRun ) if( m_isDryRun )
{ {
for( const std::pair<wxString, NETINFO_ITEM*>& addedNet : m_addedNets ) for( const std::pair<const wxString, NETINFO_ITEM*>& addedNet : m_addedNets )
delete addedNet.second; delete addedNet.second;
m_addedNets.clear(); m_addedNets.clear();