diff options
author | Tavian Barnes <tavianator@gmail.com> | 2009-06-26 15:30:33 +0000 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2009-06-26 15:30:33 +0000 |
commit | 742c3b57c1f8e5d5666db5f20c7fa8c8a8c8e413 (patch) | |
tree | ab76865bb11f2f12f4a35dfa0dfed4323dce0ac4 | |
parent | 80f5ba4deb91b2d09654957ceba79ca11cc2465f (diff) | |
download | dimension-742c3b57c1f8e5d5666db5f20c7fa8c8a8c8e413.tar.xz |
Check for *_async() failure in png.cpp.
-rw-r--r-- | libdimensionxx/png.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/libdimensionxx/png.cpp b/libdimensionxx/png.cpp index 41162e6..d7081bd 100644 --- a/libdimensionxx/png.cpp +++ b/libdimensionxx/png.cpp @@ -106,9 +106,15 @@ namespace Dimension FILE_Cookie* cookie = new FILE_Cookie(*m_ostr); persister.persist(cookie); + // Start the asynchronous task + dmnsn_progress *progress + = dmnsn_png_write_canvas_async(canvas, cookie->file()); + if (!progress) { + throw Dimension_Error("Starting background PNG write failed."); + } + // Return the Progress object - return Progress(dmnsn_png_write_canvas_async(m_canvas, cookie->file()), - persister); + return Progress(progresss, persister); } // Read a PNG file in the background @@ -127,15 +133,22 @@ namespace Dimension FILE_Cookie* cookie = new FILE_Cookie(istr); persister.persist(cookie); + // Start the asynchronous task + dmnsn_progress *progress + = dmnsn_png_read_canvas_async(canvas, cookie->file()); + if (!progress) { + throw Dimension_Error("Starting background PNG read failed."); + } + // Return the Progress object - return Progress(dmnsn_png_read_canvas_async(canvas, cookie->file()), - persister); + return Progress(progresss, persister); } // Construct an input PNG_Canvas from a background task PNG_Canvas::PNG_Canvas(Progress& progress) : Canvas(), m_istr(0), m_ostr(0), m_written(false) { + // Will throw if progress is not from a PNG_Canvas::read_async call dmnsn_canvas** canvas = progress.persister().first<dmnsn_canvas*>().persisted(); @@ -153,6 +166,7 @@ namespace Dimension PNG_Canvas::PNG_Canvas(Progress& progress, std::ostream& ostr) : Canvas(), m_istr(0), m_ostr(&ostr), m_written(false) { + // Will throw if progress is not from a PNG_Canvas::read_async call dmnsn_canvas** canvas = progress.persister().first<dmnsn_canvas*>().persisted(); |