From 0acff566213fdddbc8f4561887aced121f82dc26 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 23 Apr 2014 18:12:53 -0400 Subject: future: Add a race-free way to examine a partial computation. This allows safe OpenGL previews, for example. dmnsn_future* learned the dmnsn_future_{pause,resume}() functions which cause all worker threads to block. render.test now survives Helgrind with no errors. --- dimension/preview.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'dimension') diff --git a/dimension/preview.py b/dimension/preview.py index fd56123..bc8e105 100644 --- a/dimension/preview.py +++ b/dimension/preview.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ######################################################################### -# Copyright (C) 2011-2012 Tavian Barnes # +# Copyright (C) 2011-2014 Tavian Barnes # # # # This file is part of Dimension. # # # @@ -30,11 +30,14 @@ class Preview(QtOpenGL.QGLWidget): def paintGL(self): try: + self.future.pause() self.canvas.draw_GL() except: self.future.cancel() self.parent().close() raise + finally: + self.future.resume() class PreviewWindow(QtGui.QMainWindow): """Main window for a rendering preview.""" -- cgit v1.2.3