From b0ecb5b62ddd27a1827651ee82fe22434ad71341 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 20 May 2023 05:45:50 +0300 Subject: [PATCH] Fix opening boards with deprecated features. (cherry picked from commit 9d452a60976f789cd18a6c009c094a7edc9e11ef) --- pcbnew/kicad_clipboard.cpp | 2 +- pcbnew/plugins/kicad/pcb_parser.cpp | 4 ++-- pcbnew/plugins/kicad/pcb_parser.h | 4 ++-- pcbnew/plugins/kicad/pcb_plugin.cpp | 5 ++--- pcbnew/plugins/kicad/pcb_plugin.h | 4 ++-- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/pcbnew/kicad_clipboard.cpp b/pcbnew/kicad_clipboard.cpp index 2f762bf07a..4aee25c4d7 100644 --- a/pcbnew/kicad_clipboard.cpp +++ b/pcbnew/kicad_clipboard.cpp @@ -434,7 +434,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 9d3a70971c..fa28e6b894 100644 --- a/pcbnew/plugins/kicad/pcb_parser.cpp +++ b/pcbnew/plugins/kicad/pcb_parser.cpp @@ -5678,7 +5678,7 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent ) { if( m_showLegacy5ZoneWarning && 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?" ), @@ -5718,7 +5718,7 @@ ZONE* PCB_PARSER::parseZONE( BOARD_ITEM_CONTAINER* aParent ) { if( m_showLegacySegmentZoneWarning && 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 07630cd77e..44d2412cc9 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 ), @@ -369,7 +369,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 5a59a1c715..d897285c54 100644 --- a/pcbnew/plugins/kicad/pcb_plugin.cpp +++ b/pcbnew/plugins/kicad/pcb_plugin.cpp @@ -277,7 +277,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 ), @@ -2349,8 +2349,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 4b2df16634..552dfef8e4 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, @@ -428,7 +428,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