Python - in an operator, setting scene frame after undo causes playback cursor to get 'stuck' #55807

Closed
opened 2018-07-07 04:57:02 +02:00 by hudson barkley · 5 comments

System Information
Windows 8.1

Blender Version
Broken: 2.79b

Short description of error
Ok, this is kinda hard to describe, so here goes -
If a scene's sync mode is "AV-sync",
If an operator is called from a panel,
The operator runs an undo operation (bpy.ops.ed.undo()),
Then setting bpy.context.scene.frame_current will cause the playback cursor to get stuck rapidly iterating between 2 frames.

This seems to only happen if it is done in an operator, and only if the operator is called from a panel or shortcut (not just directly in the script run), and only if the av-sync is set

Exact steps for others to reproduce the error
Set a new scene's sync mode to "AV-sync"
Load the following script into a text area
Run the script
Click the new "Test" button in the "Test Panel" panel in the 3d view properties panel.

import bpy

class TestOperator(bpy.types.Operator):
    bl_idname = "test.operator"
    bl_label = "Test"

    def invoke(self, context, event):
        bpy.ops.screen.animation_play()
        bpy.ops.ed.undo_push()
        bpy.ops.ed.undo()
        context.scene.frame_current = 1  #unfortunately, this makes blender spaz out and get stuck on the frame...
        return {'FINISHED'}

class TestPanel(bpy.types.Panel):
    bl_label = "Test Panel"
    bl_space_type = "VIEW_3D"
    bl_region_type = "UI"
    
    def draw(self, context):
        self.layout.operator("test.operator")

def register():
    bpy.utils.register_class(TestOperator)
    bpy.utils.register_class(TestPanel)

if __name__ == "__main__":
    register()
**System Information** Windows 8.1 **Blender Version** Broken: 2.79b **Short description of error** Ok, this is kinda hard to describe, so here goes - If a scene's sync mode is "AV-sync", If an operator is called from a panel, The operator runs an undo operation (bpy.ops.ed.undo()), Then setting bpy.context.scene.frame_current will cause the playback cursor to get stuck rapidly iterating between 2 frames. This seems to only happen if it is done in an operator, and only if the operator is called from a panel or shortcut (not just directly in the script run), and only if the av-sync is set **Exact steps for others to reproduce the error** Set a new scene's sync mode to "AV-sync" Load the following script into a text area Run the script Click the new "Test" button in the "Test Panel" panel in the 3d view properties panel. ``` import bpy class TestOperator(bpy.types.Operator): bl_idname = "test.operator" bl_label = "Test" def invoke(self, context, event): bpy.ops.screen.animation_play() bpy.ops.ed.undo_push() bpy.ops.ed.undo() context.scene.frame_current = 1 #unfortunately, this makes blender spaz out and get stuck on the frame... return {'FINISHED'} class TestPanel(bpy.types.Panel): bl_label = "Test Panel" bl_space_type = "VIEW_3D" bl_region_type = "UI" def draw(self, context): self.layout.operator("test.operator") def register(): bpy.utils.register_class(TestOperator) bpy.utils.register_class(TestPanel) if __name__ == "__main__": register() ```
Author

Added subscriber: @snuq

Added subscriber: @snuq
Author

As a side note, I have seen this happen before from some other cause, but it was one of those unreproducable 'what the heck just happened??' moments...
So, it is entirely possible that other combinations of commands may cause this, but Blender was most definitely set to av-sync mode in that situation.

As a side note, I have seen this happen before from some other cause, but it was one of those unreproducable 'what the heck just happened??' moments... So, it is entirely possible that other combinations of commands may cause this, but Blender was most definitely set to av-sync mode in that situation.

Added subscriber: @mont29

Added subscriber: @mont29

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Bastien Montagne self-assigned this 2018-07-24 16:21:09 +02:00

Fwiw, on 2.8 it seems to work OK, so will consider that issue as fixed. Thanks for the report!

Fwiw, on 2.8 it seems to work OK, so will consider that issue as fixed. Thanks for the report!
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 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#55807
No description provided.