From faa32ad8dbc4a31a7330aa5f33c4ea813ccf48ff Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Thu, 27 May 2021 12:41:54 +0200 Subject: [PATCH] added atexit callback to tray widget --- openpype/tools/tray/pype_tray.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/openpype/tools/tray/pype_tray.py b/openpype/tools/tray/pype_tray.py index 534c99bd90..23421fdbf1 100644 --- a/openpype/tools/tray/pype_tray.py +++ b/openpype/tools/tray/pype_tray.py @@ -1,5 +1,6 @@ import os import sys +import atexit import platform from avalon import style @@ -116,6 +117,8 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon): super(SystemTrayIcon, self).__init__(icon, parent) + self._exited = False + # Store parent - QtWidgets.QMainWindow() self.parent = parent @@ -134,6 +137,8 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon): # Add menu to Context of SystemTrayIcon self.setContextMenu(self.menu) + atexit.register(self.exit) + def on_systray_activated(self, reason): # show contextMenu if left click if reason == QtWidgets.QSystemTrayIcon.Trigger: @@ -145,6 +150,10 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon): - Icon won't stay in tray after exit. """ + if self._exited: + return + self._exited = True + self.hide() self.tray_man.on_exit() QtCore.QCoreApplication.exit()