diff options
author | Tavian Barnes <tavianator@gmail.com> | 2011-09-18 17:02:26 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2011-09-18 17:02:26 -0400 |
commit | d6aa225ca7990fde1eac09e28078e71b73d113ce (patch) | |
tree | 0e23549ee8ed93edd8f8bc9ff8c90af93fe21faa | |
parent | 126c9b7b4b2c5f43b7d86f821bf5b7a416836a7e (diff) | |
download | dimension-d6aa225ca7990fde1eac09e28078e71b73d113ce.tar.xz |
Fix --disable-png behaviour in the Python module.
-rw-r--r-- | dimension/tests/demo.dmnsn | 8 | ||||
-rw-r--r-- | libdimension-python/dimension.pyx | 16 | ||||
-rwxr-xr-x | libdimension-python/tests/canvas.py | 4 | ||||
-rwxr-xr-x | libdimension-python/tests/demo.py | 1 |
4 files changed, 23 insertions, 6 deletions
diff --git a/dimension/tests/demo.dmnsn b/dimension/tests/demo.dmnsn index 040ae4f..3a04abc 100644 --- a/dimension/tests/demo.dmnsn +++ b/dimension/tests/demo.dmnsn @@ -23,10 +23,16 @@ camera = PerspectiveCamera(location = (0, 0.25, -4), camera.rotate(53*Y) # Background + +try: + image_map = ImageMap("../../libdimension/tests/png2.png").rotate(53*Y) +except OSError: + image_map = Orange + background = PigmentMap( pattern = Gradient(Y), map = { - 0: ImageMap("../../libdimension/tests/png2.png").rotate(53*Y), + 0: image_map, 0.35: Color(0, 0.1, 0.2, trans = 0.1, filter = 0.0), }, ) diff --git a/libdimension-python/dimension.pyx b/libdimension-python/dimension.pyx index b8855fe..dffa8fa 100644 --- a/libdimension-python/dimension.pyx +++ b/libdimension-python/dimension.pyx @@ -569,9 +569,19 @@ cdef class Canvas: if fclose(file) != 0: _raise_OSError() - progress = _Progress(dmnsn_png_write_canvas_async(self._canvas, file)) - progress._finalizer = finalize - return progress + cdef dmnsn_progress *progress = dmnsn_png_write_canvas_async(self._canvas, + file) + + try: + if progress == NULL: + _raise_OSError() + + ret = _Progress(progress) + ret._finalizer = finalize + return ret + except: + finalize() + raise def draw_GL(self): """Export the canvas to the current OpenGL context.""" diff --git a/libdimension-python/tests/canvas.py b/libdimension-python/tests/canvas.py index 3b2057e..239a548 100755 --- a/libdimension-python/tests/canvas.py +++ b/libdimension-python/tests/canvas.py @@ -19,8 +19,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # ######################################################################### -from dimension import * import errno +from dimension import * # Treat warnings as errors for tests die_on_warnings(True) @@ -35,7 +35,7 @@ try: canvas.optimize_PNG() except OSError as e: if e.errno == errno.ENOSYS: - havePNG = False + have_PNG = False else: raise diff --git a/libdimension-python/tests/demo.py b/libdimension-python/tests/demo.py index fe3518c..a9774bc 100755 --- a/libdimension-python/tests/demo.py +++ b/libdimension-python/tests/demo.py @@ -21,6 +21,7 @@ import os import os.path +import errno from math import * from dimension import * |