diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 6cf6c0b972..622f705201 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -1227,7 +1227,7 @@ bool SCH_EDIT_FRAME::doAutoSave() } -bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType ) +void SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType ) { wxFileName filename( aFileName ); wxFileName newfilename; @@ -1240,8 +1240,9 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType ) case SCH_IO_MGR::SCH_CADSTAR_ARCHIVE: case SCH_IO_MGR::SCH_EAGLE: case SCH_IO_MGR::SCH_LTSPICE: + { // We insist on caller sending us an absolute path, if it does not, we say it's a bug. - wxCHECK_MSG( filename.IsAbsolute(), false, + wxCHECK_MSG( filename.IsAbsolute(), /*void*/, wxT( "Import schematic: path is not absolute!" ) ); try @@ -1280,15 +1281,6 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType ) // Only perform the dangling end test on root sheet. GetScreen()->TestDanglingEnds(); - - ClearUndoRedoList(); - - initScreenZoom(); - SetSheetNumberAndCount(); - SyncView(); - - UpdateHierarchyNavigator(); - updateTitle(); } catch( const IO_ERROR& ioe ) { @@ -1302,8 +1294,6 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType ) msg.Printf( _( "Failed to load '%s'." ), aFileName ); SetMsgPanel( wxEmptyString, msg ); - - return false; } catch( const std::exception& exc ) { @@ -1316,15 +1306,41 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType ) msg.Printf( _( "Failed to load '%s'." ), aFileName ); SetMsgPanel( wxEmptyString, msg ); - - return false; } - return true; + ClearUndoRedoList(); + + initScreenZoom(); + SetSheetNumberAndCount(); + SyncView(); + + UpdateHierarchyNavigator(); + + wxCommandEvent e( EDA_EVT_SCHEMATIC_CHANGED ); + ProcessEventLocally( e ); + + for( wxEvtHandler* listener : m_schematicChangeListeners ) + { + wxCHECK2( listener, continue ); + + // Use the windows variant when handling event messages in case there is any + // special event handler pre and/or post processing specific to windows. + wxWindow* win = dynamic_cast( listener ); + + if( win ) + win->HandleWindowEvent( e ); + else + listener->SafelyProcessEvent( e ); + } + + updateTitle(); + break; + } default: - return false; + break; } + } diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index c3c55a452e..66fce15eab 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -839,23 +839,6 @@ void SCH_EDIT_FRAME::HardRedraw() if( Schematic().Settings().m_IntersheetRefsShow ) RecomputeIntersheetRefs(); - wxCommandEvent e( EDA_EVT_SCHEMATIC_CHANGED ); - ProcessEventLocally( e ); - - for( wxEvtHandler* listener : m_schematicChangeListeners ) - { - wxCHECK2( listener, continue ); - - // Use the windows variant when handling event messages in case there is any special - // event handler pre and/or post processing specific to windows. - wxWindow* win = dynamic_cast( listener ); - - if( win ) - win->HandleWindowEvent( e ); - else - listener->SafelyProcessEvent( e ); - } - FocusOnItem( nullptr ); GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() ); diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 9bc6412978..5965f20b9e 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -955,7 +955,7 @@ private: * @param full filepath of file to be imported. * @param aFileType SCH_FILE_T value for file type */ - bool importFile( const wxString& aFileName, int aFileType ); + void importFile( const wxString& aFileName, int aFileType ); /** * Save \a aSheet to a schematic file. diff --git a/eeschema/widgets/search_handlers.cpp b/eeschema/widgets/search_handlers.cpp index 5b94fcf282..a92c1625d7 100644 --- a/eeschema/widgets/search_handlers.cpp +++ b/eeschema/widgets/search_handlers.cpp @@ -98,8 +98,11 @@ void SCH_SEARCH_HANDLER::SelectItems( std::vector& aItemRows ) if( allHitsOnSamePage && !selectedHits.empty() ) { - m_frame->SetCurrentSheet( *selectedHits.front().sheetPath ); - m_frame->DisplayCurrentSheet(); + if( m_frame->GetCurrentSheet() != *selectedHits.front().sheetPath ) + { + m_frame->SetCurrentSheet( *selectedHits.front().sheetPath ); + m_frame->DisplayCurrentSheet(); + } if( selectedItems.size() ) m_frame->GetToolManager()->RunAction( EE_ACTIONS::addItemsToSel, true, &selectedItems );