[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [28731] trunk/blender/source/blender/ editors: fix for hanging while drawing fcurves, the function made some attempt to avoid the problem but when the view is zero pixels wide it still hung for some time .

Campbell Barton ideasman42 at gmail.com
Tue May 11 23:46:22 CEST 2010


Revision: 28731
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=28731
Author:   campbellbarton
Date:     2010-05-11 23:46:20 +0200 (Tue, 11 May 2010)

Log Message:
-----------
fix for hanging while drawing fcurves, the function made some attempt to avoid the problem but when the view is zero pixels wide it still hung for some time.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/UI_view2d.h
    trunk/blender/source/blender/editors/interface/view2d.c
    trunk/blender/source/blender/editors/space_graph/graph_draw.c

Modified: trunk/blender/source/blender/editors/include/UI_view2d.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_view2d.h	2010-05-11 20:38:01 UTC (rev 28730)
+++ trunk/blender/source/blender/editors/include/UI_view2d.h	2010-05-11 21:46:20 UTC (rev 28731)
@@ -164,6 +164,7 @@
 View2DGrid *UI_view2d_grid_calc(const struct bContext *C, struct View2D *v2d, short xunits, short xclamp, short yunits, short yclamp, int winx, int winy);
 void UI_view2d_grid_draw(const struct bContext *C, struct View2D *v2d, View2DGrid *grid, int flag);
 void UI_view2d_constant_grid_draw(const struct bContext *C, struct View2D *v2d);
+void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy);
 void UI_view2d_grid_free(View2DGrid *grid);
 
 /* scrollbar drawing */

Modified: trunk/blender/source/blender/editors/interface/view2d.c
===================================================================
--- trunk/blender/source/blender/editors/interface/view2d.c	2010-05-11 20:38:01 UTC (rev 28730)
+++ trunk/blender/source/blender/editors/interface/view2d.c	2010-05-11 21:46:20 UTC (rev 28731)
@@ -1314,6 +1314,13 @@
 	glEnd();
 }
 
+/* the price we pay for not exposting structs :( */
+void UI_view2d_grid_size(View2DGrid *grid, float *r_dx, float *r_dy)
+{
+	*r_dx= grid->dx;
+	*r_dy= grid->dy;
+}
+
 /* free temporary memory used for drawing grid */
 void UI_view2d_grid_free(View2DGrid *grid)
 {

Modified: trunk/blender/source/blender/editors/space_graph/graph_draw.c
===================================================================
--- trunk/blender/source/blender/editors/space_graph/graph_draw.c	2010-05-11 20:38:01 UTC (rev 28730)
+++ trunk/blender/source/blender/editors/space_graph/graph_draw.c	2010-05-11 21:46:20 UTC (rev 28731)
@@ -502,7 +502,15 @@
 	float samplefreq, ctime;
 	float stime, etime;
 	float unitFac;
-	
+	float dx, dy;
+
+	/* when opening a blend file on a different sized screen or while dragging the toolbar this can happen
+	 * best just bail out in this case */
+	UI_view2d_grid_size(grid, &dx, &dy);
+	if(dx <= 0.0f)
+		return;
+
+
 	/* disable any drivers temporarily */
 	driver= fcu->driver;
 	fcu->driver= NULL;
@@ -522,11 +530,9 @@
 	 *	loop (i.e. too close to 0), then clamp it to a determined "safe" value. The value
 	 * 	chosen here is just the coarsest value which still looks reasonable...
 	 */
-		/* grid->dx is the first float in View2DGrid struct, so just cast to float pointer, and use it
-		 * It represents the number of 'frames' between gridlines, but we divide by U.v2d_min_gridsize to get pixels-steps
-		 */
+		/* grid->dx represents the number of 'frames' between gridlines, but we divide by U.v2d_min_gridsize to get pixels-steps */
 		// TODO: perhaps we should have 1.0 frames as upper limit so that curves don't get too distorted?
-	samplefreq= *((float *)grid) / U.v2d_min_gridsize;
+	samplefreq= dx / U.v2d_min_gridsize;
 	if (samplefreq < 0.00001f) samplefreq= 0.00001f;
 	
 	





More information about the Bf-blender-cvs mailing list