Skip to content

Commit

Permalink
Make onLogTheEnd() a Python atexit function
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdnyc committed Oct 2, 2019
1 parent 5f08a30 commit 0725010
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions src/classes/app.py
Expand Up @@ -31,6 +31,7 @@
import sys
import platform
import traceback
import atexit
from uuid import uuid4
from PyQt5.QtWidgets import QApplication, QStyleFactory, QMessageBox
from PyQt5.QtGui import QPalette, QColor, QFontDatabase, QFont
Expand Down Expand Up @@ -102,9 +103,6 @@ def __init__(self, *args, mode=None):
except Exception:
pass

# Connect QCoreApplication::aboutToQuit() signal to log end of the session
self.aboutToQuit.connect(self.onLogTheEnd)

# Setup application
self.setApplicationName('openshot')
self.setApplicationVersion(info.SETUP['version'])
Expand Down Expand Up @@ -257,19 +255,17 @@ def run(self):
# return exit result
return res

# Log the session's end
@pyqtSlot()
def onLogTheEnd(self):
""" Log when the primary Qt event loop ends """
# Log the session's end
@atexit.register
def onLogTheEnd():
""" Log when the primary Qt event loop ends """

try:
from classes.logger import log
import time
log.info('OpenShot\'s session ended'.center(48))
log.info(time.asctime().center(48))
log.info("================================================")
except Exception:
pass
try:
from classes.logger import log
import time
log.info('OpenShot\'s session ended'.center(48))
log.info(time.asctime().center(48))
log.info("================================================")
except Exception:
pass

# return 0 on success
return 0

0 comments on commit 0725010

Please sign in to comment.