tpaviot / pythonocc-core

Python package for 3D geometry CAD/BIM/CAM
GNU Lesser General Public License v3.0
1.39k stars 379 forks source link

Please destroy the QApplication singleton before creating a new QApplication instance. #1363

Closed LZHLZHOOO closed 1 week ago

LZHLZHOOO commented 3 months ago
4b96f0dc14cb857437a767d6ca03e5d

I want to upload a 3D model in STP format, but I'm encountering this error. Does anyone know what might be causing this issue? Please help.

jnwalther commented 3 weeks ago

I'm not 100% sure if this is the same issue, but I got the same error message when trying to open a display window for a second time in a single Python session. It seems to be related to Pyside6. Other projects seem to have similar issues.

The solution given in that issue seems to do the trick for me, i.e. go to https://github.com/tpaviot/pythonocc-core/blob/master/src/Display/SimpleGui.py and do

-  app = QtWidgets.QApplication(sys.argv)
+  app = QtWidgets.QApplication.instance() or QtWidgets.QApplication(sys.argv)

in line 230.

I haven't tested it completely, so I can't say if this change breaks anything for the other Qt versions.

tpaviot commented 1 week ago

Fixed by #1381