From: Urban Wallasch Date: Tue, 11 May 2021 10:50:07 +0000 (+0200) Subject: * Fixed broken main window class singleton pattern. X-Git-Tag: v0.3~91 X-Git-Url: https://git.packet-gain.de/?a=commitdiff_plain;h=1f6946203e81d995322234844e5396461a1a2dda;p=ffpreview.git * Fixed broken main window class singleton pattern. --- diff --git a/ffpreview.py b/ffpreview.py index 2b9a330..867bafd 100755 --- a/ffpreview.py +++ b/ffpreview.py @@ -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):