From c52453ef90ef30da4083059f2ce32c42aa9c89b3 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Sun, 1 Nov 2009 23:16:08 +0200 Subject: [PATCH] Rather use global than list to track app. --- scikits/image/io/qt_plugin.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scikits/image/io/qt_plugin.py b/scikits/image/io/qt_plugin.py index df0c521e..51a59c1e 100644 --- a/scikits/image/io/qt_plugin.py +++ b/scikits/image/io/qt_plugin.py @@ -2,7 +2,7 @@ import plugin import numpy as np import sys -app = [None] +app = None windows = [] try: @@ -33,6 +33,8 @@ else: windows.remove(self) def show(arr, block=True): + global app + arr = np.ascontiguousarray(arr.astype(np.uint8)) if arr.ndim != 3: raise ValueError("Qt only displays colour images.") @@ -40,8 +42,8 @@ else: if arr.shape[-1] == 4: raise ValueError("Alpha channels not yet supported.") - if not '-qt4thread' in sys.argv and app[0] is None: - app[0] = QApplication([]) + if not '-qt4thread' in sys.argv and app is None: + app = QApplication([]) iw = ImageWindow(arr) iw.show() @@ -49,7 +51,7 @@ else: # Keep track of window so that it doesn't get destroyed windows.append(iw) - if app[0] and block: - app[0].exec_() + if app and block: + app.exec_() plugin.register('qt', show=show)