Crash after running bpy.ops.object.duplicate() followed by Undo #86293

Closed
opened 2021-03-04 22:36:14 +01:00 by Andreas · 16 comments

System Information
Operating system: Windows-10-10.0.19041-SP0 64 Bits
Graphics card: GeForce GTX 1050 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 456.71

Blender Version
Broken: version:

  • 2.93.0 Alpha, branch: master, commit date: 2021-03-02 09:14, hash: 8dec6452f2
  • 2.92.0, branch: master, commit date: 2021-02-24 16:25, hash: 02948a2cab
  • 2.91.2
  • 2.83.10
    Worked:
  • 2.82a

Short description of error
Crash after undoing bpy.ops.object.duplicate().

Exact steps for others to reproduce the error
Keep the default scene.
Deselect the Cube by clicking next to it.
Select the Cube.
Switch to Scripting, run bpy.ops.object.duplicate() in the Python console.
Edit->Undo

  • Blender closes unexpectedly

I've also noticed that when I start Blender, and run bpy.ops.object.duplicate() immediately with the Cube already selected, that there is no entry in the Undo history. Edit->Undo is grayed out. But bpy.ops.object.duplicate.bl_options contains 'UNDO', so I would expect an entry in the Undo history.

The same happens with bpy.ops.object.duplicate_move(). However, when I use Ctrl+D, Undo works as expected.

Edit: I just found the "Legacy Undo" option and #60695. But even with legacy undo, there's still no undo history entry after running bpy.ops.object.duplicate().

Possibly a duplicate of #80759.

**System Information** Operating system: Windows-10-10.0.19041-SP0 64 Bits Graphics card: GeForce GTX 1050 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 456.71 **Blender Version** Broken: version: - 2.93.0 Alpha, branch: master, commit date: 2021-03-02 09:14, hash: `8dec6452f2` - 2.92.0, branch: master, commit date: 2021-02-24 16:25, hash: `02948a2cab` - 2.91.2 - 2.83.10 Worked: - 2.82a **Short description of error** Crash after undoing `bpy.ops.object.duplicate()`. **Exact steps for others to reproduce the error** Keep the default scene. Deselect the Cube by clicking next to it. Select the Cube. Switch to Scripting, run `bpy.ops.object.duplicate()` in the Python console. Edit->Undo - > Blender closes unexpectedly I've also noticed that when I start Blender, and run `bpy.ops.object.duplicate()` immediately with the Cube already selected, that there is no entry in the Undo history. Edit->Undo is grayed out. But `bpy.ops.object.duplicate.bl_options` contains `'UNDO'`, so I would expect an entry in the Undo history. The same happens with `bpy.ops.object.duplicate_move()`. However, when I use Ctrl+D, Undo works as expected. Edit: I just found the "Legacy Undo" option and #60695. But even with legacy undo, there's still no undo history entry after running `bpy.ops.object.duplicate()`. Possibly a duplicate of #80759.
Author

Added subscriber: @ndh

Added subscriber: @ndh
Andreas changed title from Crash after `bpy.ops.object.duplicate()` to Crash after running `bpy.ops.object.duplicate()` followed by Undo 2021-03-04 22:48:34 +01:00

Added subscriber: @rjg

Added subscriber: @rjg

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'

I can reproduce the crash.

BKE_scene_object_base_flag_sync_from_base(Base * base) Line 2914	C
BKE_scene_set_background(Main * bmain, Scene * scene) Line 2126	C
setup_app_data(bContext * C, BlendFileData * bfd, const unsigned char * filepath, const BlendFileReadParams * params, ReportList * reports) Line 388	C
setup_app_blend_file_data(bContext * C, BlendFileData * bfd, const unsigned char * filepath, const BlendFileReadParams * params, ReportList * reports) Line 418	C
BKE_blendfile_read_from_memfile(bContext * C, MemFile * memfile, const BlendFileReadParams * params, ReportList * reports) Line 525	C
BKE_memfile_undo_decode(MemFileUndoData * mfu, const eUndoStepDir undo_direction, const bool use_old_bmain_data, bContext * C) Line 88	C
memfile_undosys_step_decode(bContext * C, Main * bmain, UndoStep * us_p, const eUndoStepDir undo_direction, bool UNUSED_is_final) Line 195	C
undosys_step_decode(bContext * C, Main * bmain, UndoStack * ustack, UndoStep * us, const eUndoStepDir dir, bool is_final) Line 215	C
BKE_undosys_step_load_data_ex(UndoStack * ustack, bContext * C, UndoStep * us_target, UndoStep * us_reference, const bool use_skip) Line 813	C
BKE_undosys_step_undo_with_data_ex(UndoStack * ustack, bContext * C, UndoStep * us_target, bool use_skip) Line 874	C
BKE_undosys_step_undo_with_data(UndoStack * ustack, bContext * C, UndoStep * us_target) Line 884	C
BKE_undosys_step_undo(UndoStack * ustack, bContext * C) Line 892	C
ed_undo_step_direction(bContext * C, eUndoStepDir step, ReportList * reports) Line 279	C
ed_undo_exec(bContext * C, wmOperator * op) Line 489	C
wm_operator_invoke(bContext * C, wmOperatorType * ot, wmEvent * event, PointerRNA * properties, ReportList * reports, const bool poll_only, bool use_last_properties) Line 1355	C
wm_handler_operator_call(bContext * C, ListBase * handlers, wmEventHandler * handler_base, wmEvent * event, PointerRNA * properties, const unsigned char * kmi_idname) Line 2199	C
wm_handlers_do_keymap_with_keymap_handler(bContext * C, wmEvent * event, ListBase * handlers, wmEventHandler_Keymap * handler, wmKeyMap * keymap, const bool do_debug_handler) Line 2524	C
wm_handlers_do_intern(bContext * C, wmEvent * event, ListBase * handlers) Line 2820	C
wm_handlers_do(bContext * C, wmEvent * event, ListBase * handlers) Line 2952	C
wm_event_do_handlers(bContext * C) Line 3486	C
WM_main(bContext * C) Line 644	C
main(int argc, const unsigned char * * UNUSED_argv_c) Line 526	C
I can reproduce the crash. ```lines BKE_scene_object_base_flag_sync_from_base(Base * base) Line 2914 C BKE_scene_set_background(Main * bmain, Scene * scene) Line 2126 C setup_app_data(bContext * C, BlendFileData * bfd, const unsigned char * filepath, const BlendFileReadParams * params, ReportList * reports) Line 388 C setup_app_blend_file_data(bContext * C, BlendFileData * bfd, const unsigned char * filepath, const BlendFileReadParams * params, ReportList * reports) Line 418 C BKE_blendfile_read_from_memfile(bContext * C, MemFile * memfile, const BlendFileReadParams * params, ReportList * reports) Line 525 C BKE_memfile_undo_decode(MemFileUndoData * mfu, const eUndoStepDir undo_direction, const bool use_old_bmain_data, bContext * C) Line 88 C memfile_undosys_step_decode(bContext * C, Main * bmain, UndoStep * us_p, const eUndoStepDir undo_direction, bool UNUSED_is_final) Line 195 C undosys_step_decode(bContext * C, Main * bmain, UndoStack * ustack, UndoStep * us, const eUndoStepDir dir, bool is_final) Line 215 C BKE_undosys_step_load_data_ex(UndoStack * ustack, bContext * C, UndoStep * us_target, UndoStep * us_reference, const bool use_skip) Line 813 C BKE_undosys_step_undo_with_data_ex(UndoStack * ustack, bContext * C, UndoStep * us_target, bool use_skip) Line 874 C BKE_undosys_step_undo_with_data(UndoStack * ustack, bContext * C, UndoStep * us_target) Line 884 C BKE_undosys_step_undo(UndoStack * ustack, bContext * C) Line 892 C ed_undo_step_direction(bContext * C, eUndoStepDir step, ReportList * reports) Line 279 C ed_undo_exec(bContext * C, wmOperator * op) Line 489 C wm_operator_invoke(bContext * C, wmOperatorType * ot, wmEvent * event, PointerRNA * properties, ReportList * reports, const bool poll_only, bool use_last_properties) Line 1355 C wm_handler_operator_call(bContext * C, ListBase * handlers, wmEventHandler * handler_base, wmEvent * event, PointerRNA * properties, const unsigned char * kmi_idname) Line 2199 C wm_handlers_do_keymap_with_keymap_handler(bContext * C, wmEvent * event, ListBase * handlers, wmEventHandler_Keymap * handler, wmKeyMap * keymap, const bool do_debug_handler) Line 2524 C wm_handlers_do_intern(bContext * C, wmEvent * event, ListBase * handlers) Line 2820 C wm_handlers_do(bContext * C, wmEvent * event, ListBase * handlers) Line 2952 C wm_event_do_handlers(bContext * C) Line 3486 C WM_main(bContext * C) Line 644 C main(int argc, const unsigned char * * UNUSED_argv_c) Line 526 C ```
Author

Calling bpy.ops.ed.undo_push() after duplicate() seems to be a workaround.

Calling `bpy.ops.ed.undo_push()` after `duplicate()` seems to be a workaround.
Author

@rjg Thanks for looking into it.
I think you might have accidentally reverted my edit (https:*developer.blender.org/transactions/detail/PHID-XACT-TASK-vjxh4mwbn767gkq/). Did you intend that?

@rjg Thanks for looking into it. I think you might have accidentally reverted [my edit ](https:*developer.blender.org/T86293#1124385) (https:*developer.blender.org/transactions/detail/PHID-XACT-TASK-vjxh4mwbn767gkq/). Did you intend that?

There are no timers involved so I don't think this is the same issue.

@ndh No that wasn't intended.

There are no timers involved so I don't think this is the same issue. @ndh No that wasn't intended.
Member

Added subscriber: @lichtwerk

Added subscriber: @lichtwerk
Philipp Oeser self-assigned this 2021-03-05 07:27:20 +01:00
Member

Will check on this

Will check on this

Added subscriber: @APEC

Added subscriber: @APEC

That is interesting, because I use this command in my addon that adds menu "Duplicate" for RMB object selected in Outliner and there is no crush after undo command.
Link for addon https://devtalk.blender.org/t/outliner-gsoc-follow-up-feedback/15948/80
The code looks very simple:

class OUTLINER_OT_duplicate(Operator):    
    bl_idname = "outliner.duplicate"
    bl_label = "Duplicate"
    bl_description = '''Duplicate selected objects'''
    bl_options = { 'REGISTER', 'UNDO' }

    def execute(self, context):
        bpy.ops.object.mode_set(mode = 'OBJECT')    
        bpy.ops.object.duplicate()
                
        return { 'FINISHED' } 

Hot key can be bound as well for Outliner and for 3dView.

That is interesting, because I use this command in my addon that adds menu "Duplicate" for RMB object selected in Outliner and there is no crush after undo command. Link for addon https://devtalk.blender.org/t/outliner-gsoc-follow-up-feedback/15948/80 The code looks very simple: ``` class OUTLINER_OT_duplicate(Operator): bl_idname = "outliner.duplicate" bl_label = "Duplicate" bl_description = '''Duplicate selected objects''' bl_options = { 'REGISTER', 'UNDO' } def execute(self, context): bpy.ops.object.mode_set(mode = 'OBJECT') bpy.ops.object.duplicate() return { 'FINISHED' } ``` Hot key can be bound as well for Outliner and for 3dView.
Member

Investigating the UNDO as we speak.

Works fine executing from the text editor btw (so the undo push seems to only be missing when executing from the py console).

Investigating the UNDO as we speak. Works fine executing from the text editor btw (so the undo push seems to only be missing when executing from the py console).

This issue was referenced by f3fb1df192

This issue was referenced by f3fb1df1922a938272a84209c55206255c687e31
Member

Edit: I just found the "Legacy Undo" option and #60695. But even with legacy undo, there's still no undo history entry after running bpy.ops.object.duplicate().

note: with Legacy Undo, it does not crash, but there is no Undo push, true.

> Edit: I just found the "Legacy Undo" option and #60695. But even with legacy undo, there's still no undo history entry after running bpy.ops.object.duplicate(). note: with Legacy Undo, it does not crash, but there is no Undo push, true.
Member

#77557 (Python Operators that add/remove ID data without an undo step crash Blender) is related

#77557 (Python Operators that add/remove ID data without an undo step crash Blender) is related
Member

Changed status from 'Confirmed' to: 'Resolved'

Changed status from 'Confirmed' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#86293
No description provided.