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 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<wxWindow*>( listener );
if( win )
win->HandleWindowEvent( e );
else
listener->SafelyProcessEvent( e );
}
updateTitle();
break;
}
default:
return false;
break;
}
}

View File

@ -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<wxWindow*>( listener );
if( win )
win->HandleWindowEvent( e );
else
listener->SafelyProcessEvent( e );
}
FocusOnItem( nullptr );
GetCanvas()->DisplaySheet( GetCurrentSheet().LastScreen() );

View File

@ -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.

View File

@ -98,8 +98,11 @@ void SCH_SEARCH_HANDLER::SelectItems( std::vector<long>& 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 );