Cannot combine invoke_props_dialog with a modal execution #48196

Closed
opened 2016-04-19 14:33:33 +02:00 by domlysz · 6 comments

Blender Version
2.76

Using invoke_props_dialogor 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()
**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() ```
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @domlysz

Added subscriber: @domlysz

Added subscribers: @ideasman42, @mont29

Added subscribers: @ideasman42, @mont29

Let’s see what @ideasman42 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…

Let’s see what @ideasman42 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…
Campbell Barton was assigned by Bastien Montagne 2016-04-21 14:56:53 +02:00

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'

This issue was referenced by blender/blender@7cbd1285a5

This issue was referenced by blender/blender@7cbd1285a5522971c9e46e417d63bac8c07bc1a4
Sign in to join this conversation.
No Milestone
No project
No Assignees
4 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-addons#48196
No description provided.