merge down update
ClosedPublic

Authored by nsmirnov on Aug 18 2017, 3:43 PM.

Diff Detail

Repository
R37 Krita
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
nsmirnov created this revision.Aug 18 2017, 3:43 PM
dkazakov requested changes to this revision.Aug 18 2017, 6:50 PM

Hi, @nsmirnov!

Please check KDE's coding policies to make formatting and indentation of the code correct :)
https://community.kde.org/Policies/Kdelibs_Coding_Style

And check my inline comments for details :)

libs/image/kis_layer_utils.cpp
685

This code will not work if the user merges down more than 2 layer. Please use KritaUtils::filterContainer() to filter out the nodes in the list. You can find an example in KisToolMove::startStrokeImpl().

libs/ui/kis_layer_manager.cc
637
  • We should use "self-descriptive names" for variables :)
  • in C++ bools are either 'true' or 'false'. They are not integers, although one can convert them to integers
641

Even though you added a check above guaranteeing that the size of selected nodes is not null, I would still recommend using more common and safe construction like for (it = selectedNodes.begin(); it != selectedNodes.end(); ++it). It is not guaranteed that one day someone comes and changes the 'if' above without noticing the problem in this loop.

643

As far as I can tell, there should have been break statement somewhere there.

Probably, we could still allow merging down multiple layer, but just don't delete them?

This revision now requires changes to proceed.Aug 18 2017, 6:50 PM
nsmirnov updated this revision to Diff 18568.Aug 23 2017, 6:56 AM
nsmirnov edited edge metadata.
nsmirnov updated this revision to Diff 18573.Aug 23 2017, 8:46 AM
dkazakov added inline comments.Aug 23 2017, 1:28 PM
libs/image/kis_layer_utils.cpp
687

Why do you check for (node == m_putAfter) here?

libs/ui/kis_layer_manager.cc
642

Why checking for m_view->activeNode() != node? It doesn't look too useful in the user's point of view... Or you there is some usecase I don't know about?

nsmirnov updated this revision to Diff 18621.Aug 23 2017, 7:06 PM
nsmirnov updated this revision to Diff 18623.Aug 23 2017, 7:27 PM
dkazakov added inline comments.Aug 24 2017, 9:54 AM
libs/image/kis_layer_utils.cpp
687

As far as I understand this check was used to support the previous check. Could you check if the merging four layers, two of which are locked still works correctly? By "correctly" I mean: one layer is added, two removed and two kept intact.

nsmirnov updated this revision to Diff 18711.Aug 24 2017, 7:10 PM
dkazakov requested changes to this revision.Aug 25 2017, 2:08 PM

Hi, @nsmirnov!

The patch itself works fine now. I have just reread the original task (T1587) and it says that the layers, used for the source of the merge but not deleted, should also be made hidden...

You can implement that by creating a new command class in KisLayerUtils and applying this command inside CleanUpNodes::populateChildCommands()

This revision now requires changes to proceed.Aug 25 2017, 2:08 PM
nsmirnov updated this revision to Diff 18782.Aug 25 2017, 10:59 PM
nsmirnov edited edge metadata.
dkazakov requested changes to this revision.Sep 1 2017, 4:24 PM

This patch has a major bug: the visibility change is not undone when pressing Ctrl+Z after doing the merge. To overcome this issue, one should create a new undo-command in KisLayerUtils and apply this command inside CleanUpNodes::populateChildCommands()

This revision now requires changes to proceed.Sep 1 2017, 4:24 PM
nsmirnov updated this revision to Diff 19909.Sep 25 2017, 6:00 PM
nsmirnov set the repository for this revision to R37 Krita.

Hi, @nsmirnov!

There is still a small bug: if a layer is invisible and locked, it gets deleted when doing multinode merge-down. I guess it happens somewhere in filterInvisibleNodes

libs/image/commands/kis_image_change_visibility_command.cpp
10

I guess you can avoid inheriting from KisImageCommand and inherit directly from KUndo2Command, you don't need any updates here :)

libs/image/kis_layer_utils.cpp
687

++it for iterators :)

dkazakov requested changes to this revision.Sep 26 2017, 6:00 AM

Mark as needs changes

This revision now requires changes to proceed.Sep 26 2017, 6:00 AM
nsmirnov updated this revision to Diff 20208.Oct 1 2017, 7:58 PM
dkazakov requested changes to this revision.Oct 2 2017, 8:22 PM

The patch doesn't compile because of wrong diff in kis_layer_utils.cpp

This revision now requires changes to proceed.Oct 2 2017, 8:22 PM
nsmirnov updated this revision to Diff 20272.Oct 2 2017, 8:48 PM
nsmirnov marked 5 inline comments as done.
This revision was automatically updated to reflect the committed changes.