Blender V5.3
ed_undo.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2004 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <atomic>
10#include <cstring>
11
12#include "CLG_log.h"
13
14#include "DNA_key_types.h"
15#include "DNA_object_types.h"
16#include "DNA_scene_types.h"
17
18#include "BLI_listbase.hh"
19#include "BLI_task_c.hh"
20#include "BLI_utildefines.hh"
21#include "BLI_vector.hh"
22
23#include "BKE_blender_undo.hh"
24#include "BKE_callbacks.hh"
25#include "BKE_context.hh"
26#include "BKE_global.hh"
27#include "BKE_layer.hh"
28#include "BKE_main.hh"
29#include "BKE_object.hh"
30#include "BKE_paint.hh"
31#include "BKE_report.hh"
32#include "BKE_scene.hh"
33#include "BKE_screen.hh"
34#include "BKE_undo_system.hh"
35#include "BKE_workspace.hh"
36
37#include "BLO_blend_validate.hh"
38
39#include "ED_asset.hh"
40#include "ED_gpencil_legacy.hh"
41#include "ED_object.hh"
42#include "ED_outliner.hh"
43#include "ED_render.hh"
44#include "ED_screen.hh"
45#include "ED_sculpt.hh"
46#include "ED_undo.hh"
47
48#include "WM_api.hh"
49#include "WM_toolsystem.hh"
50#include "WM_types.hh"
51
52#include "RNA_access.hh"
53#include "RNA_define.hh"
54#include "RNA_enum_types.hh"
55#include "RNA_prototypes.hh"
56
57namespace blender {
58
60static CLG_LogRef LOG = {"undo"};
61
62/* -------------------------------------------------------------------- */
67
69{
71
72 /* Currently only checks matching begin/end calls. */
73 if (wm->runtime->undo_stack == nullptr) {
74 /* No undo stack is valid, nothing to do. */
75 return true;
76 }
77 if (wm->runtime->undo_stack->group_level != 0) {
78 /* If this fails #ED_undo_grouped_begin, #ED_undo_grouped_end calls don't match. */
79 return false;
80 }
81 if (wm->runtime->undo_stack->step_active != nullptr) {
82 if (wm->runtime->undo_stack->step_active->skip == true) {
83 /* Skip is only allowed between begin/end calls,
84 * a state that should never happen in main event loop. */
85 return false;
86 }
87 }
88 return true;
89}
90
96
98{
100 BKE_undosys_stack_group_end(wm->runtime->undo_stack);
101}
102
103void ED_undo_push(bContext *C, const char *str, UndoEncodeHints hints)
104{
105 CLOG_INFO(&LOG, "Push '%s'", str);
107
109 if (G.background) {
110 /* Python developers may have explicitly created the undo stack in background mode,
111 * otherwise allow it to be nullptr, see: #60934.
112 * Otherwise it must never be nullptr, even when undo is disabled. */
113 if (wm->runtime->undo_stack == nullptr) {
114 return;
115 }
116 }
117
118 int steps = U.undosteps;
119
120 /* Ensure steps that have been initialized are always pushed,
121 * even when undo steps are zero.
122 *
123 * Note that some modes (paint, sculpt) initialize an undo step before an action runs,
124 * then accumulate changes there, or restore data from it in the case of 2D painting.
125 *
126 * For this reason we need to handle the undo step even when undo steps is set to zero.
127 */
128 if ((steps <= 0) && wm->runtime->undo_stack->step_init != nullptr) {
129 steps = 1;
130 }
131 if (steps <= 0) {
132 return;
133 }
134
135 eUndoPushReturn push_retval;
136
137 /* Only apply limit if this is the last undo step. */
138 if (wm->runtime->undo_stack->step_active &&
139 (wm->runtime->undo_stack->step_active->next == nullptr))
140 {
141 BKE_undosys_stack_limit_steps_and_memory(wm->runtime->undo_stack, steps - 1, 0);
142 }
143
144 push_retval = BKE_undosys_step_push(wm->runtime->undo_stack, C, str, hints);
145
146 if (U.undomemory != 0) {
147 const size_t memory_limit = size_t(U.undomemory) * 1024 * 1024;
148 BKE_undosys_stack_limit_steps_and_memory(wm->runtime->undo_stack, -1, memory_limit);
149 }
150
152 BKE_undosys_print(wm->runtime->undo_stack);
153 }
154
155 if (push_retval & UNDO_PUSH_RET_OVERRIDE_CHANGED) {
157 }
158}
159
165 const enum eUndoStepDir undo_dir,
166 ReportList *reports)
167{
168 BLI_assert(ELEM(undo_dir, STEP_UNDO, STEP_REDO));
169
170 Main *bmain = CTX_data_main(C);
171 Scene *scene = CTX_data_scene(C);
172
173 /* undo during jobs are running can easily lead to freeing data using by jobs,
174 * or they can just lead to freezing job in some other cases */
177
178 if (G.debug & G_DEBUG_IO) {
179 if (bmain->lock != nullptr) {
181 reports, RPT_DEBUG, "Checking validity of current .blend file *BEFORE* undo step");
182 BLO_main_validate_libraries(bmain, reports);
183 }
184 }
185
186 /* App-Handlers (pre). */
187 {
188 /* NOTE: ignore grease pencil for now. */
189 wm->op_undo_depth++;
191 bmain, &scene->id, (undo_dir == STEP_UNDO) ? BKE_CB_EVT_UNDO_PRE : BKE_CB_EVT_REDO_PRE);
192 wm->op_undo_depth--;
193 }
194}
195
203 const enum eUndoStepDir undo_dir,
204 ReportList *reports)
205{
206 using namespace blender::ed;
207 BLI_assert(ELEM(undo_dir, STEP_UNDO, STEP_REDO));
208
209 Main *bmain = CTX_data_main(C);
210 Scene *scene = CTX_data_scene(C);
211
212 /* App-Handlers (post). */
213 {
214 wm->op_undo_depth++;
216 bmain, &scene->id, (undo_dir == STEP_UNDO) ? BKE_CB_EVT_UNDO_POST : BKE_CB_EVT_REDO_POST);
217 wm->op_undo_depth--;
218 }
219
220 if (G.debug & G_DEBUG_IO) {
221 if (bmain->lock != nullptr) {
222 BKE_report(reports, RPT_INFO, "Checking validity of current .blend file *AFTER* undo step");
223 BLO_main_validate_libraries(bmain, reports);
224 }
225 }
226
227 /* Undo/redo may have invalidated a lot of data, ensure UI has also been fully updated before
228 * handling next events. */
230
233
236
238
240 BKE_undosys_print(wm->runtime->undo_stack);
241 }
242}
243
250 enum eUndoStepDir step,
251 ReportList *reports)
252{
254
255 CLOG_INFO(&LOG, "Step direction=%s", (step == STEP_UNDO) ? "STEP_UNDO" : "STEP_REDO");
256
258
259 ed_undo_step_pre(C, wm, step, reports);
260
261 if (step == STEP_UNDO) {
262 BKE_undosys_step_undo(wm->runtime->undo_stack, C);
263 }
264 else {
265 BKE_undosys_step_redo(wm->runtime->undo_stack, C);
266 }
267
268 ed_undo_step_post(C, wm, step, reports);
269
270 return OPERATOR_FINISHED;
271}
272
278static int ed_undo_step_by_name(bContext *C, const char *undo_name, ReportList *reports)
279{
280 BLI_assert(undo_name != nullptr);
281
283 UndoStep *undo_step_from_name = BKE_undosys_step_find_by_name(wm->runtime->undo_stack,
284 undo_name);
285 if (undo_step_from_name == nullptr) {
286 CLOG_ERROR(&LOG, "Step name='%s' not found in current undo stack", undo_name);
287
288 return OPERATOR_CANCELLED;
289 }
290
291 UndoStep *undo_step_target = undo_step_from_name->prev;
292 if (undo_step_target == nullptr) {
293 CLOG_ERROR(&LOG, "Step name='%s' cannot be undone", undo_name);
294
295 return OPERATOR_CANCELLED;
296 }
297
298 const int undo_dir_i = BKE_undosys_step_calc_direction(
299 wm->runtime->undo_stack, undo_step_target, nullptr);
300 BLI_assert(ELEM(undo_dir_i, -1, 1));
301 const enum eUndoStepDir undo_dir = (undo_dir_i == -1) ? STEP_UNDO : STEP_REDO;
302
303 CLOG_INFO(&LOG,
304 "Step name='%s', found direction=%s",
305 undo_name,
306 (undo_dir == STEP_UNDO) ? "STEP_UNDO" : "STEP_REDO");
307
308 ed_undo_step_pre(C, wm, undo_dir, reports);
309
310 BKE_undosys_step_load_data_ex(wm->runtime->undo_stack, C, undo_step_target, nullptr, true);
311
312 ed_undo_step_post(C, wm, undo_dir, reports);
313
314 return OPERATOR_FINISHED;
315}
316
322static int ed_undo_step_by_index(bContext *C, const int undo_index, ReportList *reports)
323{
324 BLI_assert(undo_index >= 0);
325
327 const int active_step_index = BLI_findindex(&wm->runtime->undo_stack->steps,
328 wm->runtime->undo_stack->step_active);
329 if (undo_index == active_step_index) {
330 return OPERATOR_CANCELLED;
331 }
332 const enum eUndoStepDir undo_dir = (undo_index < active_step_index) ? STEP_UNDO : STEP_REDO;
333
334 CLOG_INFO(&LOG,
335 "Step index='%d', found direction=%s",
336 undo_index,
337 (undo_dir == STEP_UNDO) ? "STEP_UNDO" : "STEP_REDO");
338
339 ed_undo_step_pre(C, wm, undo_dir, reports);
340
341 BKE_undosys_step_load_from_index(wm->runtime->undo_stack, C, undo_index);
342
343 ed_undo_step_post(C, wm, undo_dir, reports);
344
345 return OPERATOR_FINISHED;
346}
347
348static bool ed_undo_grouped_check_by_name(const UndoStack *ustack, const char *str)
349{
350 const UndoStep *us = ustack->step_active;
351 if (us && STREQ(str, us->name)) {
352 return true;
353 }
354 return false;
355}
356
358{
359 /* do nothing if previous undo task is the same as this one (or from the same undo group) */
361 UndoStack *ustack = wm->runtime->undo_stack;
362 /* See matching check in #ED_undo_push. */
363 if (G.background) {
364 if (ustack == nullptr) {
365 return;
366 }
367 }
368 if (ed_undo_grouped_check_by_name(ustack, str)) {
370 }
371
372 /* push as usual */
373 ED_undo_push(C, str, hints);
374}
375
377{
379}
381{
383}
384
395static void ed_undo_push_check_id_changes_fn(TaskPool *__restrict pool, void *taskdata)
396{
397 const ID *id_first = static_cast<const ID *>(taskdata);
398 std::atomic<bool> &modified = *static_cast<std::atomic<bool> *>(BLI_task_pool_user_data(pool));
399
400 /* The #ID_KE & edit-mode id-types are typically only hit when Python scripts modify ID
401 * (keys or object-data) while inside edit-mode that is not itself edit-mode data.
402 * While this isn't common it's not an error and should be supported. */
403
404 const ID_Type id_type = GS(id_first->name);
405 if (id_type == ID_OB) {
406 /* Object (particle system edit-mode only). */
407 for (const ID *id = id_first; id && !modified.load(); id = static_cast<ID *>(id->next)) {
408 if (id->recalc_after_undo_push == false) {
409 continue;
410 }
411
412 /* - Every particle-edit stroke tags the underlying object.
413 * - This doesn't give us a convenient way to differentiate
414 * between particle system & other object data.
415 * - Resolve by checking #ID_RECALC_PSYS_ALL
416 *
417 * Not ideal but the alternative would be not to support particle-editing at all. */
418 const Object *ob = reinterpret_cast<const Object *>(id);
419 if (ob->mode & OB_MODE_PARTICLE_EDIT) {
420 if ((id->recalc_after_undo_push & ~(ID_RECALC_PSYS_ALL)) == 0) {
421 continue;
422 }
423 }
424 modified.store(true); /* Breaks. */
425 }
426 }
427 else if (id_type == ID_KE) {
428 /* Key-blocks (check for edit-mode). */
429 for (const ID *id = id_first; id && !modified.load(); id = static_cast<ID *>(id->next)) {
430 if (id->recalc_after_undo_push == false) {
431 continue;
432 }
433 /* Skip shape-keys on data in edit-mode for the same reason
434 * as the #OB_DATA_SUPPORT_EDITMODE below. */
435 const ID *key_from = reinterpret_cast<const ID *>(reinterpret_cast<const Key *>(id)->from);
436 if (key_from && OB_DATA_SUPPORT_EDITMODE(GS(key_from->name)) &&
437 BKE_object_data_is_in_editmode(nullptr, key_from))
438 {
439 continue;
440 }
441 modified.store(true); /* Breaks. */
442 }
443 }
444 else if (OB_DATA_SUPPORT_EDITMODE(id_type)) {
445 /* Object data (check for edit-mode). */
446 for (const ID *id = id_first; id && !modified.load(); id = static_cast<ID *>(id->next)) {
447 if (id->recalc_after_undo_push == false) {
448 continue;
449 }
450
451 /* Skip data in edit-mode: changes are stored by the modes own undo system and
452 * practically all edit-mode operations tag the data being edited. */
453 if (BKE_object_data_is_in_editmode(nullptr, id)) {
454 continue;
455 }
456 modified.store(true); /* Breaks. */
457 }
458 }
459 else {
460 /* Any ID types. */
461 for (const ID *id = id_first; id && !modified.load(); id = static_cast<ID *>(id->next)) {
462 if (id->recalc_after_undo_push == false) {
463 continue;
464 }
465 modified.store(true); /* Breaks. */
466 }
467 }
468}
469
479{
480 /* ID's added/removed/renamed. */
481 if (bmain->is_memfile_undo_written == false) {
482 return true;
483 }
484
485 /* Gather modified ID's, skipping ID types that are not stored by undo. */
487 const MainListsArray lbarray = BKE_main_lists_get(*bmain);
488 for (const ListBaseT<ID> *lb : lbarray) {
489 const ID *id_first = lb->first();
490 if ((id_first == nullptr) || !ID_CHECK_UNDO(id_first)) {
491 continue;
492 }
493 ids.append(id_first);
494 }
495
496 /* Check the gathered ID's in parallel, one task per ID type.
497 *
498 * NOTE(@ideasman42): This may create some tasks without much work:
499 * Something we typically want to avoid. We could optimize this by doing
500 * a single threaded pass on the first N items in each list.
501 * However it adds code complexity without solving any real world problem.
502 * Accept the overhead in the case where there isn't much work to improve
503 * the worst when there are many ID's. */
504 std::atomic<bool> modified = false;
505 TaskPool *task_pool = BLI_task_pool_create(&modified, TASK_PRIORITY_HIGH);
506 for (const ID *id_first : ids) {
507 if (modified.load()) {
508 break;
509 }
511 task_pool, ed_undo_push_check_id_changes_fn, const_cast<ID *>(id_first), false, nullptr);
512 }
514 BLI_task_pool_free(task_pool);
515
516 return modified.load();
517}
518
520{
521 const UndoStack *ustack = CTX_wm_manager(C)->runtime->undo_stack;
523
524 /* The undo stack may be null in background mode where undo pushes are a no-op,
525 * see matching check in #ED_undo_push. */
526 if (ustack == nullptr) {
527 return hints;
528 }
529
530 /* Match the undo type #BKE_undosys_step_push uses,
531 * the context is only a fallback when no undo step has been initialized. */
532 const UndoType *ut = ustack->step_init ? ustack->step_init->type :
534
535 if (ELEM(ut, nullptr, BKE_UNDOSYS_TYPE_MEMFILE)) {
536 return hints;
537 }
538
540 /* When the undo step for this operator is not stored in the memfile undo system,
541 * changes to ID's made by the operator would be excluded from the undo step.
542 * Request a memfile undo step before this operators step so they're included. */
543 Main *bmain = CTX_data_main(C);
545 CLOG_DEBUG(&LOG, "adding additional MEMFILE undo step: %s", str);
547 }
548 }
549
550 return hints;
551}
552
554{
556
557 /* in future, get undo string info? */
558 ED_undo_push(C, op->type->name, hints);
559}
560
562{
563 const char *str = (op->type->undo_group[0] != '\0') ? op->type->undo_group : op->type->name;
565 ED_undo_grouped_push(C, str, hints);
566}
567
569{
570 /* search back a couple of undo's, in case something else added pushes */
572}
573
574bool ED_undo_is_valid(const bContext *C, const char *undoname)
575{
577 UndoStack *ustack = wm->runtime->undo_stack;
578 return ustack && BKE_undosys_stack_has_undo(ustack, undoname);
579}
580
582{
584 UndoStack *ustack = wm->runtime->undo_stack;
585 return ustack && BKE_undosys_stack_has_redo(ustack);
586}
587
589{
590 /* Some modes don't co-exist with memfile undo, disable their use: #60593
591 * (this matches 2.7x behavior). */
592 const Main *bmain = CTX_data_main(C);
593 const Scene *scene = CTX_data_scene(C);
594 ViewLayer *view_layer = CTX_data_view_layer(C);
595 if (view_layer != nullptr) {
596 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
597 Object *obact = BKE_view_layer_active_object_get(view_layer);
598 if (obact != nullptr) {
599 if (obact->mode & OB_MODE_EDIT) {
600 return false;
601 }
602 }
603 }
604 return true;
605}
606
608 ID *id,
609 const PointerRNA &ptr,
610 const PropertyRNA &prop)
611{
612 if (!RNA_property_undo_check(&prop, ptr.type)) {
613 return std::nullopt;
614 }
615 /* If the whole ID type doesn't support undo there is no need to check the current context. */
616 if (id && !ID_CHECK_UNDO(id)) {
617 return std::nullopt;
618 }
619
620 if (ELEM(&prop,
621 /* Exception for renaming ID data, we always need undo pushes in this case,
622 * because undo systems track data by their ID, see: #67002. */
623 &rna_ID_name,
624 /* Exception for active shape-key, since changing this in edit-mode updates
625 * the shape key from object mode data. */
626 &rna_Object_active_shape_key_index))
627 {
629 }
630
631 Main *bmain = CTX_data_main(C);
632 const Scene *scene = CTX_data_scene(C);
633 ViewLayer *view_layer = CTX_data_view_layer(C);
634 if (view_layer != nullptr) {
635 BKE_view_layer_synced_ensure(*bmain, scene, view_layer);
636 Object *obact = BKE_view_layer_active_object_get(view_layer);
637 if (obact != nullptr) {
638 if (obact->mode & OB_MODE_SCULPT) {
639 /* Changing properties while in sculpt mode is expensive due to the paint BVH rebuild.
640 * Avoid pushing such undo steps for now. */
641 CLOG_DEBUG(&LOG, "skipping undo for sculpt-mode");
642 return std::nullopt;
643 }
644 if (obact->mode & OB_MODE_PARTICLE_EDIT) {
645 /* Particle-edit undo steps only store point-cache data
646 * (see #particle_undosys_step_encode), never generic ID/property state,
647 * so redirect property changes to a `memfile` step. */
649 }
650 if (obact->mode & OB_MODE_EDIT) {
651 /* Check if the `id` is covered by edit-mode undo. */
652
653 /* When the object is in edit-mode, returning None here is fine as the edit-mode
654 * data will track the undo state.
655 *
656 * Checking if the ID itself is in edit-mode ensures (for example),
657 * that a mesh pinned in the properties editor which is *not* in edit-mode
658 * has its undo data tracked even the active mesh is in edit-mode. */
659
660 const bool is_id_in_editmode = (id && obact->data &&
661 GS(id->name) == GS(((ID *)obact->data)->name) &&
662 /* Only object-data that stores it's own edit-mode
663 * data tracks it's own undo steps.
664 * So passing object as null is OK here. */
665 BKE_object_data_is_in_editmode(nullptr, id));
666
667 if (is_id_in_editmode == false) {
668 bool skip_undo = true;
669 /* Make a special exception for mesh and tool-settings
670 * because the undo steps store some tool-settings. */
671 if (obact->type == OB_MESH) {
672 if (RNA_struct_is_a(ptr.type, RNA_ToolSettings)) {
673 skip_undo = false;
674 }
675 }
676
677 if (skip_undo) {
678 /* The property isn't stored by edit-mode undo steps (id type mismatch),
679 * store the change in a memfile step, the edit-mode step has no changes itself. */
680 CLOG_DEBUG(&LOG, "memfile-only undo for edit-mode");
682 }
683 }
684 }
685 }
686 }
688}
689
691{
692 wmWindowManager *wm = G_MAIN->wm.first();
693 return wm->runtime->undo_stack;
694}
695
697
698/* -------------------------------------------------------------------- */
701
706{
707 /* The "last operator" should disappear, later we can tie this with undo stack nicer. */
709
710 /* Keep button under the cursor active. */
712
714}
715
717{
718 /* "last operator" should disappear, later we can tie this with undo stack nicer */
721 if (ret & OPERATOR_FINISHED) {
723 }
724 return ret;
725}
726
728{
729 if (G.background) {
730 /* Exception for background mode, see: #60934.
731 * NOTE: since the undo stack isn't initialized on startup, background mode behavior
732 * won't match regular usage, this is just for scripts to do explicit undo pushes. */
734 if (wm->runtime->undo_stack == nullptr) {
735 wm->runtime->undo_stack = BKE_undosys_stack_create();
736 }
737 }
738 char str[BKE_UNDO_STR_MAX];
739 RNA_string_get(op->ptr, "message", str);
741 return OPERATOR_FINISHED;
742}
743
752
754{
758 if (ret & OPERATOR_FINISHED) {
759 /* Keep button under the cursor active. */
761 }
762 return ret;
763}
764
765/* Disable in background mode, we could support if it's useful, #60934. */
766
768{
770 if (wm->runtime->undo_stack == nullptr) {
771 /* This message is intended for Python developers,
772 * it will be part of the exception when attempting to call undo in background mode. */
774 C,
775 "Undo disabled at startup in background-mode "
776 "(call `ed.undo_push()` to explicitly initialize the undo-system)");
777 return false;
778 }
779 return true;
780}
781
783{
784 if (ed_undo_is_init_poll(C) == false) {
785 return false;
786 }
788}
789
791{
793 return (last_op && ed_undo_is_init_and_screenactive_poll(C) &&
795}
796
798{
800 return false;
801 }
803 return (undo_stack->step_active != nullptr) && (undo_stack->step_active->prev != nullptr);
804}
805
807{
808 /* identifiers */
809 ot->name = "Undo";
810 ot->description = "Undo previous action";
811 ot->idname = "ED_OT_undo";
812
813 /* API callbacks. */
814 ot->exec = ed_undo_exec;
815 ot->poll = ed_undo_poll;
816}
817
819{
820 /* identifiers */
821 ot->name = "Undo Push";
822 ot->description = "Add an undo state (internal use only)";
823 ot->idname = "ED_OT_undo_push";
824
825 /* API callbacks. */
827 /* Unlike others undo operators this initializes undo stack. */
829
830 ot->flag = OPTYPE_INTERNAL;
831
833 "message",
834 "Add an undo step *function may be moved*",
836 "Undo Message",
837 "");
838}
839
841{
843 return false;
844 }
846 return (undo_stack->step_active != nullptr) && (undo_stack->step_active->next != nullptr);
847}
848
850{
851 /* identifiers */
852 ot->name = "Redo";
853 ot->description = "Redo previous action";
854 ot->idname = "ED_OT_redo";
855
856 /* API callbacks. */
857 ot->exec = ed_redo_exec;
858 ot->poll = ed_redo_poll;
859}
860
862{
863 /* identifiers */
864 ot->name = "Undo and Redo";
865 ot->description = "Undo and redo previous action";
866 ot->idname = "ED_OT_undo_redo";
867
868 /* API callbacks. */
871}
872
874
875/* -------------------------------------------------------------------- */
878
880{
881 bool success = false;
882
883 if (op) {
884 CLOG_INFO(&LOG, "Operator repeat idname='%s'", op->type->idname);
886 const ScrArea *area = CTX_wm_area(C);
887 Scene *scene = CTX_data_scene(C);
888
889 /* keep in sync with logic in view3d_panel_operator_redo() */
890 ARegion *region_orig = CTX_wm_region(C);
891 /* If the redo is called from a HUD, this knows about the region type the operator was
892 * initially called in, so attempt to restore that. */
893 ARegion *redo_region_from_hud = (region_orig->regiontype == RGN_TYPE_HUD) ?
894 ui::ED_area_type_hud_redo_region_find(area, region_orig) :
895 nullptr;
896 ARegion *region_repeat = redo_region_from_hud ? redo_region_from_hud :
898
899 if (region_repeat) {
900 CTX_wm_region_set(C, region_repeat);
901 }
902
904 /* NOTE: undo/redo can't run if there are jobs active,
905 * check for screen jobs only so jobs like material/texture/world preview
906 * (which copy their data), won't stop redo, see #29579.
907 *
908 * NOTE: WM_operator_check_ui_enabled() jobs test _must_ stay in sync with this. */
910 {
911 if (G.debug & G_DEBUG) {
912 printf("redo_cb: operator redo %s\n", op->type->name);
913 }
914
916
917 ED_undo_pop_op(C, op);
918
919 if (op->type->check) {
920 if (op->type->check(C, op)) {
921 /* check for popup and re-layout buttons */
922 ARegion *region_popup = CTX_wm_region_popup(C);
923 if (region_popup) {
924 ED_region_tag_refresh_ui(region_popup);
925 }
926 }
927 }
928
929 const wmOperatorStatus retval = WM_operator_repeat(C, op);
930 if ((retval & OPERATOR_FINISHED) == 0) {
931 if (G.debug & G_DEBUG) {
932 printf("redo_cb: operator redo failed: %s, return %d\n", op->type->name, retval);
933 }
935 }
936 else {
937 success = true;
938 }
939 }
940 else {
941 if (G.debug & G_DEBUG) {
942 printf("redo_cb: WM_operator_repeat_check returned false %s\n", op->type->name);
943 }
944 }
945
946 /* set region back */
947 CTX_wm_region_set(C, region_orig);
948 }
949 else {
950 CLOG_WARN(&LOG, "called with nullptr 'op'");
951 }
952
953 return success;
954}
955
956void ED_undo_operator_repeat_cb(bContext *C, void *arg_op, void * /*arg_unused*/)
957{
958 ED_undo_operator_repeat(C, static_cast<wmOperator *>(arg_op));
959}
960
961void ED_undo_operator_repeat_cb_evt(bContext *C, void *arg_op, int /*arg_unused*/)
962{
963 ED_undo_operator_repeat(C, static_cast<wmOperator *>(arg_op));
964}
965
967
968/* -------------------------------------------------------------------- */
973
974/* NOTE: also check #ed_undo_step() in top if you change notifiers. */
976{
977 PropertyRNA *prop = RNA_struct_find_property(op->ptr, "item");
978 if (RNA_property_is_set(op->ptr, prop)) {
979 const int item = RNA_property_int_get(op->ptr, prop);
980 const int ret = ed_undo_step_by_index(C, item, op->reports);
981 if (ret & OPERATOR_FINISHED) {
983
985 return OPERATOR_FINISHED;
986 }
987 }
988 return OPERATOR_CANCELLED;
989}
990
992{
993 PropertyRNA *prop = RNA_struct_find_property(op->ptr, "item");
994 if (RNA_property_is_set(op->ptr, prop)) {
995 return undo_history_exec(C, op);
996 }
997
998 WM_menu_name_call(C, "TOPBAR_MT_undo_history", wm::OpCallContext::InvokeDefault);
999 return OPERATOR_FINISHED;
1000}
1001
1003{
1004 /* identifiers */
1005 ot->name = "Undo History";
1006 ot->description =
1007 "Undo or redo from the current active step until the specified action in history";
1008 ot->idname = "ED_OT_undo_history";
1009
1010 /* API callbacks. */
1012 ot->exec = undo_history_exec;
1014
1015 RNA_def_int(ot->srna, "item", 0, 0, INT_MAX, "Item", "", 0, INT_MAX);
1016}
1017
1019
1020/* -------------------------------------------------------------------- */
1023
1025 Scene *scene,
1026 ViewLayer *view_layer,
1027 Object *ob,
1028 const char *info,
1029 CLG_LogRef *log)
1030{
1031 using namespace blender::ed;
1032 BKE_view_layer_synced_ensure(bmain, scene, view_layer);
1033 Object *ob_prev = BKE_view_layer_active_object_get(view_layer);
1034 if (ob_prev != ob) {
1035 Base *base = BKE_view_layer_base_find(view_layer, ob);
1036 if (base != nullptr) {
1037 view_layer->basact = base;
1038 object::base_active_refresh(G_MAIN, scene, view_layer);
1039 }
1040 else {
1041 /* Should never fail, may not crash but can give odd behavior. */
1042 CLOG_WARN(log, "'%s' failed to restore active object: '%s'", info, ob->id.name + 2);
1043 }
1044 }
1045}
1046
1048 const Scene *scene_ref,
1049 Scene **scene_p,
1050 ViewLayer **view_layer_p)
1051{
1052 if (*scene_p == scene_ref) {
1053 return;
1054 }
1055 for (wmWindow &win : wm->windows) {
1056 if (win.scene == scene_ref) {
1057 *scene_p = win.scene;
1058 *view_layer_p = WM_window_get_active_view_layer(&win);
1059 return;
1060 }
1061 }
1062}
1063
1065 ViewLayer *view_layer,
1066 Object **object_array,
1067 uint object_array_len,
1068 uint object_array_stride)
1069{
1070 using namespace blender::ed;
1071 Main *bmain = G_MAIN;
1072 /* Don't request unique data because we want to de-select objects when exiting edit-mode
1073 * for that to be done on all objects we can't skip ones that share data. */
1074 Vector<Base *> bases = ED_undo_editmode_bases_from_view_layer(*bmain, scene, view_layer);
1075 for (Base *base : bases) {
1076 (base->object->data)->tag |= ID_TAG_DOIT;
1077 }
1078 Object **ob_p = object_array;
1079 for (uint i = 0; i < object_array_len;
1080 i++, ob_p = static_cast<Object **>(POINTER_OFFSET(ob_p, object_array_stride)))
1081 {
1082 Object *obedit = *ob_p;
1083 object::editmode_enter_ex(bmain, scene, obedit, object::EM_NO_CONTEXT);
1084 (obedit->data)->tag &= ~ID_TAG_DOIT;
1085 }
1086 for (Base *base : bases) {
1087 const ID *id = base->object->data;
1088 if (id->tag & ID_TAG_DOIT) {
1089 object::editmode_exit_ex(bmain, scene, base->object, object::EM_FREEDATA);
1090 /* Ideally we would know the selection state it was before entering edit-mode,
1091 * for now follow the convention of having them unselected when exiting the mode. */
1093 }
1094 }
1095}
1096
1098
1099/* -------------------------------------------------------------------- */
1108
1110 const Scene *scene,
1111 ViewLayer *view_layer)
1112{
1113 BKE_view_layer_synced_ensure(bmain, scene, view_layer);
1114 Base *baseact = BKE_view_layer_active_base_get(view_layer);
1115 if ((baseact == nullptr) || (baseact->object->mode & OB_MODE_EDIT) == 0) {
1116 return {};
1117 }
1118 Set<const ID *> object_data;
1119 const short object_type = baseact->object->type;
1120 Vector<Object *> objects(object_data.size());
1121 /* Base iteration, starting with the active-base to ensure it's the first item in the array.
1122 * Looping over the active-base twice is OK as the tag check prevents it being handled twice. */
1123 for (Base *base = baseact, *base_next = BKE_view_layer_object_bases_get(view_layer)->first();
1124 base;
1125 base = base_next, base_next = base_next ? base_next->next : nullptr)
1126 {
1127 Object *ob = base->object;
1128 if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) {
1129 if (object_data.add(static_cast<const ID *>(ob->data))) {
1130 objects.append(ob);
1131 }
1132 }
1133 }
1134 BLI_assert(!object_data.is_empty());
1135 BLI_assert(objects[0] == baseact->object);
1136 return objects;
1137}
1138
1140 const Scene *scene,
1141 ViewLayer *view_layer)
1142{
1143 BKE_view_layer_synced_ensure(bmain, scene, view_layer);
1144 Base *baseact = BKE_view_layer_active_base_get(view_layer);
1145 if ((baseact == nullptr) || (baseact->object->mode & OB_MODE_EDIT) == 0) {
1146 return {};
1147 }
1148 Set<const ID *> object_data;
1149 const short object_type = baseact->object->type;
1150 Vector<Base *> bases;
1151 /* Base iteration, starting with the active-base to ensure it's the first item in the array.
1152 * Looping over the active-base twice is OK as the tag check prevents it being handled twice. */
1153 for (Base *base = BKE_view_layer_active_base_get(view_layer),
1154 *base_next = BKE_view_layer_object_bases_get(view_layer)->first();
1155 base;
1156 base = base_next, base_next = base_next ? base_next->next : nullptr)
1157 {
1158 Object *ob = base->object;
1159 if ((ob->type == object_type) && (ob->mode & OB_MODE_EDIT)) {
1160 if (object_data.add(static_cast<const ID *>(ob->data))) {
1161 bases.append(base);
1162 }
1163 }
1164 }
1165
1166 BLI_assert(!object_data.is_empty());
1167 BLI_assert(bases[0] == baseact);
1168 return bases;
1169}
1170
1172{
1173 size_t total_memory = 0;
1174
1175 for (UndoStep *us = ustack->steps.first(); us != nullptr; us = us->next) {
1176 if (us->type == BKE_UNDOSYS_TYPE_SCULPT) {
1178 }
1179 else if (us->data_size > 0) {
1180 total_memory += us->data_size;
1181 }
1182 }
1183
1184 return total_memory;
1185}
1186
1188
1189} // namespace blender
#define BKE_UNDO_STR_MAX
#define G_MAIN
General operations, lookup, etc. for blender objects.
Utilities ensuring .blend file (i.e. Main) is in valid state during write and/or read process.
#define CLOG_ERROR(clg_ref,...)
Definition CLG_log.h:188
#define CLOG_DEBUG(clg_ref,...)
Definition CLG_log.h:191
#define CLOG_WARN(clg_ref,...)
Definition CLG_log.h:189
#define CLOG_CHECK(clg_ref, verbose_level,...)
Definition CLG_log.h:147
@ CLG_LEVEL_DEBUG
Definition CLG_log.h:62
#define CLOG_INFO(clg_ref,...)
Definition CLG_log.h:190
#define ID_CHECK_UNDO(id)
Definition DNA_ID.h:686
Object is a sort of wrapper for general info.
#define OB_DATA_SUPPORT_EDITMODE(_type)
#define C
Definition RandGen.cpp:29
#define NC_WINDOW
Definition WM_types.hh:388
#define NC_WM
Definition WM_types.hh:387
#define ND_LIB_OVERRIDE_CHANGED
Definition WM_types.hh:435
#define ND_UNDO
Definition WM_types.hh:433
#define ELEM(...)
#define POINTER_OFFSET(v, ofs)
#define STREQ(a, b)
int64_t size() const
Definition BLI_set.hh:606
bool add(const Key &key)
Definition BLI_set.hh:248
bool is_empty() const
Definition BLI_set.hh:614
void append(const T &value)
#define str(s)
#define INT_MAX
#define log
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
void base_select(Base *base, eObjectSelect_Mode mode)
bool editmode_enter_ex(Main *bmain, Scene *scene, Object *ob, int flag)
void base_active_refresh(Main *bmain, Scene *scene, ViewLayer *view_layer)
bool editmode_exit_ex(Main *bmain, Scene *scene, Object *obedit, int flag)
size_t step_memory_size_get(UndoStep *step)
ARegion * ED_area_type_hud_redo_region_find(const ScrArea *area, const ARegion *hud_region)
BMesh Iterators.
void WM_main_add_notifier(uint type, void *reference)
UserDef U
Definition blender.cc:58
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
void WM_toolsystem_refresh_active(bContext *C)
ARegion * BKE_area_find_region_active_win(const ScrArea *area)
Definition screen.cc:1037
std::array< ListBaseT< ID > *, INDEX_ID_MAX - 1 > MainListsArray
Definition BKE_main.hh:797
void ED_OT_undo_push(wmOperatorType *ot)
Definition ed_undo.cc:818
bool ED_undo_has_redo_step(const bContext *C)
Definition ed_undo.cc:581
ScrArea * CTX_wm_area(const bContext *C)
static bool ed_undo_poll(bContext *C)
Definition ed_undo.cc:797
static bool ed_undo_is_init_poll(bContext *C)
Definition ed_undo.cc:767
Object * BKE_view_layer_active_object_get(const ViewLayer *view_layer)
PropertyRNA * RNA_def_string(StructOrFunctionRNA *cont_, const char *identifier, const char *default_value, const int maxlen, const char *ui_name, const char *ui_description)
bool ED_undo_operator_repeat(bContext *C, wmOperator *op)
Definition ed_undo.cc:879
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
void ED_undo_grouped_push(bContext *C, const char *str, UndoEncodeHints hints=UndoEncodeHints(0))
Definition ed_undo.cc:357
bool ED_undo_is_memfile_compatible(const bContext *C)
Definition ed_undo.cc:588
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
unsigned int uint
Definition BKE_text.h:55
bool BKE_undosys_stack_has_undo(const UndoStack *ustack, const char *name)
void ED_OT_undo_redo(wmOperatorType *ot)
Definition ed_undo.cc:861
@ BKE_CB_EVT_REDO_POST
@ BKE_CB_EVT_UNDO_PRE
@ BKE_CB_EVT_UNDO_POST
@ BKE_CB_EVT_REDO_PRE
UndoStack * ED_undo_stack_get()
Definition ed_undo.cc:690
@ UNDOTYPE_FLAG_ENCODE_PRE_MEMFILE_SUPPORTED
void ED_preview_kill_jobs_for_undo(wmWindowManager *wm, Main *bmain)
static bool ed_undo_redo_poll(bContext *C)
Definition ed_undo.cc:790
bool ED_undo_is_state_valid(bContext *C)
Definition ed_undo.cc:68
@ TASK_PRIORITY_HIGH
Definition BLI_task_c.hh:61
void BKE_undosys_stack_clear_active(UndoStack *ustack)
@ WM_JOB_TYPE_ANY
Definition WM_api.hh:2008
void BKE_undosys_stack_group_end(UndoStack *ustack)
void ED_undo_object_set_active_or_warn(const Main &bmain, Scene *scene, ViewLayer *view_layer, Object *ob, const char *info, CLG_LogRef *log)
Definition ed_undo.cc:1024
static wmOperatorStatus ed_undo_step_direction(bContext *C, enum eUndoStepDir step, ReportList *reports)
Definition ed_undo.cc:249
static wmOperatorStatus ed_undo_redo_exec(bContext *C, wmOperator *)
Definition ed_undo.cc:753
void ED_outliner_select_sync_from_all_tag(bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
static wmOperatorStatus undo_history_invoke(bContext *C, wmOperator *op, const wmEvent *)
Definition ed_undo.cc:991
Base * BKE_view_layer_active_base_get(ViewLayer *view_layer)
void BKE_callback_exec_id(Main *bmain, ID *id, eCbEvent evt)
Definition callbacks.cc:45
MainListsArray BKE_main_lists_get(Main &bmain)
Definition main.cc:1158
void ED_OT_undo(wmOperatorType *ot)
Definition ed_undo.cc:806
void ED_OT_redo(wmOperatorType *ot)
Definition ed_undo.cc:849
UndoStack * BKE_undosys_stack_create()
Vector< Object * > ED_undo_editmode_objects_from_view_layer(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
Definition ed_undo.cc:1109
@ WM_JOB_BACKGROUND
Definition WM_api.hh:1999
void ED_undo_push_op(bContext *C, wmOperator *op)
Definition ed_undo.cc:553
ViewLayer * WM_window_get_active_view_layer(const wmWindow *win)
static void ed_undo_refresh_for_op(bContext *C)
Definition ed_undo.cc:705
std::optional< UndoEncodeHints > ED_undo_is_legacy_compatible_for_property(bContext *C, ID *id, const PointerRNA &ptr, const PropertyRNA &prop)
Definition ed_undo.cc:607
ViewLayer * CTX_data_view_layer(const bContext *C)
void ED_undo_operator_repeat_cb(bContext *C, void *arg_op, void *arg_unused)
Definition ed_undo.cc:956
static bool ed_undo_is_init_and_screenactive_poll(bContext *C)
Definition ed_undo.cc:782
void BLI_task_pool_work_and_wait(TaskPool *pool)
Definition task_pool.cc:455
void ED_undo_operator_repeat_cb_evt(bContext *C, void *arg_op, int arg_unused)
Definition ed_undo.cc:961
void * BLI_task_pool_user_data(TaskPool *pool)
Definition task_pool.cc:460
bool BLO_main_validate_libraries(Main *bmain, ReportList *reports)
Global G
Definition blender.cc:57
void ED_undo_grouped_push_op(bContext *C, wmOperator *op)
Definition ed_undo.cc:561
int BLI_findindex(const ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
Definition listbase.cc:593
bool RNA_property_undo_check(const PropertyRNA *prop, const StructRNA *type)
void BKE_undosys_stack_group_begin(UndoStack *ustack)
void CTX_wm_operator_poll_msg_set(bContext *C, const char *msg)
static void ed_undo_push_check_id_changes_fn(TaskPool *__restrict pool, void *taskdata)
Definition ed_undo.cc:395
void WM_toolsystem_refresh_screen_all(Main *bmain)
eUndoStepDir BKE_undosys_step_calc_direction(const UndoStack *ustack, const UndoStep *us_target, const UndoStep *us_reference)
void ED_region_tag_refresh_ui(ARegion *region)
Definition area.cc:738
void ED_undo_redo(bContext *C)
Definition ed_undo.cc:380
void ED_undo_pop_op(bContext *C, wmOperator *op)
Definition ed_undo.cc:568
static wmOperatorStatus ed_redo_exec(bContext *C, wmOperator *op)
Definition ed_undo.cc:744
void BKE_undosys_print(UndoStack *ustack)
void BKE_undosys_step_load_from_index(UndoStack *ustack, bContext *C, int index)
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition report.cc:162
@ OB_MODE_PARTICLE_EDIT
bool WM_jobs_has_running(const wmWindowManager *window_manager, const void *owner, const eWM_JobType type, const eWM_JobFlag exclude_flags)
Definition wm_jobs.cc:809
wmWindowManager * CTX_wm_manager(const bContext *C)
wmOperatorStatus WM_operator_repeat(bContext *C, wmOperator *op)
void ED_undo_pop(bContext *C)
Definition ed_undo.cc:376
static int ed_undo_step_by_index(bContext *C, const int undo_index, ReportList *reports)
Definition ed_undo.cc:322
void ED_undo_push(bContext *C, const char *str, UndoEncodeHints hints=UndoEncodeHints(0))
Definition ed_undo.cc:103
static void ed_undo_step_post(bContext *C, wmWindowManager *wm, const enum eUndoStepDir undo_dir, ReportList *reports)
Definition ed_undo.cc:201
bool BKE_object_data_is_in_editmode(const Object *ob, const ID *id)
Definition object.cc:1932
void WM_menu_name_call(bContext *C, const char *menu_name, wm::OpCallContext context)
void WM_operator_free_all_after(wmWindowManager *wm, wmOperator *op)
Definition wm.cc:312
const UndoType * BKE_UNDOSYS_TYPE_SCULPT
bool BKE_view_layer_synced_ensure(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
const UndoType * BKE_UNDOSYS_TYPE_MEMFILE
Vector< Base * > ED_undo_editmode_bases_from_view_layer(const Main &bmain, const Scene *scene, ViewLayer *view_layer)
Definition ed_undo.cc:1139
static wmOperatorStatus ed_undo_push_exec(bContext *C, wmOperator *op)
Definition ed_undo.cc:727
bool BKE_undosys_step_undo(UndoStack *ustack, bContext *C)
void ED_OT_undo_history(wmOperatorType *ot)
Definition ed_undo.cc:1002
size_t ED_undosys_total_memory_calc(UndoStack *ustack)
Definition ed_undo.cc:1171
bool BKE_undosys_step_redo(UndoStack *ustack, bContext *C)
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
void ED_undo_group_begin(bContext *C)
Definition ed_undo.cc:91
void BLI_task_pool_free(TaskPool *pool)
Definition task_pool.cc:441
static void ed_undo_step_pre(bContext *C, wmWindowManager *wm, const enum eUndoStepDir undo_dir, ReportList *reports)
Definition ed_undo.cc:163
TaskPool * BLI_task_pool_create(void *userdata, eTaskPriority priority)
Definition task_pool.cc:404
static bool ed_undo_push_check_id_changes_outside_mode(Main *bmain)
Definition ed_undo.cc:478
@ UNDO_PUSH_RET_OVERRIDE_CHANGED
PropertyRNA * RNA_def_int(StructOrFunctionRNA *cont_, const char *identifier, const int default_value, const int hardmin, const int hardmax, const char *ui_name, const char *ui_description, const int softmin, const int softmax)
void WM_event_handling_break(const bContext &C)
void WM_operator_stack_clear(wmWindowManager *wm)
Definition wm.cc:375
void WM_file_tag_modified()
Definition wm_files.cc:188
Main * CTX_data_main(const bContext *C)
static UndoEncodeHints undo_encode_hints_from_context(bContext *C, const char *str)
Definition ed_undo.cc:519
@ ID_RECALC_PSYS_ALL
Definition DNA_ID.h:1193
ID_Type GS(const char *name)
Definition DNA_ID.h:410
ARegion * CTX_wm_region_popup(const bContext *C)
Base * BKE_view_layer_base_find(ViewLayer *view_layer, Object *ob)
@ ID_TAG_DOIT
Definition DNA_ID.h:1029
void BKE_undosys_stack_limit_steps_and_memory(UndoStack *ustack, int steps, size_t memory_limit)
bool BKE_undosys_stack_has_redo(const UndoStack *ustack)
wmOperator * WM_operator_last_redo(const bContext *C)
bool WM_operator_repeat_check(const bContext *, wmOperator *op)
static CLG_LogRef LOG
Definition logging.cpp:12
void ED_undo_object_editmode_restore_helper(Scene *scene, ViewLayer *view_layer, Object **object_array, uint object_array_len, uint object_array_stride)
Definition ed_undo.cc:1064
static bool ed_undo_grouped_check_by_name(const UndoStack *ustack, const char *str)
Definition ed_undo.cc:348
Scene * CTX_data_scene(const bContext *C)
static bool ed_redo_poll(bContext *C)
Definition ed_undo.cc:840
void CTX_wm_region_set(bContext *C, ARegion *region)
bool BKE_undosys_step_load_data_ex(UndoStack *ustack, bContext *C, UndoStep *us_target, UndoStep *us_reference, bool use_skip)
static int ed_undo_step_by_name(bContext *C, const char *undo_name, ReportList *reports)
Definition ed_undo.cc:278
UndoStep * BKE_undosys_step_find_by_name(UndoStack *ustack, const char *name)
@ OPTYPE_INTERNAL
Definition WM_types.hh:210
void WM_jobs_kill_all(wmWindowManager *wm)
Definition wm_jobs.cc:621
std::string RNA_string_get(PointerRNA *ptr, const char *name)
static wmOperatorStatus undo_history_exec(bContext *C, wmOperator *op)
Definition ed_undo.cc:975
void ED_undo_group_end(bContext *C)
Definition ed_undo.cc:97
void WM_event_add_mousemove(wmWindow *win)
bool WM_operator_check_ui_enabled(const bContext *C, const char *idname)
int RNA_property_int_get(PointerRNA *ptr, PropertyRNA *prop)
bool WM_operator_poll(bContext *C, wmOperatorType *ot)
const UndoType * BKE_undosys_type_from_context(bContext *C)
void BLI_task_pool_push(TaskPool *pool, TaskRunFunction run, void *taskdata, bool free_taskdata, TaskFreeFunction freedata)
Definition task_pool.cc:446
ARegion * CTX_wm_region(const bContext *C)
bool ED_undo_is_valid(const bContext *C, const char *undoname)
Definition ed_undo.cc:574
static wmOperatorStatus ed_undo_exec(bContext *C, wmOperator *op)
Definition ed_undo.cc:716
ListBaseT< Base > * BKE_view_layer_object_bases_get(ViewLayer *view_layer)
eUndoPushReturn BKE_undosys_step_push(UndoStack *ustack, bContext *C, const char *name, UndoEncodeHints hints)
bool RNA_property_is_set(PointerRNA *ptr, PropertyRNA *prop)
bool ED_operator_screenactive(bContext *C)
void ED_undo_object_editmode_validate_scene_from_windows(wmWindowManager *wm, const Scene *scene_ref, Scene **scene_p, ViewLayer **view_layer_p)
Definition ed_undo.cc:1047
eRegion_Type regiontype
struct Object * object
char name[258]
Definition DNA_ID.h:433
MainLock * lock
Definition BKE_main.hh:451
bool is_memfile_undo_written
Definition BKE_main.hh:297
StructRNA * type
Definition RNA_types.hh:63
ListBaseT< UndoStep > steps
const UndoType * type
const char * undo_group
Definition WM_types.hh:1117
wmOperatorStatus(*) exec(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1125
bool(*) check(bContext *C, wmOperator *op)
Definition WM_types.hh:1133
const char * description
Definition WM_types.hh:1115
bool(*) poll(bContext *C) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1165
wmOperatorStatus(*) invoke(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
Definition WM_types.hh:1141
struct ReportList * reports
struct wmOperatorType * type
bke::WindowManagerRuntime * runtime
#define undo_stack