From 537d6bdb752ffb03b037bc9347bb59aef4850305 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 15 Jul 2023 22:39:07 +0100 Subject: [PATCH] Don't destroy ERC dialog twice. (And some other cleanup.) --- eeschema/sch_edit_frame.cpp | 39 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 3c6650f664..775ce51c46 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -44,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -90,8 +89,6 @@ #include #include #include - -#include #include @@ -233,7 +230,6 @@ SCH_EDIT_FRAME::SCH_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : .DestroyOnClose( false ) .Show( m_show_search ) ); - FinishAUIInitialization(); resolveCanvasType(); @@ -789,17 +785,13 @@ SCHEMATIC& SCH_EDIT_FRAME::Schematic() const wxString SCH_EDIT_FRAME::GetScreenDesc() const { - wxString s = GetCurrentSheet().Last()->GetName(); - - return s; + return GetCurrentSheet().Last()->GetName(); } wxString SCH_EDIT_FRAME::GetFullScreenDesc() const { - wxString s = GetCurrentSheet().PathHumanReadable(); - - return s; + return GetCurrentSheet().PathHumanReadable(); } @@ -966,11 +958,6 @@ void SCH_EDIT_FRAME::doCloseWindow() m_netNavigator->Unbind( wxEVT_TREE_SEL_CHANGED, &SCH_EDIT_FRAME::onNetNavigatorSelection, this ); - wxWindow* open_dlg = wxWindow::FindWindowByName( DIALOG_ERC_WINDOW_NAME ); - - if( open_dlg ) - open_dlg->Destroy(); - // Close the find dialog and preserve its setting if it is displayed. if( m_findReplaceDialog ) { @@ -1105,10 +1092,7 @@ void SCH_EDIT_FRAME::OnModify() { EDA_BASE_FRAME::OnModify(); - wxASSERT( GetScreen() ); - - if( !GetScreen() ) - return; + wxCHECK( GetScreen(), /* void */ ); GetScreen()->SetContentModified(); m_autoSaveRequired = true; @@ -1594,21 +1578,24 @@ void SCH_EDIT_FRAME::AutoRotateItem( SCH_SCREEN* aScreen, SCH_ITEM* aItem ) { if( aItem->IsType( { SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T } ) ) { - auto label = static_cast( aItem ); + SCH_LABEL_BASE* label = static_cast( aItem ); + if( label->AutoRotateOnPlacement() ) { - auto textSpin = aScreen->GetLabelOrientationForPoint( - label->GetPosition(), label->GetTextSpinStyle(), &GetCurrentSheet() ); - if( textSpin != label->GetTextSpinStyle() ) + TEXT_SPIN_STYLE spin = aScreen->GetLabelOrientationForPoint( label->GetPosition(), + label->GetTextSpinStyle(), + &GetCurrentSheet() ); + + if( spin != label->GetTextSpinStyle() ) { - label->SetTextSpinStyle( textSpin ); + label->SetTextSpinStyle( spin ); + for( SCH_ITEM* item : aScreen->Items().OfType( SCH_GLOBAL_LABEL_T ) ) { SCH_LABEL_BASE* otherLabel = static_cast( item ); + if( otherLabel != label && otherLabel->GetText() == label->GetText() ) - { otherLabel->AutoplaceFields( aScreen, false ); - } } } }