diff src/graphics.cc @ 10265:8c583af2cf64

validate text object children of axes objects
author John W. Eaton <jwe@octave.org>
date Thu, 04 Feb 2010 03:56:28 -0500
parents cd96d29c5efa
children 4b124317dc38
line wrap: on
line diff
--- a/src/graphics.cc	Thu Feb 04 03:55:41 2010 -0500
+++ b/src/graphics.cc	Thu Feb 04 03:56:28 2010 -0500
@@ -2664,7 +2664,28 @@
 				  const std::string& who,
 				  const octave_value& v)
 {
-  graphics_handle val = ::reparent (v, "set", who, __myhandle__, false);
+  graphics_handle val;
+
+  if (v.is_string ())
+    {
+      val = gh_manager::make_graphics_handle ("text", __myhandle__, false);
+
+      xset (val, "string", v);
+    }
+  else
+    {
+      graphics_object go = gh_manager::get_object (gh_manager::lookup (v));
+
+      if (go.isa ("text"))
+        val = ::reparent (v, "set", who, __myhandle__, false);
+      else
+        {
+          std::string cname = v.class_name ();
+
+          error ("set: expecting text graphics object or character string for %s property, found %s",
+                 who.c_str (), cname.c_str ());
+        }
+    }
 
   if (! error_state)
     {