#718: Mejorar la comprobación de salida de la sesión de usuario.
git-svn-id: https://opengnsys.es/svn/branches/version1.1@4971 a21b9725-9963-47de-94b9-378ad31fedc9remotes/github/oglive
parent
11f7a07988
commit
98fc98d803
|
@ -39,6 +39,7 @@ import time
|
|||
import signal
|
||||
import json
|
||||
import six
|
||||
import atexit
|
||||
|
||||
from opengnsys import ipc
|
||||
from opengnsys import utils
|
||||
|
@ -54,11 +55,15 @@ from opengnsys.loader import loadModules
|
|||
|
||||
trayIcon = None
|
||||
|
||||
|
||||
def sigTerm(sigNo, stackFrame):
|
||||
def sigAtExit():
|
||||
#logger.debug("Exec sigAtExit")
|
||||
if trayIcon:
|
||||
trayIcon.quit()
|
||||
|
||||
#def sigTerm(sigNo, stackFrame):
|
||||
# logger.debug("Exec sigTerm")
|
||||
# if trayIcon:
|
||||
# trayIcon.quit()
|
||||
|
||||
# About dialog
|
||||
class OGAAboutDialog(QtGui.QDialog):
|
||||
|
@ -161,7 +166,6 @@ class MessagesProcessor(QtCore.QThread):
|
|||
class OGASystemTray(QtGui.QSystemTrayIcon):
|
||||
def __init__(self, app_, parent=None):
|
||||
self.app = app_
|
||||
|
||||
self.config = readConfig(client=True)
|
||||
|
||||
# Get opengnsys section as dict
|
||||
|
@ -273,7 +277,7 @@ class OGASystemTray(QtGui.QSystemTrayIcon):
|
|||
def about(self):
|
||||
self.aboutDlg.exec_()
|
||||
|
||||
def quit(self):
|
||||
def cleanup(self):
|
||||
logger.debug('Quit invoked')
|
||||
if self.stopped is False:
|
||||
self.stopped = True
|
||||
|
@ -298,8 +302,17 @@ class OGASystemTray(QtGui.QSystemTrayIcon):
|
|||
except Exception:
|
||||
pass
|
||||
|
||||
def quit(self):
|
||||
#logger.debug("Exec quit {}".format(self.stopped))
|
||||
if self.stopped is False:
|
||||
self.cleanup()
|
||||
self.app.quit()
|
||||
|
||||
def closeEvent(self,event):
|
||||
logger.debug("Exec closeEvent")
|
||||
event.accept()
|
||||
self.quit()
|
||||
|
||||
if __name__ == '__main__':
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
|
||||
|
@ -325,10 +338,12 @@ if __name__ == '__main__':
|
|||
trayIcon.quit()
|
||||
sys.exit(1)
|
||||
|
||||
app.aboutToQuit.connect(trayIcon.cleanup)
|
||||
trayIcon.show()
|
||||
|
||||
# Catch kill and logout user :)
|
||||
signal.signal(signal.SIGTERM, sigTerm)
|
||||
#signal.signal(signal.SIGTERM, sigTerm)
|
||||
atexit.register(sigAtExit)
|
||||
|
||||
res = app.exec_()
|
||||
|
||||
|
|
Loading…
Reference in New Issue