techartorg / bqt

A Blender add-on to support & manage Qt Widgets in Blender (PySide2)
https://github.com/techartorg/bqt/wiki
Mozilla Public License 2.0
162 stars 23 forks source link

Access violation fix #43

Closed hanWolf3D closed 1 year ago

hanWolf3D commented 1 year ago

this PR addresses an issue with access violation

details:

QApplication is instanced, and a reference is saved in a variable in the QOperator. the blender window is wrapped in QT, and is now managed by pyside/ the QApplication

when closing blender, operators likely get deregistered, which means the reference to QApplication is gone, and QApplication gets garbage collected. but blender is managed by the QApp, which tries to delete all it's widgets etc.

since the operator owns qapp, qapp owns blender, and blender owns the operator. we have a loop.

moving the qapp to a global variable instead of the operator seems to fix the access violation error :D

notes the specific commit that fixes the violation is the removal of the qoperator. replacing it with just a function