summaryrefslogtreecommitdiffstats
path: root/dimension/preview.py
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2014-04-23 18:12:53 -0400
committerTavian Barnes <tavianator@tavianator.com>2014-04-23 22:41:21 -0400
commit0acff566213fdddbc8f4561887aced121f82dc26 (patch)
tree97620a5ef72efc783d35817e4349a9f8a1d8cff8 /dimension/preview.py
parent3ce3ed46f5cd95bfca4f9303c93859fac54476bb (diff)
downloaddimension-0acff566213fdddbc8f4561887aced121f82dc26.tar.xz
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.
Diffstat (limited to 'dimension/preview.py')
-rw-r--r--dimension/preview.py5
1 files changed, 4 insertions, 1 deletions
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 <tavianator@tavianator.com> #
+# Copyright (C) 2011-2014 Tavian Barnes <tavianator@tavianator.com> #
# #
# 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."""