Undo: support implicit-sharing in memfile undo step #106903

Merged
Jacques Lucke merged 78 commits from JacquesLucke/blender:implicit-sharing-undo into main 2024-02-29 17:15:09 +01:00
1 changed files with 14 additions and 2 deletions
Showing only changes of commit a2e0700867 - Show all commits

View File

@ -2058,20 +2058,32 @@ void wm_autosave_timer(Main *bmain, wmWindowManager *wm, wmTimer * /*wt*/)
{
wm_autosave_timer_end(wm);
/* Time to wait until the next attempt to autosave if it is disabled right now. */
const double try_again_time_step = 0.01;
/* If a modal operator is running, don't autosave because we might not be in
* a valid state to save. But try again in 10ms. */
* a valid state to save. */
LISTBASE_FOREACH (wmWindow *, win, &wm->windows) {
LISTBASE_FOREACH (wmEventHandler *, handler_base, &win->modalhandlers) {
if (handler_base->type == WM_HANDLER_TYPE_OP) {
wmEventHandler_Op *handler = (wmEventHandler_Op *)handler_base;
if (handler->op) {
wm_autosave_timer_begin_ex(wm, 0.01);
wm_autosave_timer_begin_ex(wm, try_again_time_step);
return;
}
}
}
}
LISTBASE_FOREACH (Object *, object, &bmain->objects) {
if (object->type == OB_MESH && object->mode & (OB_MODE_EDIT | OB_MODE_SCULPT)) {
/* Don't autosave in modes that require #ED_editors_flush_edits to be called because this can
* potentially be very slow. */
wm_autosave_timer_begin_ex(wm, try_again_time_step);
return;
}
}
wm_autosave_write(bmain);
/* Restart the timer after file write, just in case file write takes a long time. */