diff libinterp/corefcn/graphics.cc @ 19120:dc88c5784f74

Respect the order in which default graphics properties are set (bug #38449) * /libinterp/corefcn/graphics.cc (xreset_default_properties): use [] operator to store new prop/val * /libinterp/corefcn/graphics.cc: add %!test for bug #38449 * /libinterp/corefcn/graphics.in.h (pval_pair): new typedef for std::pair <std::string, octave_value> * /libinterp/corefcn/graphics.in.h (class pval_vector): new class to keep track of the order in which prop/val pairs are stored ** const_iterator find (const std::string pname), iterator find (const std::string pname)): mimic std::map::find ** octave_value lookup (const std::string pname)): mimic std::map::lookup ** octave_value& operator [] (const std::string pname)): mimic std::map [] operator ** void erase (const std::string pname): mimic std::map::erase ** void erase (iterator it): call std::vector <pval_pair>::erase
author Pantxo Diribarne <pantxo.diribarne@gmail.com>
date Sun, 07 Sep 2014 10:47:20 +0200
parents f984fc55a825
children 3e0720bd6bfc
line wrap: on
line diff
--- a/libinterp/corefcn/graphics.cc	Fri Sep 12 11:06:02 2014 -0400
+++ b/libinterp/corefcn/graphics.cc	Sun Sep 07 10:47:20 2014 +0200
@@ -2775,8 +2775,7 @@
         {
           // Store *mode prop/val in order to set them last 
           if (pname.find ("mode") == (pname.length () - 4))
-            pval.insert (std::pair<std::string, octave_value>
-                         (pname, it->second));
+            pval[pname] = it->second;
           else
             obj.set (pname, it->second);
         }
@@ -2819,6 +2818,22 @@
     }
 }
 
+/*
+## test defaults are set in the order they were stored
+%!test
+%! set(0, "defaultfigureunits", "normalized");
+%! set(0, "defaultfigureposition", [0.7 0 0.3 0.3]);
+%! hf = figure ("visible", "off");
+%! tol = 20 * eps;
+%! unwind_protect
+%!   assert (get (hf, "position"), [0.7 0 0.3 0.3], tol);
+%! unwind_protect_cleanup
+%!   close (hf);
+%!   set(0, "defaultfigureunits", "remove");
+%!   set(0, "defaultfigureposition", "remove");
+%! end_unwind_protect
+*/
+
 octave_value
 base_properties::get_dynamic (const caseless_str& name) const
 {