Page MenuHome

Cannot combine invoke_props_dialog with a modal execution
Closed, ResolvedPublic

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()

Event Timeline

domlysz (domlysz) added a project: Python.
domlysz (domlysz) set Type to Bug.
domlysz (domlysz) created this task.
domlysz (domlysz) raised the priority of this task from to Needs Triage by Developer.

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…