Infinite loop on uic.loadUi() with PySide2
See original GitHub issueI’m trying to use qtpy so I can support both PyQt5 and PySide2. I have a part in my program when I load a different INI file that has a different ui file that updates my GUI. This works fine with PyQt5, but I get an access violation and the program dies when I try the same thing with PySide2.
from qtpy import uic, QtNetwork
from qtpy.QtCore import Slot, QTimer
import pyqtgraph as pg
The offending line is
self.FileNamingWidget = uic.loadUi(uifilename)
I have two different conda environments, one with PyQt5, and the other with PySide2. In the PyQt5 environment, everything works as expected. In the PySide2 environment, I get
Windows fatal exception: access violation
Current thread 0x00003428 (most recent call first):
File "C:\Software\envs\fieldcapenv_pyside\lib\site-packages\qtpy\uic.py", line 146 in createWidget
File "C:\Software\envs\fieldcapenv_pyside\lib\site-packages\qtpy\uic.py", line 232 in loadUi
File "C:\Users\timothy.j.williams1\PycharmProjects\NVFieldCap\nvfieldcap\application.py", line 1089 in Load_Profile
File "C:\Users\timothy.j.williams1\PycharmProjects\NVFieldCap\nvfieldcap\application.py", line 2100 in run
File "C:/Users/timothy.j.williams1/PycharmProjects/NVFieldCap/bin/nvfieldcap.py", line 102 in _run_nvfieldcap
File "C:/Users/timothy.j.williams1/PycharmProjects/NVFieldCap/bin/nvfieldcap.py", line 130 in <module>
Process finished with exit code -1073741819 (0xC0000005)
If I step through the debugger, I can see that a widget gets created in uic.UiLoader.createWidget
, but when it returns the widget back to uic.loadUi
,
widget = loader.load(uifile)
loader.load
is just called again. I’m in an infinite loop until I disable my breakpoint.
I should note that when I to step into uic.loadUi
in my PyQt5 environment, I’m not taken to pyqt.uic.loadUi
, but PyQt5\uic\__init__.py
.
from .Loader.loader import DynamicUILoader
While in the debugger console, I can do
uic.loadUi(uifilename)
PyDev console: starting.
<PyQt5.QtWidgets.QTabWidget object at 0x0000020F94B68318>
If I try that on the PySide2 environment, I get the access violation.
Thanks for any help.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Went to revisit this again. I’m not having the same problem. With PySide2 I’m getting this
I’m not getting this error with PyQt5, but my GUI is also not updating as it should. I’m convinced now that part of this is due to my incorrect mixing of qtpy and pyqtgraph widgets.
If I take out this code completely
things work just fine. I’m not doing something right with the LayoutWidget. I really don’t need to be doing this anyway. I’m closing this.
Hi @dalthviz . It does seem so. I fixed the bug of my own making referenced above. I ended up taking out some code that was loading a UI file basically when I shouldn’t so the problem in effect went away. I had code calling
uic.loadUi()
somewhere else as part of a dialog, but it was usingPyQt5.uic
. I changed it to using qtpy.uic and that worked fine.PyQt5 code:
qtpy code:
Given that this works, and I believe my other bug was the real problem, I’m tempted to close this issue. I’ll try first to see if I can replicate it with a smaller example.