BJImageCropper icon indicating copy to clipboard operation
BJImageCropper copied to clipboard

bug infinite loop

Open pocketal opened this issue 12 years ago • 3 comments

Hi Barrett Jacobsen

First of all, thanks for this great project, it's very helpful. Yesterday, i have found a bug during my test. In one case there is an infinite loop, in the while loop of the function call :

  • (void)constrainCropToImage; I think the block who create the pb is that one :

if (CGOriginX(frame) + CGWidth(frame) > CGWidth(cropView.superview.frame)) { ........ ........ }

To create this case I start my cropView to 0,0 with the max frame. Then I select the leftView and drag it slowly to the right and in one moment the program stop because of the while loop.

I have try to fixed the bug but I'm not sure.

Other question : If I want to crop the image and keep the ratio, what can I do ??

thanks a lot !!

pocketal avatar Nov 06 '12 13:11 pocketal

Can you post an xcode project with your test case, I can't duplicate this based off your description.

barrettj avatar Nov 12 '12 19:11 barrettj

how can I post a project please ?? thx

pocketal avatar Nov 16 '12 14:11 pocketal

Here is the fix I originally posted on another site. I've changed line "if (CGOriginX(frame) + CGWidth(frame) > CGWidth(cropView.superview.frame))" to "if (CGOriginX(frame) + CGWidth(frame) - CGWidth(cropView.superview.frame) > 0.01)" so that 0.0002 difference will not result in infinite loop and cropper will not hung. I'll submit a pull request.

TimurBK avatar Dec 02 '14 07:12 TimurBK