* Fixed broken main window class singleton pattern.
authorUrban Wallasch <urban.wallasch@freenet.de>
Tue, 11 May 2021 10:50:07 +0000 (12:50 +0200)
committerUrban Wallasch <urban.wallasch@freenet.de>
Tue, 11 May 2021 10:50:07 +0000 (12:50 +0200)
ffpreview.py

index 2b9a33032679ac8753750a889208bc66de3e17e4..867bafd1783b09c43c25f3904998ae66dc3e12fb 100755 (executable)
@@ -447,6 +447,7 @@ class tScrollArea(QScrollArea):
 
 
 class sMainWindow(QMainWindow):
+    """ Application main window class singleton. """
     _instance = None
     px = 50
     py = 50
@@ -454,11 +455,13 @@ class sMainWindow(QMainWindow):
     tlheight = 0
     tlabels = []
 
+    def __new__(cls, *args, title='', **kwargs):
+        if cls._instance is None:
+            cls._instance = super().__new__(cls, *args, **kwargs)
+        return cls._instance
+
     def __init__(self, *args, title='', **kwargs):
-        if self._instance:
-            raise Exception ('No more than one main window allowed!')
         super().__init__(*args, **kwargs)
-        _instance = self
         self.init_window(title)
 
     def closeEvent(self, event):