Move where we fire EDA_EVT_SCHEMATIC_CHANGED again.

The location in HARD_REDRAW got called everytime we change schematic
pages, which is not what we want.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/14945
This commit is contained in:
Jeff Young 2023-06-13 16:35:28 +01:00
parent 03990ee7e0
commit 20d2568f0c
4 changed files with 39 additions and 37 deletions

View File

@ -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 filename( aFileName );
wxFileName newfilename; 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_CADSTAR_ARCHIVE:
case SCH_IO_MGR::SCH_EAGLE: case SCH_IO_MGR::SCH_EAGLE:
case SCH_IO_MGR::SCH_LTSPICE: 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. // 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!" ) ); wxT( "Import schematic: path is not absolute!" ) );
try try
@ -1280,15 +1281,6 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
// Only perform the dangling end test on root sheet. // Only perform the dangling end test on root sheet.
GetScreen()->TestDanglingEnds(); GetScreen()->TestDanglingEnds();
ClearUndoRedoList();
initScreenZoom();
SetSheetNumberAndCount();
SyncView();
UpdateHierarchyNavigator();
updateTitle();
} }
catch( const IO_ERROR& ioe ) 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 ); msg.Printf( _( "Failed to load '%s'." ), aFileName );
SetMsgPanel( wxEmptyString, msg ); SetMsgPanel( wxEmptyString, msg );
return false;
} }
catch( const std::exception& exc ) 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 ); msg.Printf( _( "Failed to load '%s'." ), aFileName );
SetMsgPanel( wxEmptyString, msg ); 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<wxWindow*>( listener );
if( win )
win->HandleWindowEvent( e );
else
listener->SafelyProcessEvent( e );
}
updateTitle();
break;
}
default: default:
return false; break;
} }
} }

View File

@ -839,23 +839,6 @@ void SCH_EDIT_FRAME::HardRedraw()
if( Schematic().Settings().m_IntersheetRefsShow ) if( Schematic().Settings().m_IntersheetRefsShow )
RecomputeIntersheetRefs(); 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<wxWindow*>( listener );
if( win )
win->HandleWindowEvent( e );
else
listener->SafelyProcessEvent( e );
}
FocusOnItem( nullptr ); FocusOnItem( nullptr );
GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() ); GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );

View File

@ -955,7 +955,7 @@ private:
* @param full filepath of file to be imported. * @param full filepath of file to be imported.
* @param aFileType SCH_FILE_T value for file type * @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. * Save \a aSheet to a schematic file.

View File

@ -98,8 +98,11 @@ void SCH_SEARCH_HANDLER::SelectItems( std::vector<long>& aItemRows )
if( allHitsOnSamePage && !selectedHits.empty() ) if( allHitsOnSamePage && !selectedHits.empty() )
{ {
m_frame->SetCurrentSheet( *selectedHits.front().sheetPath ); if( m_frame->GetCurrentSheet() != *selectedHits.front().sheetPath )
m_frame->DisplayCurrentSheet(); {
m_frame->SetCurrentSheet( *selectedHits.front().sheetPath );
m_frame->DisplayCurrentSheet();
}
if( selectedItems.size() ) if( selectedItems.size() )
m_frame->GetToolManager()->RunAction( EE_ACTIONS::addItemsToSel, true, &selectedItems ); m_frame->GetToolManager()->RunAction( EE_ACTIONS::addItemsToSel, true, &selectedItems );