From 1f6946203e81d995322234844e5396461a1a2dda Mon Sep 17 00:00:00 2001 From: Urban Wallasch Date: Tue, 11 May 2021 12:50:07 +0200 Subject: [PATCH] * Fixed broken main window class singleton pattern. --- ffpreview.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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): -- 2.30.2