我使用QThread创建PySide2(fbs-https://build-system.fman.io/)应用程序,当我单击按钮时,我的ResetWiFi线程因Process finished with exit code 138 (interrupted by signal 10: SIGBUS)
崩溃
from time import sleep
from PySide2.QtCore import QThread
from fbs_runtime.application_context import ApplicationContext
from PySide2.QtWidgets import QMainWindow, QPushButton, QVBoxLayout
import sys
class TestThread(QThread):
def __init__(self, parent=None):
super(TestThread, self).__init__(parent)
def run(self):
for i in range(10):
print('Test')
sleep(1)
class AppContext(ApplicationContext): # 1. Subclass ApplicationContext
def run(self): # 2. Implement run()
window = QMainWindow()
button = QPushButton()
window.layout().addChildWidget(button)
self.tt = TestThread()
button.clicked.connect(self.tt.start)
version = self.build_settings['version']
window.setWindowTitle("MyAppTest v" + version)
window.resize(250, 150)
window.show()
return self.app.exec_() # 3. End run() with this line
if __name__ == '__main__':
appctxt = AppContext() # 4. Instantiate the subclass
exit_code = appctxt.run() # 5. Invoke run()
sys.exit(exit_code)
我将尝试像self.tt = TestThread()
那样写,但是不起作用。
在Linux上,它运作良好。仅在MacOS上有问题。