AcademySoftwareFoundation / xstudio

xSTUDIO is a modern, high performance and feature rich playback and review application designed for organisations and individuals in the post production, VFX and Animation industries.
Apache License 2.0
643 stars 84 forks source link

Proper way of creating non-modal Qt window #63

Open faulknermano opened 1 year ago

faulknermano commented 1 year ago

Hi! I can create a modal Qt window via window.exec_() but when I try using show(), the frame comes up, but the window does not draw.

We have had similar issues with other applications and developed workarounds by hooking up with the host application's tick callback to call processEvents() and so to allow redraws and other events to tick.

But I was wondering what is the best approach with non-modal guis in xstudio?

Thank you for reading.

faulknermano commented 1 year ago

Actually, not just non-modal Qt widgets, but I also can't properly use QDialogs either. QPushButton presses crash XS.

Take this simple QDialog:

class Temp(QtWidgets.QDialog):
    def __init__(self, parent=None):
        super(Temp, self).__init__(parent)
        self.layout = QtWidgets.QGridLayout()
        self.setLayout(self.layout)
        self.button_load = QtWidgets.QPushButton('Load')
        self.button_load.clicked.connect(self.on_click_button_load)
        self.layout.addWidget(self.button_load, 0, 0, 1, 1)
    def on_click_button_load(self):
        print('hi')

Called simply:

from my_guis import Temp
w = Temp();
w.exec_()

It will bring up the dialog with a push button. Press the button once/twice and XS goes down. My console looks like:

================================================================================================================================
[2023-09-28 11:30:39.404] [xstudio] [info] XStudio logging started.
[2023-09-28 11:30:40.594] [xstudio] [info] API enabled on 127.0.0.1:45500, session name default0
[2023-09-28 11:30:44.511] [xstudio] [info] XStudio UI launched.
QWidget::repaint: Recursive repaint detected
QWidget::repaint: Recursive repaint detected
QBackingStore::endPaint() called with active painter; did you forget to destroy it or call QPainter::end() on it?
Error: signal 11:
xstudio.bin[0x6390e6]
/lib64/libc.so.6(+0x36400)[0x7f1e1de75400]
/packages/vendor/github.com/xstudio/linux_64/0.11.1/lib/libQt5Gui.so.5(+0xe3a24)[0x7f1e2314aa24]
/packages/vendor/github.com/xstudio/linux_64/0.11.1/lib/libQt5Gui.so.5(+0x3f3ba3)[0x7f1e2345aba3]
/packages/vendor/github.com/xstudio/linux_64/0.11.1/lib/libQt5Gui.so.5(_ZNK9QTextLine4drawEP8QPainterRK7QPointFPKN11QTextLayout11FormatRangeE+0xa06)[0x7f1e2328b276]
/packages/vendor/github.com/xstudio/linux_64/0.11.1/lib/libQt5Gui.so.5(+0x3eaefb)[0x7f1e23451efb]
/packages/vendor/github.com/xstudio/linux_64/0.11.1/lib/libQt5Gui.so.5(_ZN8QPainter8drawTextERK5QRectiRK7QStringPS0_+0xfd)[0x7f1e234526cd]
/packages/vendor/github.com/xstudio/linux_64/0.11.1/lib/libQt5Widgets.so.5(_ZNK12QFusionStyle12drawItemTextEP8QPainterRK5QRectiRK8QPalettebRK7QStringNS5_9ColorRoleE+0xd8)[0x7f1e28cff9a8]
/packages/vendor/github.com/xstudio/linux_64/0.11.1/lib/libQt5Widgets.so.5(_ZNK12QCommonStyle11drawControlEN6QStyle14ControlElementEPK12QStyleOptionP8QPainterPK7QWidget+0x8fc)[0x7f1e28ca6bcc]
/packages/vendor/github.com/xstudio/linux_64/0.11.1/lib/libQt5Widgets.so.5(_ZNK12QFusionStyle11drawControlEN6QStyle14ControlElementEPK12QStyleOptionP8QPainterPK7QWidget+0x74e)[0x7f1e28d0103e]
QObject::~QObject: Timers cannot be stopped from another thread
QObject::~QObject: Timers cannot be stopped from another thread

Is this is an XS issue?