Mercurial > octave-nkf
diff src/graphics.cc @ 15069:7a3957ca99c3
Handle complex arguments in imagesc (bug #36866)
* image.m: Don't error out with complex images, show real part and
warn, like imshow.
* graphics.in.h (array_property): Change type_constraint to std::set
instead of std::list.
(array_property::add_constraint): Use std::set::insert instead of
std::list::push_back.
(image::properties::init): Add new "real" constraint.
* graphics.cc (array_property::validate): Check for new "real" type constraint.
* gl-render.cc (opengl_renderer::draw_image): Abort if no image data is found.
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Tue, 31 Jul 2012 18:06:54 -0400 |
parents | dd4ad69e4ab9 |
children |
line wrap: on
line diff
--- a/src/graphics.cc Tue Jul 31 15:40:52 2012 -0500 +++ b/src/graphics.cc Tue Jul 31 18:06:54 2012 -0400 @@ -1201,10 +1201,14 @@ // check value type if (type_constraints.size () > 0) { - for (std::list<std::string>::const_iterator it = type_constraints.begin (); - ! xok && it != type_constraints.end (); ++it) - if ((*it) == v.class_name ()) - xok = true; + if(type_constraints.find (v.class_name()) != type_constraints.end()) + xok = true; + + // check if complex is allowed (it's also of class "double", so + // checking that alone is not enough to ensure real type) + if (type_constraints.find ("real") != type_constraints.end () + && v.is_complex_type ()) + xok = false; } else xok = v.is_numeric_type ();