Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-05-12 01:46:20 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-05-12 01:46:20 +0400
commitd153850520cc191b7cfad6c84cd56bebadeda376 (patch)
tree8b0e064c15ff4057f73a5d4400b26b472963a5bf /source/blender/editors
parent3088bda1b7daf70ff924ccdfcbd6f3f8319ac6dd (diff)
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.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/include/UI_view2d.h1
-rw-r--r--source/blender/editors/interface/view2d.c7
-rw-r--r--source/blender/editors/space_graph/graph_draw.c16
3 files changed, 19 insertions, 5 deletions
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h
index 38c2780608f..bf4a3de9cc6 100644
--- a/source/blender/editors/include/UI_view2d.h
+++ b/source/blender/editors/include/UI_view2d.h
@@ -164,6 +164,7 @@ void UI_view2d_view_restore(const struct bContext *C);
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 */
diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c
index d482f20b077..9a88a52d4b4 100644
--- a/source/blender/editors/interface/view2d.c
+++ b/source/blender/editors/interface/view2d.c
@@ -1314,6 +1314,13 @@ void UI_view2d_constant_grid_draw(const bContext *C, View2D *v2d)
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)
{
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index b297178c498..543bd8b9964 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -502,7 +502,15 @@ static void draw_fcurve_curve (bAnimContext *ac, ID *id, FCurve *fcu, SpaceIpo *
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 @@ static void draw_fcurve_curve (bAnimContext *ac, ID *id, FCurve *fcu, SpaceIpo *
* 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;