Maniphest T48196

Cannot combine invoke_props_dialog with a modal execution
Closed, Resolved

Assigned To
Campbell Barton (campbellbarton)
Authored By
domlysz (domlysz)
Apr 19 2016, 2:33 PM
Tags
  • Add-ons (BF-Blender)
  • BF Blender
Subscribers
Bastien Montagne (mont29)
Campbell Barton (campbellbarton)
domlysz (domlysz)

Description

Blender Version
2.76

Using invoke_props_dialog or another function which requires RUNNING_MODAL in invoke (like fileselect_add) is not possible with a modal excution (ie using modal_handler_add and a modal() function).

The folowing code crash Blender.

import bpy
from bpy.props import IntProperty

class TEST(bpy.types.Operator):

	bl_idname = "test.modal"
	bl_label = "test invoke props + modal"

	nb = IntProperty(name="int prop")

	def invoke(self, context, event):
		return context.window_manager.invoke_props_dialog(self)
		
	def execute(self, context):
		context.window_manager.modal_handler_add(self)
		return {'RUNNING_MODAL'}

	def modal(self, context, event):

		if event.type in {'ESC'}:
			return {'CANCELLED'}

		return {'RUNNING_MODAL'}

def register():
	bpy.utils.register_class(TEST)


def unregister():
	bpy.utils.unregister_class(TEST)

if __name__ == "__main__":
	register()

Revisions and Commits

rB Blender

Event Timeline

domlysz (domlysz) created this task.Apr 19 2016, 2:33 PM
domlysz (domlysz) raised the priority of this task from to 90.
domlysz (domlysz) updated the task description.
domlysz (domlysz) added a project: Add-ons (BF-Blender).
domlysz (domlysz) edited a custom field.
domlysz (domlysz) added a subscriber: domlysz (domlysz).
Bastien Montagne (mont29) added subscribers: Campbell Barton (campbellbarton), Bastien Montagne (mont29).Apr 21 2016, 2:56 PM

Let’s see what @Campbell Barton (campbellbarton) says here, but would not expect this to work, context.window_manager.invoke_props_dialog(self) is already running modal, so that would be trying to fire two modal sessions one after the other, from the same operator…

Bastien Montagne (mont29) assigned this task to Campbell Barton (campbellbarton).Apr 21 2016, 2:56 PM
Bastien Montagne (mont29) lowered the priority of this task from 90 to Normal.
Bastien Montagne (mont29) added a project: BF Blender.
Campbell Barton (campbellbarton) changed the task status from Unknown Status to Resolved by committing rB7cbd1285a552: Fix T48196: Crash enabling modal operator in exec.Jun 21 2016, 7:00 AM
Campbell Barton (campbellbarton) added a commit: rB7cbd1285a552: Fix T48196: Crash enabling modal operator in exec.