Skip to content
This repository has been archived by the owner on Nov 29, 2020. It is now read-only.

fix crash if output has no margins #270

Closed
wants to merge 2 commits into from

Conversation

trufanov-nok
Copy link

resolves #210
ST crashes on line 255.

The problem must be with rounding rectangles in float coordinates to rectangles in integer coordinates. In some circumstances it rounds to -1 pixel for output rect and to +1 pixel for working rect. Working rect size becomes 1 pixel bigger than output page size and everything collapses. And non-zero margins seems to save ST from that. toAlignedRect() is using ceil() instead of round() for float coordinates conversion so the sizes should always match.

It crashes on line 255.

The problem must be with rounding rectangles in float coordinates to rectangles in integer coordinates. In some circumstances it rounds to -1 pixel for output rect and to +1 pixel for working rect. Working rect size becomes 1 pixel bigger than output page size and everything collapses. And non-zero margins seems to save ST from that. toAlignedRect() is using ceil() instead of round() for float coordinates conversion so the sizes should always match.
Sometimes `toAlignedRect` may return rect with coordinate < 0.0. Made additional checks for that.
{
int dy = -1*m_contentRect.top();
m_outRect.adjust(0,0,0,dy); // size increase
m_contentRect.adjust(0,dy,0,dy); // shift
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wondering if it might increase readability to use <cmath>.abs instead of multiplying this by -1.

what are your thoughts?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've no preferences in this case. You can change this if you want or let me know if you want me to do this.

@trufanov-nok trufanov-nok deleted the patch-2 branch September 16, 2017 23:18
@trufanov-nok
Copy link
Author

found same issue with m_outRect. So made the checks for it too here.
still no evidence that the problem is completely solved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants