Page MenuHome

Python API calling: bpy.ops.text.cut +bpy.ops.text.paste will fail when undo.
Closed, ResolvedPublic

Description

System Information
Operating system: Windows-10-10.0.17763 64 Bits
Graphics card: Intel(R) UHD Graphics 600 Intel 4.5.0 - Build 24.20.100.6137

Blender Version
Broken: version: 2.80 (sub 74), branch: blender2.7, commit date: 2019-06-16 23:08, hash: rB12da679fa094
Worked: (optional)

Short description of error
bpy.ops.text.cut +bpy.ops.text.paste will fail when undo.

Exact steps for others to reproduce the error

  • Copy/paste the following script into the text editor.
  • Select some of the uncommented text.
  • Run the script.
  • The script now cuts(copies) and pastes.
  • No change should be seen.
  • Undo.
  • The selected text disappears.

This is the bug. All operators using cut+paste will not be able to undo correct.

Change "cut" to "copy" to see the correct behavior.

import bpy
print("Hello World")
bpy.ops.text.cut()
bpy.ops.text.paste()
################################################
#Highlight a bit of this text and run the script
#Then undo - the text will not be restored.
################################################

Details

Type
Bug

Event Timeline

Sebastian Parborg (zeddb) triaged this task as Confirmed, Medium priority.Jun 21 2019, 11:34 AM
__GI_raise(int sig) (/build/glibc-OTsEL5/glibc-2.27/sysdeps/unix/sysv/linux/raise.c:51)
__GI_abort() (/build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:79)
BKE_undosys_step_push_init_with_type(UndoStack * ustack, bContext * C, const char * name, const UndoType * ut) (/home/jacques/blender-git/blender/source/blender/blenkernel/intern/undo_system.c:458)
ED_text_undo_push_init(bContext * C) (/home/jacques/blender-git/blender/source/blender/editors/space_text/text_undo.c:234)
text_paste_exec(bContext * C, wmOperator * op) (/home/jacques/blender-git/blender/source/blender/editors/space_text/text_ops.c:843)
wm_operator_invoke(bContext * C, wmOperatorType * ot, wmEvent * event, PointerRNA * properties, ReportList * reports, const _Bool poll_only, _Bool use_last_properties) (/home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_event_system.c:1452)
wm_operator_call_internal(bContext * C, wmOperatorType * ot, PointerRNA * properties, ReportList * reports, const short context, const _Bool poll_only, wmEvent * event) (/home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_event_system.c:1687)
WM_operator_call_py(bContext * C, wmOperatorType * ot, short context, PointerRNA * properties, ReportList * reports, const _Bool is_undo) (/home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_event_system.c:1787)
pyop_call(PyObject * UNUSED_self, PyObject * args) (/home/jacques/blender-git/blender/source/blender/python/intern/bpy_operator.c:267)
_PyMethodDef_RawFastCallKeywords (Unknown Source:0)
_PyCFunction_FastCallKeywords (Unknown Source:0)
_PyEval_EvalFrameDefault (Unknown Source:0)
__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytecode_while_frame_eval(PyFrameObject * __pyx_v_frame_obj, int __pyx_v_exc) (/io/ptvsd/src/ptvsd/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_evaluator.c:7206)
_PyEval_EvalCodeWithName (Unknown Source:0)
_PyFunction_FastCallDict (Unknown Source:0)
_PyObject_Call_Prepend (Unknown Source:0)
[Unknown/Just-In-Time compiled code] (Unknown Source:0)
_PyObject_FastCallKeywords (Unknown Source:0)
_PyEval_EvalFrameDefault (Unknown Source:0)
__pyx_f_18_pydevd_frame_eval_22pydevd_frame_evaluator_get_bytecode_while_frame_eval(PyFrameObject * __pyx_v_frame_obj, int __pyx_v_exc) (/io/ptvsd/src/ptvsd/_vendored/pydevd/_pydevd_frame_eval/pydevd_frame_evaluator.c:7206)
_PyEval_EvalCodeWithName (Unknown Source:0)
PyEval_EvalCodeEx (Unknown Source:0)
PyEval_EvalCode (Unknown Source:0)
python_script_exec(bContext * C, const char * fn, struct Text * text, struct ReportList * reports, const _Bool do_jump) (/home/jacques/blender-git/blender/source/blender/python/intern/bpy_interface.c:476)
BPY_execute_text(bContext * C, struct Text * text, struct ReportList * reports, const _Bool do_jump) (/home/jacques/blender-git/blender/source/blender/python/intern/bpy_interface.c:569)
text_run_script(bContext * C, ReportList * reports) (/home/jacques/blender-git/blender/source/blender/editors/space_text/text_ops.c:708)
text_run_script_exec(bContext * C, wmOperator * op) (/home/jacques/blender-git/blender/source/blender/editors/space_text/text_ops.c:747)
wm_operator_invoke(bContext * C, wmOperatorType * ot, wmEvent * event, PointerRNA * properties, ReportList * reports, const _Bool poll_only, _Bool use_last_properties) (/home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_event_system.c:1452)
wm_operator_call_internal(bContext * C, wmOperatorType * ot, PointerRNA * properties, ReportList * reports, const short context, const _Bool poll_only, wmEvent * event) (/home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_event_system.c:1653)
WM_operator_name_call_ptr(bContext * C, wmOperatorType * ot, short context, PointerRNA * properties) (/home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_event_system.c:1701)
ui_apply_but_funcs_after(bContext * C) (/home/jacques/blender-git/blender/source/blender/editors/interface/interface_handlers.c:806)
ui_handler_region_menu(bContext * C, const wmEvent * event, void * UNUSED_userdata) (/home/jacques/blender-git/blender/source/blender/editors/interface/interface_handlers.c:10144)
wm_handler_ui_call(bContext * C, wmEventHandler_UI * handler, const wmEvent * event, int always_pass) (/home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_event_system.c:623)
wm_handlers_do_intern(bContext * C, wmEvent * event, ListBase * handlers) (/home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_event_system.c:2701)
wm_handlers_do(bContext * C, wmEvent * event, ListBase * handlers) (/home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_event_system.c:2947)
wm_event_do_handlers(bContext * C) (/home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm_event_system.c:3309)
WM_main(bContext * C) (/home/jacques/blender-git/blender/source/blender/windowmanager/intern/wm.c:417)
main(int argc, const char ** argv) (/home/jacques/blender-git/blender/source/creator/creator.c:500)
Campbell Barton (campbellbarton) lowered the priority of this task from Confirmed, Medium to Confirmed, Low.Jun 29 2019, 12:49 AM
Campbell Barton (campbellbarton) renamed this task from API: bpy.ops.text.cut +bpy.ops.text.paste will fail when undo. to Python API calling: bpy.ops.text.cut +bpy.ops.text.paste will fail when undo..Jul 1 2019, 4:15 AM

Note that D5222 will make this a simpler fix.