diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 0399ac628c..a8d657609a 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -1233,42 +1233,6 @@ 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 7ae3bb0a73..ce9f36422a 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -635,20 +635,6 @@ 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 9625331d9f..790a22cbd8 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -684,6 +684,18 @@ 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() ) @@ -696,6 +708,16 @@ 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 88376c47f6..c301e030bd 100644 --- a/eeschema/sch_sheet_path.h +++ b/eeschema/sch_sheet_path.h @@ -436,6 +436,13 @@ 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. @@ -443,6 +450,8 @@ 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 a0d2fd4c8a..b7a23f8d09 100644 --- a/eeschema/schframe.cpp +++ b/eeschema/schframe.cpp @@ -616,7 +616,9 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent ) return; } - if( g_RootSheet->IsModified() ) + SCH_SHEET_LIST sheetList; + + if( sheetList.IsModified() ) { wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() ); wxString msg = wxString::Format( _( @@ -667,7 +669,7 @@ void SCH_EDIT_FRAME::OnCloseWindow( wxCloseEvent& aEvent ) wxRemoveFile( fn.GetFullPath() ); } - g_RootSheet->ClearModifyStatus(); + sheetList.ClearModifyStatus(); wxString fileName = Prj().AbsolutePath( g_RootSheet->GetScreen()->GetFileName() ); @@ -787,13 +789,16 @@ void SCH_EDIT_FRAME::OnUpdateHiddenPins( wxUpdateUIEvent& aEvent ) void SCH_EDIT_FRAME::OnUpdateSave( wxUpdateUIEvent& aEvent ) { - aEvent.Enable( g_RootSheet->IsModified() ); + SCH_SHEET_LIST sheetList; + + aEvent.Enable( sheetList.IsModified() ); } void SCH_EDIT_FRAME::OnUpdateSaveSheet( wxUpdateUIEvent& aEvent ) { aEvent.Enable( GetScreen()->IsModify() ); + }