Search code examples
pythonpyside6

Pyside delay on process exit


I have a Windows desktop (open-source) application developed in Pyside6. I am trying to remove a tooltip delay for a certain widget (a pretty innocent operation) and I am ending up with a huge delay when exiting the application (the process ends a minute after I click on exit).The code I am adding is this:

class NoDelayHintProxyStyle(QtWidgets.QProxyStyle):
    def styleHint(self, hint, option=..., widget=..., returnData=...):
        if hint == QtWidgets.QStyle.SH_ToolTip_WakeUpDelay:
            return 0

        return QtWidgets.QProxyStyle.styleHint(self, hint, option, widget, returnData)

...

        self._w.comboSampleRate.setToolTip(
            """
            some text
            """
        )

        self._w.comboSampleRate.setStyle(
            NoDelayHintProxyStyle(self._w.comboSampleRate.style())
        )
...

I suspect that the problem is not directly related to this code and this code is just a symptom. It feels that an object / or some 3rd party lib thread is not terminated properly on exit.

Is there any simple way to monitor objects, threads termination with Pyside?

Thanks


Solution

  • Answering my own question:

    The proper way to do it is like the following:

    class NoDelayHintProxyStyle(QtWidgets.QProxyStyle):
    
        def __init__(self):
            QtWidgets.QProxyStyle.__init__(self)
    
        def styleHint(self, hint, option=..., widget=..., returnData=...):
            if hint == QtWidgets.QStyle.SH_ToolTip_WakeUpDelay:
                return 0
    
            return QtWidgets.QProxyStyle.styleHint(self, hint, option, widget, returnData)
    
    ...
    
            self._w.comboSampleRate.setToolTip(
                """
                some text
                """
            )
    
            self._w.comboSampleRate.setStyle(
                NoDelayHintProxyStyle()
            )
    
    ...