Skip to content

Commit

Permalink
prevent crash on drawing when extruder offset is set too large
Browse files Browse the repository at this point in the history
  • Loading branch information
hurzl committed Feb 29, 2016
1 parent b7bf048 commit d22a585
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/slicer/geometry.cpp
Expand Up @@ -1406,8 +1406,10 @@ int getCairoSurfaceDatapoint(const Cairo::RefPtr<Cairo::ImageSurface> surface,
const unsigned char * data = surface->get_data();
const Vector2d diag = max - min;
const Vector2d relp = p - min;
const int ipx = (int)(relp.x() / diag.x() * (double)w);
const int ipy = (int)(relp.y() / diag.y() * (double)h);
int ipx = (int)(relp.x() / diag.x() * (double)w);
int ipy = (int)(relp.y() / diag.y() * (double)h);
if (ipx < 0) ipx = 0;
if (ipy < 0) ipy = 0;
int value = data[ipy*w + ipx];
return value;
}

0 comments on commit d22a585

Please sign in to comment.