diff --git a/bitmap2component/bitmap2cmp_gui.cpp b/bitmap2component/bitmap2cmp_gui.cpp index 5aa689326a..e221f588c0 100644 --- a/bitmap2component/bitmap2cmp_gui.cpp +++ b/bitmap2component/bitmap2cmp_gui.cpp @@ -79,7 +79,7 @@ private: wxString m_ConvertedFileName; wxSize m_frameSize; wxPoint m_framePos; - std::unique_ptr m_config; + wxConfigBase* m_config; public: BM2CMP_FRAME( KIWAY* aKiway, wxWindow* aParent ); @@ -223,6 +223,8 @@ BM2CMP_FRAME::~BM2CMP_FRAME() m_config->Write( KEYWORD_LAST_FORMAT, m_radioBoxFormat->GetSelection() ); m_config->Write( KEYWORD_LAST_MODLAYER, m_radio_PCBLayer->GetSelection() ); + delete m_config; + /* This needed for OSX: avoids further OnDraw processing after this * destructor and before the native window is destroyed */ diff --git a/common/bin_mod.cpp b/common/bin_mod.cpp index 1ad4b01ae0..08513995e2 100644 --- a/common/bin_mod.cpp +++ b/common/bin_mod.cpp @@ -29,6 +29,7 @@ BIN_MOD::BIN_MOD( const char* aName ) : m_name( aName ), + m_config( 0 ), m_history( 0 ) { } @@ -47,7 +48,7 @@ void BIN_MOD::Init() Pgm().CommonSettings()->Read( FILE_HISTORY_SIZE_KEY, &fileHistorySize, DEFAULT_FILE_HISTORY_SIZE ); m_history = new FILE_HISTORY( (unsigned) std::max( 0, fileHistorySize ), ID_FILE1 ); - m_history->Load( *m_config.get() ); + m_history->Load( *m_config ); // Prepare On Line Help. Use only lower case for help file names, in order to // avoid problems with upper/lower case file names under windows and unix. @@ -63,11 +64,14 @@ void BIN_MOD::End() { if( m_config ) { - m_history->Save( *m_config.get() ); + m_history->Save( *m_config ); + delete m_history; // Deleting a wxConfigBase writes its contents to disk if changed. - m_config.reset(); + // Might be NULL if called twice, in which case nothing happens. + delete m_config; + m_config = 0; } } diff --git a/common/common.cpp b/common/common.cpp index d3c6bef899..9d5bca535e 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -248,13 +248,15 @@ double RoundTo0( double x, double precision ) } -std::unique_ptr GetNewConfig( const wxString& aProgName ) +wxConfigBase* GetNewConfig( const wxString& aProgName ) { + wxConfigBase* cfg = 0; wxFileName configname; configname.AssignDir( GetKicadConfigPath() ); configname.SetFullName( aProgName ); - return std::make_unique( wxT( "" ), wxT( "" ), configname.GetFullPath() ); + cfg = new wxFileConfig( wxT( "" ), wxT( "" ), configname.GetFullPath() ); + return cfg; } diff --git a/common/pgm_base.cpp b/common/pgm_base.cpp index 5f05f13a10..6235890836 100644 --- a/common/pgm_base.cpp +++ b/common/pgm_base.cpp @@ -154,6 +154,7 @@ PGM_BASE::PGM_BASE() { m_pgm_checker = NULL; m_locale = NULL; + m_common_settings = NULL; m_show_env_var_dialog = true; @@ -172,7 +173,9 @@ PGM_BASE::~PGM_BASE() void PGM_BASE::Destroy() { // unlike a normal destructor, this is designed to be called more than once safely: - m_common_settings.reset(); + + delete m_common_settings; + m_common_settings = 0; delete m_pgm_checker; m_pgm_checker = 0; @@ -559,7 +562,7 @@ void PGM_BASE::loadCommonSettings() // options only in pcbnew (which was the only canvas to support them). Since there's // no single right answer to where to pull the common settings from, we might as well // get them along with the hardware antialiasing option from pcbnew. - auto pcbnewConfig = GetNewConfig( wxString::FromUTF8( "pcbnew" ) ); + wxConfigBase* pcbnewConfig = GetNewConfig( wxString::FromUTF8( "pcbnew" ) ); wxString pcbFrameKey( PCB_EDIT_FRAME_NAME ); if( !m_common_settings->HasEntry( ICON_SCALE_KEY ) ) diff --git a/eeschema/widgets/symbol_preview_widget.cpp b/eeschema/widgets/symbol_preview_widget.cpp index e3c50c3ba6..19453dcc65 100644 --- a/eeschema/widgets/symbol_preview_widget.cpp +++ b/eeschema/widgets/symbol_preview_widget.cpp @@ -41,8 +41,8 @@ SYMBOL_PREVIEW_WIDGET::SYMBOL_PREVIEW_WIDGET( wxWindow* aParent, KIWAY& aKiway, m_previewItem( nullptr ) { wxString eeschemaFrameKey( SCH_EDIT_FRAME_NAME ); - auto eeschemaConfig = GetNewConfig( Pgm().App().GetAppName() ); - m_galDisplayOptions.ReadConfig( eeschemaConfig.get(), eeschemaFrameKey + GAL_DISPLAY_OPTIONS_KEY ); + wxConfigBase* eeschemaConfig = GetNewConfig( Pgm().App().GetAppName() ); + m_galDisplayOptions.ReadConfig( eeschemaConfig, eeschemaFrameKey + GAL_DISPLAY_OPTIONS_KEY ); EDA_DRAW_PANEL_GAL::GAL_TYPE canvasType = aCanvasType; diff --git a/include/bin_mod.h b/include/bin_mod.h index a516a76421..d2ad208277 100644 --- a/include/bin_mod.h +++ b/include/bin_mod.h @@ -33,7 +33,6 @@ #include #include -#include class wxConfigBase; class FILE_HISTORY; @@ -56,7 +55,7 @@ struct BIN_MOD const char* m_name; ///< name of this binary module, static C string. - std::unique_ptr m_config; ///< maybe from $HOME/.${m_name} + wxConfigBase* m_config; ///< maybe from $HOME/.${m_name} FILE_HISTORY* m_history; wxString m_help_file; diff --git a/include/common.h b/include/common.h index 62410d3676..9c12789ed8 100644 --- a/include/common.h +++ b/include/common.h @@ -43,7 +43,6 @@ #include #include -#include // C++11 "polyfill" for the C++14 std::make_unique function #include "make_unique.h" @@ -311,7 +310,7 @@ const wxString PrePendPath( const wxString& aEnvVar, const wxString& aPriorityPa * @return A pointer to a new wxConfigBase derived object is returned. The caller is in charge * of deleting it. */ -std::unique_ptr GetNewConfig( const wxString& aProgName ); +wxConfigBase* GetNewConfig( const wxString& aProgName ); /** * Return the user configuration path used to store KiCad's configuration files. diff --git a/include/kiface_i.h b/include/kiface_i.h index e72f26a234..688d2e6af3 100644 --- a/include/kiface_i.h +++ b/include/kiface_i.h @@ -100,7 +100,7 @@ public: const wxString Name() { return wxString::FromUTF8( m_bm.m_name ); } - wxConfigBase* KifaceSettings() const { return m_bm.m_config.get(); } + wxConfigBase* KifaceSettings() const { return m_bm.m_config; } /** * Function StartFlags diff --git a/include/pgm_base.h b/include/pgm_base.h index c3f665146f..c754c8cf3b 100644 --- a/include/pgm_base.h +++ b/include/pgm_base.h @@ -32,7 +32,6 @@ #define PGM_BASE_H_ #include -#include #include #include #include @@ -185,7 +184,7 @@ public: */ VTBL_ENTRY void MacOpenFile( const wxString& aFileName ) = 0; - VTBL_ENTRY wxConfigBase* CommonSettings() const { return m_common_settings.get(); } + VTBL_ENTRY wxConfigBase* CommonSettings() const { return m_common_settings; } VTBL_ENTRY void SetEditorName( const wxString& aFileName ); @@ -363,7 +362,7 @@ protected: /// Configuration settings common to all KiCad program modules, /// like as in $HOME/.kicad_common - std::unique_ptr m_common_settings; + wxConfigBase* m_common_settings; /// full path to this program wxString m_bin_dir; diff --git a/kicad/pgm_kicad.h b/kicad/pgm_kicad.h index 2a8e234dc8..c3eb04c74e 100644 --- a/kicad/pgm_kicad.h +++ b/kicad/pgm_kicad.h @@ -56,7 +56,7 @@ public: FILE_HISTORY& GetFileHistory() { return *m_bm.m_history; } - wxConfigBase* PgmSettings() { return m_bm.m_config.get(); } + wxConfigBase* PgmSettings() { return m_bm.m_config; } SEARCH_STACK& SysSearch() { return m_bm.m_search; } diff --git a/pcb_calculator/pcb_calculator_frame.cpp b/pcb_calculator/pcb_calculator_frame.cpp index d65e6bd7dd..04b3ad56f0 100644 --- a/pcb_calculator/pcb_calculator_frame.cpp +++ b/pcb_calculator/pcb_calculator_frame.cpp @@ -83,15 +83,15 @@ PCB_CALCULATOR_FRAME::PCB_CALCULATOR_FRAME( KIWAY* aKiway, wxWindow* aParent ) : m_attenuator_list.push_back( new ATTENUATOR_SPLITTER() ); m_currAttenuator = m_attenuator_list[0]; - auto config = GetNewConfig( Pgm().App().GetAppName() ); - LoadSettings( config.get() ); + wxConfigBase* config = GetNewConfig( Pgm().App().GetAppName() ); + LoadSettings( config ); ReadDataFile(); TranslineTypeSelection( m_currTransLineType ); m_TranslineSelection->SetSelection( m_currTransLineType ); - TW_Init( config.get() ); + TW_Init( config ); SetAttenuator( m_AttenuatorsSelection->GetSelection() );