13
0

Allow StateProtector to save pending files

This is in preparation for saving state while the session is
record-arm'ed. Most notably config changes and undo/redo.

In case both normal and pending save happens, pending must be
last and is required to recover from crashes during recording.
This commit is contained in:
Robin Gareus 2020-01-30 04:12:19 +01:00
parent 998fadda57
commit 0d127813fb
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 18 additions and 2 deletions

View File

@ -628,6 +628,10 @@ public:
_session->_save_queued = false; _session->_save_queued = false;
_session->save_state (""); _session->save_state ("");
} }
while (_session->_save_queued_pending) {
_session->_save_queued_pending = false;
_session->save_state ("", true);
}
} }
} }
private: private:
@ -1413,6 +1417,8 @@ private:
friend class StateProtector; friend class StateProtector;
gint _suspend_save; /* atomic */ gint _suspend_save; /* atomic */
volatile bool _save_queued; volatile bool _save_queued;
volatile bool _save_queued_pending;
Glib::Threads::Mutex save_state_lock; Glib::Threads::Mutex save_state_lock;
Glib::Threads::Mutex save_source_lock; Glib::Threads::Mutex save_source_lock;
Glib::Threads::Mutex peak_cleanup_lock; Glib::Threads::Mutex peak_cleanup_lock;

View File

@ -785,10 +785,20 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot
} }
if (g_atomic_int_get(&_suspend_save)) { if (g_atomic_int_get(&_suspend_save)) {
_save_queued = true; /* StateProtector cannot be used for templates or save-as */
assert (!template_only && !switch_to_snapshot && !for_archive && snapshot_name.empty ());
if (pending) {
_save_queued_pending = true;
} else {
_save_queued = true;
}
return 1; return 1;
} }
_save_queued = false; if (pending) {
_save_queued_pending = false;
} else {
_save_queued = false;
}
snapshot_t fork_state = NormalSave; snapshot_t fork_state = NormalSave;
if (!snapshot_name.empty() && snapshot_name != _current_snapshot_name && !template_only && !pending && !for_archive) { if (!snapshot_name.empty() && snapshot_name != _current_snapshot_name && !template_only && !pending && !for_archive) {