diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index bc08ab8573..09a521f8b3 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -812,16 +812,14 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs ) #if wxCHECK_VERSION( 3, 1, 7 ) FILEDLG_HOOK_SAVE_PROJECT newProjectHook; - bool checkHook = false; #endif + // Add a "Create a project" checkbox in standalone mode and one isn't loaded if( Kiface().IsSingle() || aSaveAs ) { #if wxCHECK_VERSION( 3, 1, 7 ) dlg.SetCustomizeHook( newProjectHook ); - checkHook = true; #else - // Add a "Create a project" checkbox in standalone mode and one isn't loaded dlg.SetExtraControlCreator( &LEGACYFILEDLG_SAVE_PROJECT::Create ); #endif } @@ -847,7 +845,7 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs ) } #if wxCHECK_VERSION( 3, 1, 7 ) - if( checkHook ) + if( newProjectHook.IsAttachedToDialog() ) createNewProject = newProjectHook.GetCreateNewProject(); #else if( wxWindow* ec = dlg.GetExtraControl() ) diff --git a/eeschema/widgets/filedlg_hook_save_project.h b/eeschema/widgets/filedlg_hook_save_project.h index bbaccc09aa..0365012f68 100644 --- a/eeschema/widgets/filedlg_hook_save_project.h +++ b/eeschema/widgets/filedlg_hook_save_project.h @@ -31,6 +31,8 @@ public: { m_cb = customizer.AddCheckBox( _( "Create a new project for this schematic" ) ); m_cb->SetValue( true ); + + m_controlsAttached = true; } virtual void TransferDataFromCustomControls() override @@ -41,12 +43,16 @@ public: ///< Gets the selected state of the create new project option bool GetCreateNewProject() const { return m_createNewProject; } -private: - bool m_createNewProject; + ///< Gets if this hook has attached controls to a dialog box + bool IsAttachedToDialog() const { return m_controlsAttached; } - wxFileDialogCheckBox* m_cb; +private: + bool m_createNewProject = true; + bool m_controlsAttached = false; + + wxFileDialogCheckBox* m_cb = nullptr; wxDECLARE_NO_COPY_CLASS( FILEDLG_HOOK_SAVE_PROJECT ); }; -#endif \ No newline at end of file +#endif