zooui.objects.scene.sceneutils.autosave module¶
SceneAutosaveManager - Autosave functionality for Scene class.
This class manages automatic backup creation for scene files with configurable interval and rotation. It was extracted from the Scene class to improve modularity and maintainability.
- zooui.objects.scene.sceneutils.autosave.stop_timer_safely(timer)[source]¶
Safely stop a QTimer, ensuring thread safety.
This function ensures that QTimer.stop() is called from the same thread that created the timer, preventing Qt threading errors.
- Parameters:
timer – QTimer instance to stop, or None
- class zooui.objects.scene.sceneutils.autosave.SceneAutosaveManager(scene, config=None)[source]¶
Bases:
objectManager for scene autosave functionality.
This class handles automatic backup creation for scene files with configurable interval and rotation. It manages the backup timer, configuration, and integration with the BackupManager.
- _scene¶
Reference to the parent Scene object
- _logger¶
Logger instance for autosave operations
- _autosave_enabled¶
Whether autosave is enabled
- _autosave_interval¶
Autosave interval in seconds
- _autosave_config¶
Autosave configuration dictionary
- _autosave_timer¶
QTimer for periodic autosave
- _autosave_active¶
Whether autosave timer is active
- _backup_manager¶
BackupManager instance for creating backups
- _last_save_path¶
Path of last saved scene file
Initialize SceneAutosaveManager.
- Parameters:
scene – Parent Scene object
config – Optional configuration dictionary with autosave settings
- _enable_autosave_if_configured()[source]¶
Enable autosave if configured in settings.
Creates backup manager, runs expiration cleanup, and starts autosave timer.
- _trigger_autosave_backup(filename)[source]¶
Trigger autosave backup creation via BackupManager.
- Parameters:
filename – Path to the scene file to backup
- _autosave_timeout()[source]¶
Timer callback for periodic autosave.
Called when autosave timer expires to create a backup.
- enable_autosave(interval_minutes)[source]¶
Enable autosave with specified interval.
Starts QTimer for periodic autosave.
- Parameters:
interval_minutes – Autosave interval in minutes (minimum 1)
- cleanup_legacy_backups()[source]¶
Clean up legacy flat backup files from old backup structure.
Called during application shutdown to migrate from the old flat backup system to the new per-scene directory structure.
- Returns:
Number of legacy backup files deleted
- Return type:
int
- disable_autosave()[source]¶
Disable autosave and stop timer safely.
Idempotent: if autosave is already disabled, this is a no-op.
- is_autosave_enabled()[source]¶
Check if autosave is currently enabled.
- Returns:
True if autosave is enabled, False otherwise
- get_autosave_interval()[source]¶
Get current autosave interval in seconds.
- Returns:
Autosave interval in seconds
- get_autosave_config()[source]¶
Get autosave configuration.
- Returns:
Dictionary with autosave configuration
See Also¶
zooui/objects/scene/scene - Scene management
zooui/backup/backupmanager - Backup creation and rotation