From 9d452a60976f789cd18a6c009c094a7edc9e11ef Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 20 May 2023 07:00:09 +0300 Subject: [PATCH] Fix opening boards with deprecated features. --- pcbnew/kicad_clipboard.cpp | 2 +- pcbnew/plugins/kicad/pcb_parser.cpp | 10 +++++----- pcbnew/plugins/kicad/pcb_parser.h | 4 ++-- pcbnew/plugins/kicad/pcb_plugin.cpp | 5 ++--- pcbnew/plugins/kicad/pcb_plugin.h | 4 ++-- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/pcbnew/kicad_clipboard.cpp b/pcbnew/kicad_clipboard.cpp index 3b9d8c03f4..603f786357 100644 --- a/pcbnew/kicad_clipboard.cpp +++ b/pcbnew/kicad_clipboard.cpp @@ -399,7 +399,7 @@ BOARD* CLIPBOARD_IO::Load( const wxString& aFileName, BOARD* aAppendToMe, }; STRING_LINE_READER reader( result, wxT( "clipboard" ) ); - PCB_PARSER parser( &reader, aAppendToMe, &queryUser ); + PCB_PARSER parser( &reader, aAppendToMe, queryUser ); init( aProperties ); diff --git a/pcbnew/plugins/kicad/pcb_parser.cpp b/pcbnew/plugins/kicad/pcb_parser.cpp index 92cc522755..0f59fd938b 100644 --- a/pcbnew/plugins/kicad/pcb_parser.cpp +++ b/pcbnew/plugins/kicad/pcb_parser.cpp @@ -990,8 +990,8 @@ BOARD* PCB_PARSER::parseBOARD_unchecked() undefinedLayerNames, destLayerName ); - if( !(*m_queryUserCallback)( _( "Undefined Layers Warning" ), wxICON_WARNING, msg, - _( "Rescue" ) ) ) + if( !m_queryUserCallback( _( "Undefined Layers Warning" ), wxICON_WARNING, msg, + _( "Rescue" ) ) ) { THROW_IO_ERROR( wxT( "CANCEL" ) ); } @@ -2216,7 +2216,7 @@ void PCB_PARSER::parseSetup() { // Thick outline fill mode no longer supported. Make sure user is OK with // converting fills. - if( !(*m_queryUserCallback)( + if( !m_queryUserCallback( _( "Legacy Zone Warning" ), wxICON_WARNING, _( "The legacy zone fill strategy is no longer supported.\n" "Convert zones to smoothed polygon fills?" ), @@ -5171,7 +5171,7 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent ) { if( Pgm().IsGUI() && m_queryUserCallback ) { - if( !(*m_queryUserCallback)( + if( !m_queryUserCallback( _( "Legacy Zone Warning" ), wxICON_WARNING, _( "The legacy zone fill strategy is no longer supported.\n" "Convert zones to smoothed polygon fills?" ), @@ -5220,7 +5220,7 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent ) { if( Pgm().IsGUI() && m_queryUserCallback ) { - if( !(*m_queryUserCallback)( + if( !m_queryUserCallback( _( "Legacy Zone Warning" ), wxICON_WARNING, _( "The segment zone fill mode is no longer supported.\n" "Convert zones to smoothed polygon fills?" ), diff --git a/pcbnew/plugins/kicad/pcb_parser.h b/pcbnew/plugins/kicad/pcb_parser.h index 3319cedbc2..79ba3b3b5e 100644 --- a/pcbnew/plugins/kicad/pcb_parser.h +++ b/pcbnew/plugins/kicad/pcb_parser.h @@ -74,7 +74,7 @@ class PCB_PARSER : public PCB_LEXER { public: PCB_PARSER( LINE_READER* aReader, BOARD* aAppendToMe, - std::function* aQueryUserCallback, + std::function aQueryUserCallback, PROGRESS_REPORTER* aProgressReporter = nullptr, unsigned aLineCount = 0 ) : PCB_LEXER( aReader ), m_board( aAppendToMe ), @@ -368,7 +368,7 @@ private: std::vector m_groupInfos; - std::function* m_queryUserCallback; + std::function m_queryUserCallback; }; diff --git a/pcbnew/plugins/kicad/pcb_plugin.cpp b/pcbnew/plugins/kicad/pcb_plugin.cpp index cefd9f2a6f..1f47958920 100644 --- a/pcbnew/plugins/kicad/pcb_plugin.cpp +++ b/pcbnew/plugins/kicad/pcb_plugin.cpp @@ -274,7 +274,7 @@ void PCB_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, const STRING_UT if( sanityResult != wxEmptyString && m_queryUserCallback ) { - if( !(*m_queryUserCallback)( + if( !m_queryUserCallback( _( "Internal Group Data Error" ), wxICON_ERROR, wxString::Format( _( "Please report this bug. Error validating group " "structure: %s\n\nSave anyway?" ), sanityResult ), @@ -2224,8 +2224,7 @@ void PCB_PLUGIN::format( const ZONE* aZone, int aNestLevel ) const PCB_PLUGIN::PCB_PLUGIN( int aControlFlags ) : m_cache( nullptr ), m_ctl( aControlFlags ), - m_mapping( new NETINFO_MAPPING() ), - m_queryUserCallback( nullptr ) + m_mapping( new NETINFO_MAPPING() ) { init( nullptr ); m_out = &m_sf; diff --git a/pcbnew/plugins/kicad/pcb_plugin.h b/pcbnew/plugins/kicad/pcb_plugin.h index 99484d3d78..b6d685cb74 100644 --- a/pcbnew/plugins/kicad/pcb_plugin.h +++ b/pcbnew/plugins/kicad/pcb_plugin.h @@ -277,7 +277,7 @@ public: void SetQueryUserCallback( std::function aCallback ) override { - m_queryUserCallback = &aCallback; + m_queryUserCallback = aCallback; } void Save( const wxString& aFileName, BOARD* aBoard, @@ -426,7 +426,7 @@ protected: NETINFO_MAPPING* m_mapping; ///< mapping for net codes, so only not empty net codes ///< are stored with consecutive integers as net codes - std::function* m_queryUserCallback; + std::function m_queryUserCallback; }; #endif // PCB_PLUGIN_H