From e27786de2d9ed7746febad6cbb09554d115ef9ec Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sun, 4 Oct 2020 18:39:21 -0400 Subject: [PATCH] Fix double call of OnPgmExit Also fix bad filename being passed to pcbnew when starting from a blank schematic in standalone mode Fixes https://gitlab.com/kicad/code/kicad/-/issues/5786 --- common/single_top.cpp | 14 +++++++------- eeschema/sch_component.h | 2 +- eeschema/sch_edit_frame.cpp | 4 +++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/common/single_top.cpp b/common/single_top.cpp index b19bac7067..db2225311c 100644 --- a/common/single_top.cpp +++ b/common/single_top.cpp @@ -161,13 +161,7 @@ struct APP_SINGLE_TOP : public wxApp try { - if( !program.OnPgmInit() ) - { - program.OnPgmExit(); - return false; - } - - return true; + return program.OnPgmInit(); } catch( const std::exception& e ) { @@ -294,7 +288,11 @@ bool PGM_SINGLE_TOP::OnPgmInit() #endif if( !InitPgm() ) + { + // Clean up + OnPgmExit(); return false; + } #if !defined(BUILD_KIWAY_DLL) @@ -353,6 +351,8 @@ bool PGM_SINGLE_TOP::OnPgmInit() if( appType == FRAME_T_COUNT ) { wxLogError( wxT( "Unknown frame: %s" ), frameName ); + // Clean up + OnPgmExit(); return false; } } diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index 050fbdcf7c..3c44ecc271 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -611,7 +611,7 @@ public: wxPoint GetPinPhysicalPosition( const LIB_PIN* Pin ) const; - bool IsConnectable() const override { return m_onBoard; } + bool IsConnectable() const override { return true; } bool CanConnect( const SCH_ITEM* aItem ) const override { diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 2cb53d4c98..a11e1888cc 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -903,7 +903,7 @@ void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event ) { wxFileName kicad_board = Prj().AbsolutePath( Schematic().GetFileName() ); - if( kicad_board.IsOk() ) + if( kicad_board.IsOk() && !Schematic().GetFileName().IsEmpty() ) { kicad_board.SetExt( PcbFileExtension ); wxFileName legacy_board( kicad_board ); @@ -940,6 +940,8 @@ void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event ) } else { + // If we are running inside a project, it should be impossible for this case to happen + wxASSERT( Kiface().IsSingle() ); ExecuteFile( this, PCBNEW_EXE ); } }