Unify IsSave and IsModify
The flags and calls were used identically, leading to potential confusion/bugs. Testing for modification should go through IsContentModified()
This commit is contained in:
parent
f399dc7dd0
commit
d7f219e98f
|
@ -40,7 +40,6 @@ BASE_SCREEN::BASE_SCREEN( EDA_ITEM* aParent, KICAD_T aType ) :
|
|||
m_Center = true;
|
||||
|
||||
m_flagModified = false; // Set when any change is made on board.
|
||||
m_flagSave = false; // Used in auto save set when an auto save is required.
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1025,7 +1025,7 @@ void EDA_BASE_FRAME::CheckForAutoSaveFile( const wxFileName& aFileName )
|
|||
}
|
||||
|
||||
|
||||
bool EDA_BASE_FRAME::IsContentModified()
|
||||
bool EDA_BASE_FRAME::IsContentModified() const
|
||||
{
|
||||
// This function should be overridden in child classes
|
||||
return false;
|
||||
|
|
|
@ -139,7 +139,7 @@ public:
|
|||
*
|
||||
* @return true if the any changes have not been saved
|
||||
*/
|
||||
bool IsContentModified() override
|
||||
bool IsContentModified() const override
|
||||
{
|
||||
return m_modified;
|
||||
}
|
||||
|
|
|
@ -188,7 +188,6 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SHEET* aSheet, bool aSaveUnderNewName )
|
|||
UpdateFileHistory( schematicFileName.GetFullPath() );
|
||||
}
|
||||
|
||||
screen->ClrSave();
|
||||
screen->ClrModify();
|
||||
UpdateTitle();
|
||||
|
||||
|
@ -1029,6 +1028,10 @@ bool SCH_EDIT_FRAME::doAutoSave()
|
|||
wxFileName tmp;
|
||||
SCH_SCREENS screens( Schematic().Root() );
|
||||
|
||||
// Don't run autosave if content has not been modified
|
||||
if( !IsContentModified() )
|
||||
return true;
|
||||
|
||||
bool autoSaveOk = true;
|
||||
|
||||
if( fn.GetPath().IsEmpty() )
|
||||
|
@ -1047,7 +1050,7 @@ bool SCH_EDIT_FRAME::doAutoSave()
|
|||
for( size_t i = 0; i < screens.GetCount(); i++ )
|
||||
{
|
||||
// Only create auto save files for the schematics that have been modified.
|
||||
if( !screens.GetScreen( i )->IsSave() )
|
||||
if( !screens.GetScreen( i )->IsModify() )
|
||||
continue;
|
||||
|
||||
tmpFileName = fn = screens.GetScreen( i )->GetFileName();
|
||||
|
|
|
@ -783,7 +783,6 @@ void SCH_EDIT_FRAME::OnModify()
|
|||
return;
|
||||
|
||||
GetScreen()->SetModify();
|
||||
GetScreen()->SetSave();
|
||||
|
||||
if( ADVANCED_CFG::GetCfg().m_RealTimeConnectivity && CONNECTION_GRAPH::m_allowRealTime )
|
||||
RecalculateConnections( NO_CLEANUP );
|
||||
|
@ -1099,13 +1098,7 @@ bool SCH_EDIT_FRAME::isAutoSaveRequired() const
|
|||
|
||||
if( Schematic().IsValid() )
|
||||
{
|
||||
SCH_SCREENS screenList( Schematic().Root() );
|
||||
|
||||
for( SCH_SCREEN* screen = screenList.GetFirst(); screen; screen = screenList.GetNext() )
|
||||
{
|
||||
if( screen->IsSave() )
|
||||
return true;
|
||||
}
|
||||
return IsContentModified();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -1555,7 +1548,7 @@ void SCH_EDIT_FRAME::FixupJunctions()
|
|||
}
|
||||
|
||||
|
||||
bool SCH_EDIT_FRAME::IsContentModified()
|
||||
bool SCH_EDIT_FRAME::IsContentModified() const
|
||||
{
|
||||
return Schematic().GetSheets().IsModified();
|
||||
}
|
||||
|
|
|
@ -175,7 +175,7 @@ public:
|
|||
*
|
||||
* @return true if the any changes have not been saved
|
||||
*/
|
||||
bool IsContentModified() override;
|
||||
bool IsContentModified() const override;
|
||||
|
||||
/**
|
||||
* Must be called after a schematic change in order to set the "modify" flag of the
|
||||
|
|
|
@ -1230,7 +1230,7 @@ bool SYMBOL_EDIT_FRAME::HasLibModifications() const
|
|||
}
|
||||
|
||||
|
||||
bool SYMBOL_EDIT_FRAME::IsContentModified()
|
||||
bool SYMBOL_EDIT_FRAME::IsContentModified() const
|
||||
{
|
||||
wxCHECK( m_libMgr, false );
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public:
|
|||
*
|
||||
* @return true if the any changes have not been saved
|
||||
*/
|
||||
bool IsContentModified() override;
|
||||
bool IsContentModified() const override;
|
||||
|
||||
/**
|
||||
* Check if any pending libraries have been modified.
|
||||
|
@ -100,7 +100,7 @@ public:
|
|||
*
|
||||
* This is a LIB_PART that I own, it is at best a copy of one in a library.
|
||||
*/
|
||||
LIB_PART* GetCurPart() { return m_my_part; }
|
||||
LIB_PART* GetCurPart() const { return m_my_part; }
|
||||
|
||||
/**
|
||||
* Take ownership of aPart and notes that it is the one currently being edited.
|
||||
|
|
|
@ -58,10 +58,7 @@ public:
|
|||
|
||||
void SetModify() { m_flagModified = true; }
|
||||
void ClrModify() { m_flagModified = false; }
|
||||
void SetSave() { m_flagSave = true; }
|
||||
void ClrSave() { m_flagSave = false; }
|
||||
bool IsModify() const { return m_flagModified; }
|
||||
bool IsSave() const { return m_flagSave; }
|
||||
|
||||
/**
|
||||
* Return the class name.
|
||||
|
@ -134,7 +131,6 @@ protected:
|
|||
|
||||
private:
|
||||
bool m_flagModified; ///< Indicates current drawing has been modified.
|
||||
bool m_flagSave; ///< Indicates automatic file save.
|
||||
|
||||
/**
|
||||
* The cross hair position in logical (drawing) units. The cross hair is not the cursor
|
||||
|
|
|
@ -498,7 +498,7 @@ public:
|
|||
*
|
||||
* @return true if the contents of the frame have not been saved
|
||||
*/
|
||||
virtual bool IsContentModified();
|
||||
virtual bool IsContentModified() const;
|
||||
|
||||
/**
|
||||
* Get the undecorated window size that can be used for restoring the window size.
|
||||
|
|
|
@ -328,7 +328,7 @@ bool PL_EDITOR_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, i
|
|||
}
|
||||
|
||||
|
||||
bool PL_EDITOR_FRAME::IsContentModified()
|
||||
bool PL_EDITOR_FRAME::IsContentModified() const
|
||||
{
|
||||
return GetScreen() && GetScreen()->IsModify();
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ public:
|
|||
*
|
||||
* @return true if the any changes have not been saved
|
||||
*/
|
||||
bool IsContentModified() override;
|
||||
bool IsContentModified() const override;
|
||||
|
||||
/*
|
||||
* Function OnExit
|
||||
|
|
|
@ -1065,7 +1065,6 @@ bool PCB_EDIT_FRAME::SavePcbFile( const wxString& aFileName, bool addToHistory,
|
|||
m_infoBar->Dismiss();
|
||||
|
||||
GetScreen()->ClrModify();
|
||||
GetScreen()->ClrSave();
|
||||
UpdateTitle();
|
||||
return true;
|
||||
}
|
||||
|
@ -1140,6 +1139,10 @@ bool PCB_EDIT_FRAME::doAutoSave()
|
|||
{
|
||||
wxFileName tmpFileName;
|
||||
|
||||
// Don't run autosave if content has not been modified
|
||||
if( !IsContentModified() )
|
||||
return true;
|
||||
|
||||
wxString title = GetTitle(); // Save frame title, that can be modified by the save process
|
||||
|
||||
if( GetBoard()->GetFileName().IsEmpty() )
|
||||
|
|
|
@ -316,7 +316,7 @@ FOOTPRINT_EDIT_FRAME::~FOOTPRINT_EDIT_FRAME()
|
|||
}
|
||||
|
||||
|
||||
bool FOOTPRINT_EDIT_FRAME::IsContentModified()
|
||||
bool FOOTPRINT_EDIT_FRAME::IsContentModified() const
|
||||
{
|
||||
return GetScreen() && GetScreen()->IsModify() && GetBoard() && GetBoard()->GetFirstFootprint();
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
*
|
||||
* @return true if the any changes have not been saved
|
||||
*/
|
||||
bool IsContentModified() override;
|
||||
bool IsContentModified() const override;
|
||||
|
||||
bool IsCurrentFPFromBoard() const;
|
||||
|
||||
|
|
|
@ -690,7 +690,6 @@ void PCB_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars
|
|||
void PCB_BASE_FRAME::OnModify()
|
||||
{
|
||||
GetScreen()->SetModify();
|
||||
GetScreen()->SetSave();
|
||||
|
||||
GetBoard()->IncrementTimeStamp();
|
||||
|
||||
|
|
|
@ -447,7 +447,7 @@ void PCB_EDIT_FRAME::SetPageSettings( const PAGE_INFO& aPageSettings )
|
|||
}
|
||||
|
||||
|
||||
bool PCB_EDIT_FRAME::IsContentModified()
|
||||
bool PCB_EDIT_FRAME::IsContentModified() const
|
||||
{
|
||||
return GetScreen() && GetScreen()->IsModify();
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ bool PCB_EDIT_FRAME::IsContentModified()
|
|||
bool PCB_EDIT_FRAME::isAutoSaveRequired() const
|
||||
{
|
||||
if( GetScreen() )
|
||||
return GetScreen()->IsSave();
|
||||
return GetScreen()->IsModify();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ public:
|
|||
*
|
||||
* @return true if the any changes have not been saved
|
||||
*/
|
||||
bool IsContentModified() override;
|
||||
bool IsContentModified() const override;
|
||||
|
||||
/**
|
||||
* Reload the Python plugins if they are newer than the already loaded, and load new
|
||||
|
|
Loading…
Reference in New Issue