Page MenuHome

Python 'View' functions for Sequencer/Preview makes Blender crash
Closed, InvalidPublic

Description

Blender 2.79b on Windows 8

This line crashes Blender in the script context bellow:

bpy.ops.sequencer.view_all_preview()

And so does:

view_frame, view_ghost_border, .view_zoom_ratio

Script to expose the crash:

# Adds a windowless fullscreen preview to the sequencer
# Have a Sequencer/Preview area open, and select 'True Fullscreen' in the View Menu.
# Uncomment this line: "bpy.ops.sequencer.view_all_preview()" to make Blender crash.
# Use Alt+F11, Alt+F10 and home to return to a normal screen

import bpy

class SEQUENCE_MT_true_fullscreen(bpy.types.Operator):
	"""True fullscreen preview. Close in upper right corner"""
	bl_label = "True Fullscreen"
	bl_idname = "sequencer.true_fullscreen"
	bl_options = {'REGISTER', 'UNDO'}

	def execute(self, context):
		scene=bpy.context.scene

		if not bpy.context.scene.sequence_editor: #create sequence, if missing
			bpy.context.scene.sequence_editor_create() 
  
		context = bpy.context
		for area in bpy.context.screen.areas:
			if area.type == 'SEQUENCE_EDITOR':
				if area.spaces[0].view_type == 'PREVIEW':  
				   override = bpy.context.copy()
				   override['space_data'] = area.spaces.active
				   override['region'] = area.regions[-1]
				   override['area'] = area
       			           override['screen'] = context.screen
				   bpy.ops.screen.screen_full_area(override, use_hide_panels=True)
				   bpy.ops.wm.window_fullscreen_toggle()
				   bpy.ops.sequencer.view_all_preview() # This line crashes Blender
                                  #and so does .view_frame(), view_ghost_border(), .view_zoom_ratio()

		return {'FINISHED'}

def menu_append(self, context):
	self.layout.operator(SEQUENCE_MT_true_fullscreen.bl_idname)

def register():
	bpy.utils.register_class(SEQUENCE_MT_true_fullscreen)
	bpy.types.SEQUENCER_MT_view.append(menu_append) # add to "view" vse header menu

def unregister():
	bpy.utils.unregister_class(SEQUENCE_MT_true_fullscreen)
	bpy.types.SEQUENCER_MT_view.remove(menu_append)

if __name__ == "__main__":
	register()

Details

Type
Bug

Event Timeline

Bastien Montagne (mont29) triaged this task as Needs Information from User priority.Sep 21 2018, 9:57 AM

Cannot reproduce any crash here with this code (once tabulation is fixed…). Please at the very least give us error message!

Strange. It crashes here on 2.8 too.

I get no error message. The Blender UI just disappears.

The bug was encountered on StackExchange: https://blender.stackexchange.com/questions/118741/how-to-make-the-sequencer-preview-area-fullscreen-with-python

Apparently, it can be worked-around by delaying the call.

Bastien Montagne (mont29) claimed this task.

OK finally managed to reproduce (that operator only works when VSE editor is in only-preview mode).

You simply have invalid context for the crashing op call, just pass your override to it and it works as expected.

Also, We do not handle user support on this tracker, only bug reports. User forums like blenderartists.org or blender.stackexchange.com should be used for that matter.

I was working with him on this script, we did end up getting it to work, and yes, the context was the problem... but regardless, shouldn't blender give an error rather than just crashing? Seems like it is still a bug.

There are gazillions of ways to make Blender crash with bad py code… ideally yes, that should be checked in the poll callback of the operators, but that’s not a bug.