From 10d60495c6d1c68a808db5e5d6e2e5131fe28303 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Sun, 1 Nov 2009 17:58:55 +0000
Subject: [PATCH] lock drawing per openglWindow; this should fix bug #1

---
 Fltk/openglWindow.cpp | 19 ++++++++-----------
 Fltk/openglWindow.h   |  1 +
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/Fltk/openglWindow.cpp b/Fltk/openglWindow.cpp
index 1684e4e72d..843035d823 100644
--- a/Fltk/openglWindow.cpp
+++ b/Fltk/openglWindow.cpp
@@ -38,12 +38,11 @@ static void lassoZoom(drawContext *ctx, mousePosition &click1, mousePosition &cl
 }
 
 openglWindow::openglWindow(int x, int y, int w, int h, const char *l)
-  : Fl_Gl_Window(x, y, w, h, l)
+  : Fl_Gl_Window(x, y, w, h, l), _lock(false),
+    _selection(ENT_NONE), _trySelection(0)
 {
   _ctx = new drawContext();
   for(int i = 0; i < 3; i++) _point[i] = 0.;
-  _selection = ENT_NONE;
-  _trySelection = 0;
   for(int i = 0; i < 4; i++) _trySelectionXYWH[i] = 0;
   _lassoXY[0] = _lassoXY[1] = 0;
 
@@ -110,9 +109,8 @@ void openglWindow::draw()
   // some drawing routines can create data (STL triangulations, etc.):
   // make sure that we don't fire draw() while we are already drawing
   // (e.g. du to an impromptu Fl::check())
-  static bool busy = false;
-  if(busy) return;
-  busy = true;
+  if(_lock) return;
+  _lock = true;
 
   Msg::Debug("openglWindow::draw()");
 
@@ -198,7 +196,7 @@ void openglWindow::draw()
     drawBorder();
   }
 
-  busy = false;
+  _lock = false;
 }
 
 openglWindow *openglWindow::_lastHandled = 0;
@@ -522,9 +520,8 @@ bool openglWindow::processSelectionBuffer(int type, bool multipleSelection,
   // some drawing routines can create data (STL triangulations, etc.):
   // make sure that we don't fire redraw while we are already drawing
   // (e.g. du to an impromptu Fl::check())
-  static bool busy = false;
-  if(busy) return false;
-  busy = true;
+  if(_lock) return false;
+  _lock = true;
 
   make_current();
   GLuint *selectionBuffer = new GLuint[size];
@@ -544,7 +541,7 @@ bool openglWindow::processSelectionBuffer(int type, bool multipleSelection,
   GLint numhits = glRenderMode(GL_RENDER);
   _ctx->render_mode = drawContext::GMSH_RENDER;
 
-  busy = false;
+  _lock = false;
 
   if(!numhits){ // no hits
     delete [] selectionBuffer;
diff --git a/Fltk/openglWindow.h b/Fltk/openglWindow.h
index d9d02ee9ed..daf7b44836 100644
--- a/Fltk/openglWindow.h
+++ b/Fltk/openglWindow.h
@@ -22,6 +22,7 @@ class openglWindow : public Fl_Gl_Window {
  private:
   static openglWindow *_lastHandled;
   static void _setLastHandled(openglWindow*);
+  bool _lock;
   mousePosition _click, _curr, _prev;
   drawContext *_ctx;
   double _point[3];
-- 
GitLab