System Information
Operating system: Darwin-19.5.0-x86_64-i386-64bit 64 Bits
Graphics card: NVIDIA GeForce GT 650M OpenGL Engine NVIDIA Corporation 4.1 NVIDIA-14.0.32 355.11.11.10.10.143
Blender Version
Broken: version: 2.90.0 Alpha, branch: master, commit date: 2020-07-02 22:21, hash: rB5a13f682ee5f
Short description of error
Blender will sometimes end up in a weird state where the UI for grease pencil's draw tool is displayed incorrectly, it looks like a mix between draw mode and edit mode.
I ran across this while working on an add-on that tries to wrap blender's undo (more context here).
I was surprised my add-on could even get blender into this state (and i don't understand how/why it's happening) so thought i should report it in case it's a blender bug. I haven't been able to reproduce this without using the add-on code. The add-on calls blenders undo, sometimes more than once per invocation.
Here's the add-on:
bl_info = {
"name": "Keep Active Tool Undo",
"blender": (2, 90, 0),
"category": "Object",
}
import bpy
class KeepActiveToolUndo(bpy.types.Operator):
"""Keep Active Tool Undo"""
bl_idname = "wm.keep_active_tool_undo"
bl_label = "Keep Active Tool Undo"
def execute(self, context):
# record active tool and mode
original_mode = bpy.context.mode
original_tool_id = bpy.context.workspace.tools.from_space_view3d_mode(original_mode, create=False).idname
print("mode: "+original_mode)
print("tool id: "+original_tool_id)
# undo
try:
print("undo")
bpy.ops.ed.undo() #this line fails if undo stack is empty
except:
print("FAILED TO UNDO")
self.report({'INFO'}, 'Failed to undo')
# record new active tool and mode
current_mode = bpy.context.mode
current_tool_id = bpy.context.workspace.tools.from_space_view3d_mode(current_mode, create=False).idname
print("mode: "+current_mode)
print("tool id: "+current_tool_id)
# change active tool and mode back to previous ones if they've changed after the undo
if original_tool_id != current_tool_id:
for area in bpy.context.screen.areas:
if area.type == "VIEW_3D":
override = bpy.context.copy()
override["space_data"] = area.spaces[0]
override["area"] = area
bpy.ops.object.mode_set ( mode = original_mode )
bpy.ops.wm.tool_set_by_id(override, name=original_tool_id)
print("tool id different **")
print("")
#recursively undo, because we want to undo the previous action in the stack that changed a stroke
self.execute(context)
print("done --------------------------------------")
print("")
return {'FINISHED'}
# store keymaps here to access after registration
addon_keymaps = []
def register():
bpy.utils.register_class(KeepActiveToolUndo)
wm=bpy.context.window_manager
kc=wm.keyconfigs.addon
if kc:
km=kc.keymaps.new(name = "Window",space_type='EMPTY', region_type='WINDOW')
kmi = km.keymap_items.new("wm.keep_active_tool_undo", type='Z', value='PRESS',oskey=True)
addon_keymaps.append((km,kmi))
def unregister():
for km,kmi in addon_keymaps:
km.keymap_items.remove(kmi)
addon_keymaps.clear()
bpy.utils.unregister_class(KeepActiveToolUndo)
if __name__ == "__main__":
register()Exact steps for others to reproduce the error
- file > new > 2d animation
- preferences > keymap. Unmap cmd z from the undo command (the add-on uses this shortcut)
- install the add-on above, activate it
- draw a line using the grease pencil draw tool
- switch to grease pencil edit mode, select the entire line and move it a little using G
- switch back to draw mode and draw a second shape
- press cmd+z twice (with the wrapper add-on active) and you get to this weird state. The interface shows a mixture of paint and edit buttons, and you can’t paint.




