Bug 273357

Summary: The canvas is not scrolled to the cropped area after the crop
Product: [Applications] krita Reporter: Dmitry Kazakov <dimula73>
Component: GeneralAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED DUPLICATE    
Severity: critical CC: halla
Priority: NOR    
Version: git master (please specify the git hash!)   
Target Milestone: ---   
Platform: Unlisted Binaries   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: screenshot of the bug

Description Dmitry Kazakov 2011-05-15 18:27:47 UTC
This affects Crop, Resize, Size Canvas and other actions those change the size of the image.

1) Zoom the image in
2) Crop a small part of the bottom-right corner of the image
3) The view of the image will be moved to the top-left corner of the window.
Comment 1 Sven Langkamp 2011-08-12 01:54:27 UTC
Git commit efa9863ff712100367193f17d4acb0569abae279 by Sven Langkamp.
Committed on 12/08/2011 at 03:52.
Pushed by langkamp into branch 'master'.

fit to page after crop
BUG:273357

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

http://commits.kde.org/calligra/efa9863ff712100367193f17d4acb0569abae279
Comment 2 srikanth Tiyyagura 2011-08-12 16:48:42 UTC
Git commit 5523b353ffb8a7515374903f608b847faf0f91d2 by Srikanth Tiyyagura, on behalf of Sven Langkamp.
Committed on 12/08/2011 at 03:52.
Pushed by tiyyagura into branch 'krita_resource-management-tagging-tiyyagura'.

fit to page after crop
BUG:273357

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

http://commits.kde.org/calligra/5523b353ffb8a7515374903f608b847faf0f91d2
Comment 3 Inge Wallin 2011-08-16 08:09:46 UTC
Git commit 0f23eb9e726cfae6253af327340520b19f0b4c7d by Inge Wallin, on behalf of Sven Langkamp.
Committed on 12/08/2011 at 03:52.
Pushed by ingwa into branch 'nondestructive-unavail-leinir'.

fit to page after crop
BUG:273357

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

http://commits.kde.org/calligra/0f23eb9e726cfae6253af327340520b19f0b4c7d
Comment 4 Dmitry Kazakov 2011-08-22 06:32:35 UTC
The fix doesn't work. See attachment.

Problems:
1) The crop tool doesn't work with QPainter canvas (explanation below)
2) The fix doesn't fix Resize Image action
3) The fix doesn't fix Scale Image action
4) The fix doesn't work with undo/redo

Explanation:
You shouldn't call to setSize directly from anywhere other than from a couple of zoom classes. The setting of the zoom should happen automatically by zoom classes, basing on the signals emitted by the image. Calling setZoom manually causes a kind of race conditions between your call and the other recipients  of image signals. That is exactly what happens in your fix. KisPrescaledProjection is connected to a signal "size changed" from the image. It updates the cache, changes its size and redraws the canvas on the signal delivery. With calling setZoom manually, the order of the execution goes wrong somewhere.

How it is supposed to work:
1) Image emits "size changed" or "resolution changed" signal.
2) View gets this signal
3) Notifies canvas (prescaled projection) about the size change
4) Updates the zoom values
5) Prescaled projection gets the signal that the zoom changed and redraws the canvas

The order may be a bit different, but the main idea is that everything should happen on the delivery of the signal, no direct calls.
Comment 5 Dmitry Kazakov 2011-08-22 06:32:57 UTC
Created attachment 63033 [details]
screenshot of the bug
Comment 6 Halla Rempt 2011-10-16 13:51:39 UTC
This really needs to be fixed before we release 2.4. It might be the most irritating and embarrassing bug in Krita
Comment 7 Dmitry Kazakov 2011-10-30 18:06:33 UTC
Fixed by Thorsten Zachmann in b85f2e520fb172bc7d1c7f07f8f9aa44ee03dda9
Comment 8 Halla Rempt 2011-10-30 18:35:21 UTC
Cropping is now completely broken visually: on cropping, the top-left area of the image is shown, though the actual crop is done correctly.
Comment 9 Halla Rempt 2011-11-04 19:48:44 UTC
Closing this one as duplicate of 250146

*** This bug has been marked as a duplicate of bug 250146 ***