File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -448,8 +448,19 @@ def __init__(self):
448448 window .setWindowTitle (INITITLE )
449449
450450 # catch control c and terminate signals
451- signal .signal (signal .SIGTERM , self .shutdown )
452- signal .signal (signal .SIGINT , self .shutdown )
451+ # Quit the Qt event loop on the signal so APP.exec() returns and the
452+ # shutdown() below runs the normal cleanup once. Calling shutdown()
453+ # directly from the handler would clean up but leave the loop running.
454+ # Quitting the loop also bypasses the window-close confirmation dialog,
455+ # which is correct for a terminate request and leaves that interactive
456+ # feature untouched. Qt's C++ event loop does not return to Python often
457+ # enough to run Python signal handlers, so a periodic no-op timer yields
458+ # to the interpreter to let them fire.
459+ signal .signal (signal .SIGTERM , lambda * a : APP .quit ())
460+ signal .signal (signal .SIGINT , lambda * a : APP .quit ())
461+ self ._signal_timer = QtCore .QTimer ()
462+ self ._signal_timer .timeout .connect (lambda : None )
463+ self ._signal_timer .start (200 )
453464
454465 # check for handler file and if it has 'before_loop' function in
455466 # ineach screen/embedded panel. (screen should be last)
You can’t perform that action at this time.
0 commit comments