diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index c3c4b97f6a..4fae9d50a5 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -1233,6 +1233,42 @@ void SCH_SHEET::ClearAnnotation( bool aIncludeSubSheets ) } +bool SCH_SHEET::IsModified() const +{ + if( m_screen->IsModify() ) + return true; + + bool retv = false; + SCH_ITEM* item = m_screen->GetDrawItems(); + + while( item && !retv ) + { + if( item->Type() == SCH_SHEET_T ) + retv = static_cast( item )->IsModified(); + + item = item->Next(); + } + + return retv; +} + + +void SCH_SHEET::ClearModifyStatus() +{ + m_screen->ClrModify(); + + SCH_ITEM* item = m_screen->GetDrawItems(); + + while( item ) + { + if( item->Type() == SCH_SHEET_T ) + static_cast( item )->m_screen->ClrModify(); + + item = item->Next(); + } +} + + SCH_ITEM& SCH_SHEET::operator=( const SCH_ITEM& aItem ) { wxLogDebug( wxT( "Sheet assignment operator." ) ); diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index ce9f36422a..7ae3bb0a73 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -635,6 +635,20 @@ public: void ClearAnnotation( bool aIncludeSubSheets = false ); + /** + * Function IsModified + * checks the sheet and any of it's sub-sheets (hierarchy) for any modifications. + * @return true if the hierarchy is modified otherwise false. + */ + bool IsModified() const; + + /** + * Function ClearModifyStatus + * + * clears the modification flag for everything in the sheet and all sub-sheets. + */ + void ClearModifyStatus(); + #if defined(DEBUG) void Show( int nestLevel, std::ostream& os ) const; // override #endif diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index 4c875a2e80..fec3ef6815 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -684,18 +684,6 @@ void SCH_SHEET_LIST::BuildSheetList( SCH_SHEET* aSheet ) } -bool SCH_SHEET_LIST::IsModified() -{ - for( SCH_SHEET_PATH* sheet = GetFirst(); sheet; sheet = GetNext() ) - { - if( sheet->LastScreen() && sheet->LastScreen()->IsModify() ) - return true; - } - - return false; -} - - bool SCH_SHEET_LIST::IsAutoSaveRequired() { for( SCH_SHEET_PATH* sheet = GetFirst(); sheet; sheet = GetNext() ) @@ -708,16 +696,6 @@ bool SCH_SHEET_LIST::IsAutoSaveRequired() } -void SCH_SHEET_LIST::ClearModifyStatus() -{ - for( SCH_SHEET_PATH* sheet = GetFirst(); sheet; sheet = GetNext() ) - { - if( sheet->LastScreen() ) - sheet->LastScreen()->ClrModify(); - } -} - - void SCH_SHEET_LIST::AnnotatePowerSymbols( PART_LIBS* aLibs ) { int ref = 1; diff --git a/eeschema/sch_sheet_path.h b/eeschema/sch_sheet_path.h index c301e030bd..88376c47f6 100644 --- a/eeschema/sch_sheet_path.h +++ b/eeschema/sch_sheet_path.h @@ -436,13 +436,6 @@ public: */ SCH_SHEET_PATH* GetSheetByPath( const wxString aPath, bool aHumanReadable = true ); - /** - * Function IsModified - * checks the entire hierarchy for any modifications. - * @returns True if the hierarchy is modified otherwise false. - */ - bool IsModified(); - /** * Function IsAutoSaveRequired * checks the entire hierarchy for any modifications that require auto save. @@ -450,8 +443,6 @@ public: */ bool IsAutoSaveRequired(); - void ClearModifyStatus(); - /** * Function AnnotatePowerSymbols * clear and annotates the entire hierarchy of the sheet path list. diff --git a/eeschema/schframe.cpp b/eeschema/schframe.cpp index 953e7f68de..131f03e27b 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -613,9 +613,7 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent ) return; } - SCH_SHEET_LIST sheetList; - - if( sheetList.IsModified() ) + if( g_RootSheet->IsModified() ) { wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() ); wxString msg = wxString::Format( _( @@ -666,7 +664,7 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent ) wxRemoveFile( fn.GetFullPath() ); } - sheetList.ClearModifyStatus(); + g_RootSheet->ClearModifyStatus(); wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() ); @@ -786,16 +784,13 @@ void SCH_EDIT_FRAME::OnUpdateHiddenPins( wxUpdateUIEvent& aEvent ) void SCH_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent ) { - SCH_SHEET_LIST sheetList; - - aEvent.Enable( sheetList.IsModified() ); + aEvent.Enable( g_RootSheet->IsModified() ); } void SCH_EDIT_FRAME::OnUpdateSaveSheet( wxUpdateUIEvent& aEvent ) { aEvent.Enable( GetScreen()->IsModify() ); - }