Ticket #3977: 15759_15758.diff

File 15759_15758.diff, 2.1 KB (added by michaelnt, 5 years ago)
  • twisted/internet/qtreactor.py

    === modified file 'twisted/internet/qtreactor.py'
     
    2929
    3030
    3131import sys
     32import gc
    3233from zope.interface import implements
    3334from twisted.internet.interfaces import IReactorFDSet
    3435from twisted.python import log
    3536from twisted.internet import posixbase
    3637
    37 try:
    38     from PySide.QtCore import QSocketNotifier, QObject, SIGNAL, QTimer, QCoreApplication
    39     from PySide.QtCore import QEventLoop
    40 except ImportError:
    41     from PyQt4.QtCore import QSocketNotifier, QObject, SIGNAL, QTimer, QCoreApplication
    42     from PyQt4.QtCore import QEventLoop
     38from PySide.QtCore import QSocketNotifier, QObject, SIGNAL, QTimer, QCoreApplication
     39from PySide.QtCore import QEventLoop
    4340
    4441
    4542class TwistedSocketNotifier(QObject):
     
    5855            self.fn = self.read
    5956        else:
    6057            self.fn = self.write
    61         QObject.connect(self.notifier, SIGNAL("activated(int)"), self.fn)
     58        self.connect(self.notifier, SIGNAL("activated(int)"), self.fn)
    6259
    6360
    6461    def shutdown(self):
     
    126123        self._timer = QTimer()
    127124        self._timer.setSingleShot(True)
    128125        QObject.connect(self._timer, SIGNAL("timeout()"), self.iterate)
    129 
    130         if QCoreApplication.startingUp():
    131             # Application Object has not been started yet
     126       
     127        self.qApp = QCoreApplication.instance()
     128        self._ownApp=False
     129        if self.qApp is None:
    132130            self.qApp=QCoreApplication([])
    133131            self._ownApp=True
    134         else:
    135             self.qApp = QCoreApplication.instance()
    136             self._ownApp=False
    137132        self._blockApp = None
    138133        posixbase.PosixReactorBase.__init__(self)
    139134
     
    259254        self.reactorInvocation()
    260255
    261256
    262     def stop(self):
    263         super(QtReactor, self).stop()
    264         self.iterate(0)
     257    def crash(self):
     258        log.msg('crash')
     259        super(QtReactor, self).crash()
     260        if self._blockApp:
     261            self._blockApp.quit()
    265262
    266263
    267264    def run(self, installSignalHandlers=True):