Bug 346430

Summary: Crop tool failed to recognize current document size after using it for once
Product: [Applications] krita Reporter: Tyson Tan <tysontanx>
Component: Tools/TransformAssignee: Krita Bugs <krita-bugs-null>
Status: RESOLVED FIXED    
Severity: major CC: freebox64, halla
Priority: NOR    
Version First Reported In: 2.9.1   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Tyson Tan 2015-04-21 14:45:40 UTC
Crop tool in 2.9.x has been broken for a long time. The bug I'm about to report is probably related to Bug 343722. Please allow me to remind you that Bug 343722 is labeled RESOLVED/FIXED, but it actually is NOT. I somehow cannot reopen that bug. No reopen item in the drop list! Could also related to BUG 342023, BUG 343287, BUG 342842, BUG 342844, because they were all broken about the same period of time. 

This bug:
After using Crop tool when Grow option is ON, it doesn't recognize the current document boundary next time you use it when Grow option is OFF.

Reproducible: Always

Steps to Reproduce:
1. Create a 100x100 px new document;
2. Crop tool, check Grow option, trim the picture to 90x90, OR grow the picture to 120x120;
3. Crop tool, uncheck Grow option, drag handles to picture boundary.

Actual Results:  
The handles always recognize 100x100 (size before crop) as the boundary instead of the current size. This is disastrous when growing/trimming high-res pictures with precision.

Expected Results:  
Crop tool always recognize current boundary correctly.

This bug exists before 2.9 is released. It gave me much hard time but I couldn't figure it out. I finally reproduced it today reliably so I decided to file a report. Crop tool is very important so please fix this ASAP.
Comment 1 Halla Rempt 2015-04-21 15:04:06 UTC
I've reopened the bug.
Comment 2 Halla Rempt 2015-04-21 15:08:57 UTC
I've also given you the powers to edit all aspects of a bug -- I'll try and look at this bug tonight, after dinner.
Comment 3 Halla Rempt 2015-04-21 17:48:24 UTC
Git commit 822bbde486bc8d52ddb3f99f466c8bc30e96009a by Boudewijn Rempt.
Committed on 21/04/2015 at 17:47.
Pushed by rempt into branch 'calligra/2.9'.

M  +1    -0    krita/plugins/tools/tool_crop/kis_tool_crop.cc
M  +16   -21   krita/plugins/tools/tool_crop/wdg_tool_crop.ui

http://commits.kde.org/calligra/822bbde486bc8d52ddb3f99f466c8bc30e96009a
Comment 4 Halla Rempt 2015-04-21 18:35:04 UTC
Git commit 46f7f079e96968f2261b697851213e891515cbfe by Boudewijn Rempt.
Committed on 21/04/2015 at 18:34.
Pushed by rempt into branch 'calligra/2.9'.

Also reset the final rect after cropping with the new image size

M  +3    -0    krita/plugins/tools/tool_crop/kis_tool_crop.cc

http://commits.kde.org/calligra/46f7f079e96968f2261b697851213e891515cbfe
Comment 5 Tyson Tan 2015-04-22 01:02:16 UTC
Thank you, Boud! Crop tool works like a charm now. :D
Comment 6 Tyson Tan 2015-04-24 13:45:12 UTC
Sorry, today I found Crop tool has new problems when used with Scale tool. 

Steps to reproduce of problem A:
1. Create a new 1000x1000 document;
2. Menu>Image>Scale to 100x100;
3. Crop tool, choose the whole canvas then ESC to cancel (you can crop, the result is the same);
4. Undo the resize so it's back to 1000x1000;
5. Crop tool (grow unchecked)  can only select a 100x100 area.

Steps to reproduce of problem B:
1. Create a new 100x100 document;
2. Menu>Image>Scale to 1000x1000;
3. Crop tool, choose the whole canvas then ESC to cancel (you can crop, the result is the same)
4. Ctrl+Z to undo resizing, back to 100x100;
5. Crop tool (grow unchecked) can now go 1000x1000.
Comment 7 Tyson Tan 2015-05-22 03:35:13 UTC
Today I further narrowed down this bug. It appeared that 2 Crop actions in a row messed it up:

----------------------

Problem A:
Crop handles can go outside the canvas without turning on Grow.

Steps:
1. Create a 1000x1000 new document;
2. Crop it into 1000x500;
3. Crop again, drag the handles outside the edges;
4. The handles can still go as large as 1000x1000 without turning on Grow;

----------------------

Problem B:
Crop handles can only cover a small size within the canvas.

1. Create a 1000x1000 new document;
2. Resize it to 200x200;
3. Crop it once, same 200x200 is fine, because it doesn't matter;
4. Ctrl+Z twice, undo everything back to 1000x1000;
5. Crop tool;
6. Now the handles cannot go bigger than a 200x200 square.

----------------------

Workaround: 
Toggle Grow to clear this weird state.
Comment 8 mvowada 2015-05-22 09:39:12 UTC
Yes, I can reproduce both. It seems like the Crop tool ignores that the sizes of the document have changed after the first cropping. 
If it was true, it would lead to wonder from where it actually draws the document sizes for its maths, just before cropping.
Comment 9 T Zachmann 2016-01-19 18:23:47 UTC
Git commit 85708743c62802840185db74e05a85d35599a048 by Thorsten Zachmann.
Committed on 19/01/2016 at 18:22.
Pushed by zachmann into branch 'master'.

Fix bug 346430

Make sure the crop tool allways uses the currect image size.

M  +1    -3    krita/plugins/tools/tool_crop/kis_tool_crop.cc

http://commits.kde.org/krita/85708743c62802840185db74e05a85d35599a048
Comment 10 Halla Rempt 2016-01-20 10:10:06 UTC
Git commit 45316325d47d9f4b48d4f84b69c0827bbcdb9844 by Boudewijn Rempt.
Committed on 20/01/2016 at 10:09.
Pushed by rempt into branch 'calligra/2.9'.

Fix bug 346430

Make sure the crop tool allways uses the correct image size.
Patch by Thorsten Zachmann

M  +1    -3    krita/plugins/tools/tool_crop/kis_tool_crop.cc

http://commits.kde.org/calligra/45316325d47d9f4b48d4f84b69c0827bbcdb9844