From b51ec26d568ca5bc3e2a4525004247f15caebcd2 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Wed, 22 Nov 2006 02:39:18 +0000 Subject: [PATCH] fix crash when trying to draw a geom while the db is being built --- Common/Context.h | 2 +- Common/Options.cpp | 3 ++- Fltk/GUI.cpp | 9 +-------- Graphics/Geom.cpp | 4 +++- Parser/OpenFile.cpp | 5 ++++- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Common/Context.h b/Common/Context.h index f5a3dfeb0a..915c2c33be 100644 --- a/Common/Context.h +++ b/Common/Context.h @@ -145,7 +145,7 @@ public : int points_num, lines_num, surfaces_num, volumes_num; double point_size, line_width, point_sel_size, line_sel_width; int point_type, line_type; // flat or 3D - int light; + int draw, light; int old_circle, circle_points; int extrude_spline_points, old_newreg; double normals, tangents; diff --git a/Common/Options.cpp b/Common/Options.cpp index 5b3e749d16..0899e89604 100644 --- a/Common/Options.cpp +++ b/Common/Options.cpp @@ -1,4 +1,4 @@ -// $Id: Options.cpp,v 1.314 2006-11-02 17:24:53 geuzaine Exp $ +// $Id: Options.cpp,v 1.315 2006-11-22 02:39:17 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -135,6 +135,7 @@ void Init_Options(int num) CTX.mesh_timer[0] = CTX.mesh_timer[1] = CTX.mesh_timer[2] = 0.; CTX.draw_rotation_center = 0; CTX.pick_elements = 0; + CTX.geom.draw = 1; CTX.mesh.draw = 1; CTX.post.draw = 1; CTX.post.list = NULL; diff --git a/Fltk/GUI.cpp b/Fltk/GUI.cpp index 3003a4742a..5302b39439 100644 --- a/Fltk/GUI.cpp +++ b/Fltk/GUI.cpp @@ -1,4 +1,4 @@ -// $Id: GUI.cpp,v 1.561 2006-11-07 19:47:12 geuzaine Exp $ +// $Id: GUI.cpp,v 1.562 2006-11-22 02:39:17 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -1351,11 +1351,7 @@ void GUI::create_graphic_window() bottom->box(FL_FLAT_BOX); int x = 2; -#if defined(WIN32) - int sht = sh - 2; // go all the way to the bottom of the window -#else int sht = sh - 4; // leave a 2 pixel border at the bottom -#endif g_status_butt[0] = new Fl_Button(x, glheight + 2, sw, sht, "X"); x += sw; @@ -1427,9 +1423,6 @@ void GUI::create_graphic_window() x += 2; int wleft = (width - x) / 3 - 1; int wright = (width - x) - (width - x) / 3 - 1; -#if defined(WIN32) - wright += 1; // go right up to the right edge of the window -#endif g_status_label[0] = new Fl_Box(x, glheight + 2, wleft, sht); g_status_label[1] = new Fl_Box(x + (width - x) / 3, glheight + 2, wright, sht); diff --git a/Graphics/Geom.cpp b/Graphics/Geom.cpp index b40f181193..b2b48d3db1 100644 --- a/Graphics/Geom.cpp +++ b/Graphics/Geom.cpp @@ -1,4 +1,4 @@ -// $Id: Geom.cpp,v 1.122 2006-11-14 17:11:33 remacle Exp $ +// $Id: Geom.cpp,v 1.123 2006-11-22 02:39:18 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -404,6 +404,8 @@ class drawGRegion { void Draw_Geom() { + if(!CTX.geom.draw) return; + glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); for(int i = 0; i < 6; i++) diff --git a/Parser/OpenFile.cpp b/Parser/OpenFile.cpp index 9ea5605620..3c8dd3e83a 100644 --- a/Parser/OpenFile.cpp +++ b/Parser/OpenFile.cpp @@ -1,4 +1,4 @@ -// $Id: OpenFile.cpp,v 1.128 2006-11-21 23:03:13 geuzaine Exp $ +// $Id: OpenFile.cpp,v 1.129 2006-11-22 02:39:18 geuzaine Exp $ // // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // @@ -289,6 +289,7 @@ int MergeProblem(char *name, int warn_if_missing) } #endif + CTX.geom.draw = 0; // don't try to draw the model while reading int status = 0; if(!strcmp(ext, ".stl") || !strcmp(ext, ".STL")){ status = GMODEL->readSTL(name, CTX.mesh.stl_distance_tol); @@ -343,6 +344,7 @@ int MergeProblem(char *name, int warn_if_missing) #endif #endif else { + CTX.geom.draw = 1; if(!strncmp(header, "$PTS", 4) || !strncmp(header, "$NO", 3) || !strncmp(header, "$PARA", 5) || !strncmp(header, "$ELM", 4) || !strncmp(header, "$MeshFormat", 11)) { @@ -359,6 +361,7 @@ int MergeProblem(char *name, int warn_if_missing) SetBoundingBox(); + CTX.geom.draw = 1; CTX.mesh.changed = ENT_ALL; Msg(STATUS2, "Read '%s'", name); -- GitLab