changeset 12380:e8f17ad29f95 release-3-4-x

Prevent race condition in update_axes_layout
author Konstantinos Poulios <logari81@googlemail.com>
date Sun, 06 Feb 2011 02:24:28 +0100
parents aafbaea219cb
children c87c97f16862
files src/ChangeLog src/graphics.cc
diffstat 2 files changed, 15 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
+2011-02-06  Konstantinos Poulios  <logari81@googlemail.com>
+
+	* graphics.cc (updating_axes_layout): New file-scope variable.
+	(axes::properties::update_axes_layout):	Return immediately if
+	updating_axes_layout is true.
+
 2011-02-03  John W. Eaton  <jwe@octave.org>
 
 	* octave.cc: Include <sys/types.h> and <unistd.h> for isatty.
--- a/src/graphics.cc
+++ b/src/graphics.cc
@@ -3899,9 +3899,14 @@
   x_gl_mat2 = x_viewport * x_projection;
 }
 
+static bool updating_axes_layout = false;
+
 void
 axes::properties::update_axes_layout (void)
 {
+  if (updating_axes_layout)
+    return;
+
   graphics_xform xform = get_transform ();
 
   double xd = (xdir_is ("normal") ? 1 : -1);
@@ -3991,6 +3996,10 @@
   zPlaneN = (zPlane == z_min ? z_max : z_min);
   fz = (z_max-z_min)/sqrt(dir(0)*dir(0)+dir(1)*dir(1));
 
+  unwind_protect frame;
+  frame.protect_var (updating_axes_layout);
+  updating_axes_layout = true;
+
   update_ticklengths ();
 
   xySym = (xd*yd*(xPlane-xPlaneN)*(yPlane-yPlaneN) > 0);