# HG changeset patch # User Carnë Draug # Date 1382288237 -3600 # Node ID 292319fb7fcc8ea1dfcd7ee16750bd5fd8be8e96 # Parent 7903ae3b657d72e73f4cd6c7764ddcdca50de209 Catch Magick++ errors and warnings when pinging image (bug #40267) * __magick_read__.cc: enclose call to ping() into a try/catch block diff -r 7903ae3b657d -r 292319fb7fcc libinterp/dldfcn/__magick_read__.cc --- a/libinterp/dldfcn/__magick_read__.cc Sun Oct 20 16:41:54 2013 +0100 +++ b/libinterp/dldfcn/__magick_read__.cc Sun Oct 20 17:57:17 2013 +0100 @@ -652,8 +652,9 @@ } catch (Magick::ErrorCoder& e) { - // FIXME: there's a WarningCoder and ErrorCoder. Shouldn't this - // exception cause an error? + // XXX: why is this error being caught as a warning? It has always + // been like this (function was added the first time to the + // Octave Forge image package with cset d756a7b6d533) warning ("Magick++ coder error: %s", e.what ()); } catch (Magick::Exception& e) @@ -1447,9 +1448,22 @@ idx = 0; Magick::Image img; - img.subImage (idx); - img.subRange (1); - img.ping (filename); + img.subImage (idx); // start ping from this image (in case of multi-page) + img.subRange (1); // ping only one of them + try + { + img.ping (filename); + } + catch (Magick::Warning& w) + { + warning ("Magick++ warning: %s", w.what ()); + } + catch (Magick::Exception& e) + { + error ("Magick++ exception: %s", e.what ()); + return retval; + } + static const char *fields[] = {"rows", "columns", "format", 0}; octave_scalar_map ping = octave_scalar_map (string_vector (fields)); ping.setfield ("rows", octave_value (img.rows ()));