Push autosave-require down in to EDA_BASE_FRAME.
Fixes https://gitlab.com/kicad/code/kicad/issues/11790
This commit is contained in:
parent
be6f08deca
commit
3221877fe8
|
@ -127,6 +127,7 @@ void EDA_BASE_FRAME::commonInit( FRAME_T aFrameType )
|
|||
m_isClosing = false;
|
||||
m_isNonUserClose = false;
|
||||
m_autoSaveTimer = new wxTimer( this, ID_AUTO_SAVE_TIMER );
|
||||
m_autoSaveRequired = false;
|
||||
m_mruPath = PATHS::GetDefaultUserProjectsPath();
|
||||
m_frameSize = defaultSize( aFrameType );
|
||||
m_displayIndex = -1;
|
||||
|
@ -1300,6 +1301,12 @@ PICKED_ITEMS_LIST* EDA_BASE_FRAME::PopCommandFromRedoList( )
|
|||
}
|
||||
|
||||
|
||||
void EDA_BASE_FRAME::OnModify()
|
||||
{
|
||||
m_autoSaveRequired = true;
|
||||
}
|
||||
|
||||
|
||||
void EDA_BASE_FRAME::ChangeUserUnits( EDA_UNITS aUnits )
|
||||
{
|
||||
SetUserUnits( aUnits );
|
||||
|
|
|
@ -1033,6 +1033,9 @@ bool SCH_EDIT_FRAME::SaveProject( bool aSaveAs )
|
|||
success &= saveSchematicFile( screens.GetSheet( i ), tmpFn.GetFullPath() );
|
||||
}
|
||||
|
||||
if( success )
|
||||
m_autoSaveRequired = false;
|
||||
|
||||
// One or more of the modified sheets did not save correctly so update the auto save file.
|
||||
if( !aSaveAs && !success )
|
||||
success &= updateAutoSaveFile();
|
||||
|
@ -1154,10 +1157,11 @@ bool SCH_EDIT_FRAME::doAutoSave()
|
|||
|
||||
if( autoSaveOk && updateAutoSaveFile() )
|
||||
{
|
||||
m_autoSaveRequired = false;
|
||||
m_autoSavePending = false;
|
||||
|
||||
if( !Kiface().IsSingle() &&
|
||||
GetSettingsManager()->GetCommonSettings()->m_Backup.backup_on_autosave )
|
||||
if( !Kiface().IsSingle()
|
||||
&& GetSettingsManager()->GetCommonSettings()->m_Backup.backup_on_autosave )
|
||||
{
|
||||
GetSettingsManager()->TriggerBackupIfNeeded( NULL_REPORTER::GetInstance() );
|
||||
}
|
||||
|
|
|
@ -240,12 +240,6 @@ public:
|
|||
*/
|
||||
void SyncView();
|
||||
|
||||
/**
|
||||
* Must be called after a model change in order to set the "modify" flag and
|
||||
* do other frame-specific processing.
|
||||
*/
|
||||
virtual void OnModify() {}
|
||||
|
||||
void CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVarsChanged ) override;
|
||||
|
||||
/**
|
||||
|
|
|
@ -955,12 +955,15 @@ wxString SCH_EDIT_FRAME::GetUniqueFilenameForCurrentSheet()
|
|||
|
||||
void SCH_EDIT_FRAME::OnModify()
|
||||
{
|
||||
EDA_BASE_FRAME::OnModify();
|
||||
|
||||
wxASSERT( GetScreen() );
|
||||
|
||||
if( !GetScreen() )
|
||||
return;
|
||||
|
||||
GetScreen()->SetContentModified();
|
||||
m_autoSaveRequired = true;
|
||||
|
||||
if( ADVANCED_CFG::GetCfg().m_RealTimeConnectivity && CONNECTION_GRAPH::m_allowRealTime )
|
||||
RecalculateConnections( NO_CLEANUP );
|
||||
|
@ -1281,20 +1284,6 @@ void SCH_EDIT_FRAME::PrintPage( const RENDER_SETTINGS* aSettings )
|
|||
}
|
||||
|
||||
|
||||
bool SCH_EDIT_FRAME::isAutoSaveRequired() const
|
||||
{
|
||||
// In case this event happens before g_RootSheet is initialized which does happen
|
||||
// on mingw64 builds.
|
||||
|
||||
if( Schematic().IsValid() )
|
||||
{
|
||||
return IsContentModified();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void SCH_EDIT_FRAME::AutoRotateItem( SCH_SCREEN* aScreen, SCH_ITEM* aItem )
|
||||
{
|
||||
if( aItem->IsType( { SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T } ) )
|
||||
|
|
|
@ -144,8 +144,8 @@ public:
|
|||
bool IsContentModified() const override;
|
||||
|
||||
/**
|
||||
* Must be called after a schematic change in order to set the "modify" flag of the
|
||||
* current screen and update the date in frame reference.
|
||||
* Must be called after a schematic change in order to set the "modify" flag and update other
|
||||
* data structures and GUI elements.
|
||||
*/
|
||||
void OnModify() override;
|
||||
|
||||
|
@ -840,11 +840,6 @@ protected:
|
|||
*/
|
||||
bool doAutoSave() override;
|
||||
|
||||
/**
|
||||
* Return true if the schematic has been modified.
|
||||
*/
|
||||
bool isAutoSaveRequired() const override;
|
||||
|
||||
/**
|
||||
* Send the KiCad netlist over to CVPCB.
|
||||
*/
|
||||
|
|
|
@ -828,7 +828,10 @@ LIB_SYMBOL_LIBRARY_MANAGER& SYMBOL_EDIT_FRAME::GetLibManager()
|
|||
|
||||
void SYMBOL_EDIT_FRAME::OnModify()
|
||||
{
|
||||
EDA_BASE_FRAME::OnModify();
|
||||
|
||||
GetScreen()->SetContentModified();
|
||||
m_autoSaveRequired = true;
|
||||
|
||||
if( !IsSymbolFromSchematic() )
|
||||
storeCurrentSymbol();
|
||||
|
|
|
@ -564,6 +564,12 @@ public:
|
|||
|
||||
int GetMaxUndoItems() const { return m_undoRedoCountMax; }
|
||||
|
||||
/**
|
||||
* Must be called after a model change in order to set the "modify" flag and do other
|
||||
* frame-specific processing.
|
||||
*/
|
||||
virtual void OnModify();
|
||||
|
||||
bool NonUserClose( bool aForce )
|
||||
{
|
||||
m_isNonUserClose = true;
|
||||
|
@ -606,7 +612,7 @@ protected:
|
|||
*
|
||||
* Override this function if your derived frame supports automatic file saving.
|
||||
*/
|
||||
virtual bool isAutoSaveRequired() const { return false; }
|
||||
virtual bool isAutoSaveRequired() const { return m_autoSaveRequired; }
|
||||
|
||||
/**
|
||||
* This should be overridden by the derived class to handle the auto save feature.
|
||||
|
@ -724,6 +730,7 @@ private:
|
|||
|
||||
bool m_supportsAutoSave;
|
||||
bool m_autoSavePending;
|
||||
bool m_autoSaveRequired;
|
||||
wxTimer* m_autoSaveTimer;
|
||||
|
||||
int m_undoRedoCountMax; // undo/Redo command Max depth
|
||||
|
|
|
@ -243,13 +243,10 @@ public:
|
|||
FOOTPRINT* GetFootprintFromBoardByReference();
|
||||
|
||||
/**
|
||||
* Must be called after a change in order to set the "modify" flag of the current screen
|
||||
* and update the date in frame reference.
|
||||
*
|
||||
* Do not forget to call this basic OnModify function to update info in derived OnModify
|
||||
* functions.
|
||||
* Must be called after a change in order to set the "modify" flag and update other data
|
||||
* structures and GUI elements.
|
||||
*/
|
||||
virtual void OnModify();
|
||||
void OnModify() override;
|
||||
|
||||
/**
|
||||
* Creates a new footprint, at position 0,0.
|
||||
|
|
|
@ -237,8 +237,10 @@ public:
|
|||
/**
|
||||
* Must be called after a change in order to set the "modify" flag.
|
||||
*/
|
||||
void OnModify()
|
||||
void OnModify() override
|
||||
{
|
||||
EDA_BASE_FRAME::OnModify();
|
||||
|
||||
GetScreen()->SetContentModified();
|
||||
}
|
||||
|
||||
|
|
|
@ -418,7 +418,15 @@ bool PCB_EDIT_FRAME::Files_io_from_id( int id )
|
|||
|
||||
case ID_SAVE_BOARD:
|
||||
if( !GetBoard()->GetFileName().IsEmpty() )
|
||||
return SavePcbFile( Prj().AbsolutePath( GetBoard()->GetFileName() ) );
|
||||
{
|
||||
if( SavePcbFile( Prj().AbsolutePath( GetBoard()->GetFileName() ) ) )
|
||||
{
|
||||
m_autoSaveRequired = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
KI_FALLTHROUGH;
|
||||
|
||||
|
@ -446,16 +454,24 @@ bool PCB_EDIT_FRAME::Files_io_from_id( int id )
|
|||
wxFileName fn( savePath.GetPath(), orig_name, KiCadPcbFileExtension );
|
||||
wxString filename = fn.GetFullPath();
|
||||
bool createProject = false;
|
||||
bool success = false;
|
||||
|
||||
if( AskSaveBoardFileName( this, &filename, &createProject ) )
|
||||
{
|
||||
if( id == ID_COPY_BOARD_AS )
|
||||
return SavePcbCopy( filename, createProject );
|
||||
{
|
||||
success = SavePcbCopy( filename, createProject );
|
||||
}
|
||||
else
|
||||
return SavePcbFile( filename, addToHistory, createProject );
|
||||
{
|
||||
success = SavePcbFile( filename, addToHistory, createProject );
|
||||
|
||||
if( success )
|
||||
m_autoSaveRequired = false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return success;
|
||||
}
|
||||
|
||||
default:
|
||||
|
@ -1246,6 +1262,7 @@ bool PCB_EDIT_FRAME::doAutoSave()
|
|||
GetScreen()->SetContentModified();
|
||||
GetBoard()->SetFileName( tmpFileName.GetFullPath() );
|
||||
UpdateTitle();
|
||||
m_autoSaveRequired = false;
|
||||
m_autoSavePending = false;
|
||||
|
||||
if( !Kiface().IsSingle() &&
|
||||
|
|
|
@ -995,7 +995,10 @@ void PCB_BASE_FRAME::CommonSettingsChanged( bool aEnvVarsChanged, bool aTextVars
|
|||
|
||||
void PCB_BASE_FRAME::OnModify()
|
||||
{
|
||||
EDA_BASE_FRAME::OnModify();
|
||||
|
||||
GetScreen()->SetContentModified();
|
||||
m_autoSaveRequired = true;
|
||||
|
||||
GetBoard()->IncrementTimeStamp();
|
||||
|
||||
|
|
|
@ -562,15 +562,6 @@ bool PCB_EDIT_FRAME::IsContentModified() const
|
|||
}
|
||||
|
||||
|
||||
bool PCB_EDIT_FRAME::isAutoSaveRequired() const
|
||||
{
|
||||
if( GetScreen() )
|
||||
return GetScreen()->IsContentModified();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
SELECTION& PCB_EDIT_FRAME::GetCurrentSelection()
|
||||
{
|
||||
return m_toolManager->GetTool<PCB_SELECTION_TOOL>()->GetSelection();
|
||||
|
|
|
@ -781,11 +781,6 @@ protected:
|
|||
*/
|
||||
bool doAutoSave() override;
|
||||
|
||||
/**
|
||||
* Return true if the board has been modified.
|
||||
*/
|
||||
bool isAutoSaveRequired() const override;
|
||||
|
||||
/**
|
||||
* Load the given filename but sets the path to the current project path.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue