PySide2 widget's deleteLater() method not working in modal operator #109650

Closed
opened 2023-07-03 14:46:37 +02:00 by Tristan-Languebien · 1 comment

System Information
Operating system: Windows-10-10.0.19044-SP0 64 Bits
Graphics card: NVIDIA GeForce GTX 980 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 531.18

Blender Version
Broken: version: 3.5.1, branch: blender-v3.5-release, commit date: 2023-04-24 18:11, hash: e1ccd9d4a1d3
Worked: (newest version of Blender that worked as expected)

Short description of error
The deleteLater() method does't seem to work when the show() method of a PySide2 widget is called.
Oddly enough, the deleteLater() method works fine after that (when it is called from a signal for instance). Something seems to be off with the event loop...
You can try this out with the code below, just make sure to comment out "self.remove_label()" if you want to try the button

Exact steps for others to reproduce the error

from typing import Set
import bpy
from bpy.types import Context, Operator
from PySide2.QtWidgets import QVBoxLayout, QPushButton, QLabel, QWidget

class MyWidget(QWidget):
    def __init__(self):
        super().__init__()
        self.main_layout = QVBoxLayout()
        self.setLayout(self.main_layout)
        self.label = QLabel("Delete me")
        self.button = QPushButton("Test")
        self.main_layout.addWidget(self.button)
        self.main_layout.addWidget(self.label)
        self.remove_label() # Doesn't work
        self.button.clicked.connect(self.remove_label) # Works (the previous line must be commented out)
        
    def remove_label(self):
        self.label.deleteLater()
        print(self.label)

class PYSIDE2_OT_openWidget(Operator):
    bl_idname = "pyside2.widget"
    bl_label = "Pyside2 Widget"
    bl_description = "PySide2 widget, only for demonstration purposes"

    def execute(self, context: Context) -> Set[str]:
        self.widget = MyWidget()
        self.widget.show()
        return {'RUNNING_MODAL'}

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

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

if __name__ == "__main__":
    register()
**System Information** Operating system: Windows-10-10.0.19044-SP0 64 Bits Graphics card: NVIDIA GeForce GTX 980 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 531.18 **Blender Version** Broken: version: 3.5.1, branch: blender-v3.5-release, commit date: 2023-04-24 18:11, hash: `e1ccd9d4a1d3` Worked: (newest version of Blender that worked as expected) **Short description of error** The deleteLater() method does't seem to work when the show() method of a PySide2 widget is called. Oddly enough, the deleteLater() method works fine after that (when it is called from a signal for instance). Something seems to be off with the event loop... You can try this out with the code below, just make sure to comment out "self.remove_label()" if you want to try the button **Exact steps for others to reproduce the error** ```Py from typing import Set import bpy from bpy.types import Context, Operator from PySide2.QtWidgets import QVBoxLayout, QPushButton, QLabel, QWidget class MyWidget(QWidget): def __init__(self): super().__init__() self.main_layout = QVBoxLayout() self.setLayout(self.main_layout) self.label = QLabel("Delete me") self.button = QPushButton("Test") self.main_layout.addWidget(self.button) self.main_layout.addWidget(self.label) self.remove_label() # Doesn't work self.button.clicked.connect(self.remove_label) # Works (the previous line must be commented out) def remove_label(self): self.label.deleteLater() print(self.label) class PYSIDE2_OT_openWidget(Operator): bl_idname = "pyside2.widget" bl_label = "Pyside2 Widget" bl_description = "PySide2 widget, only for demonstration purposes" def execute(self, context: Context) -> Set[str]: self.widget = MyWidget() self.widget.show() return {'RUNNING_MODAL'} def register(): bpy.utils.register_class(PYSIDE2_OT_openWidget) def unregister(): bpy.utils.unregister_class(PYSIDE2_OT_openWidget) if __name__ == "__main__": register() ```
Tristan-Languebien added the
Type
Report
Status
Needs Triage
Priority
Normal
labels 2023-07-03 14:46:38 +02:00
Member

You probably need to report this issue to PySide instead of Blender since Blender doesn't come with PySide and its accompanying libraries.

Also there's likely a problem with how you wrote the modal operator, you didn't have a modal() call but have a return {'RUNNING_MODAL'}, blender will not continue executing anything from here. You could checkout Templates -> Python -> Operator Modal for reference. Thanks.

Will close this issue for now, but feel free to comment on more information you get. Thanks!

You probably need to report this issue to PySide instead of Blender since Blender doesn't come with PySide and its accompanying libraries. Also there's likely a problem with how you wrote the modal operator, you didn't have a modal() call but have a `return {'RUNNING_MODAL'}`, blender will not continue executing anything from here. You could checkout `Templates -> Python -> Operator Modal` for reference. Thanks. Will close this issue for now, but feel free to comment on more information you get. Thanks!
Blender Bot added
Status
Archived
and removed
Status
Needs Triage
labels 2023-07-04 04:04:35 +02:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
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#109650
No description provided.