WIP: Change how deleting a layer works (Bugfix)
Fixes inbox#57 (moved)
Also deleting layer sets sibling of equal depth as current
I.e. Normally if you delete the bottom layer, Inkscape goes to the next layer. If it is the top layer, it tries to go the the previous layer. If these all fail, it doesn't change the current layer.
Now it will go to the next layer (that is a direct child of the same parent), then the previous layer (that is a direct child of the same parent), then the parent. If these all fail, it doesn't change the current layer.
If this logic is undesired, a simpler fix to the above bug is as follows:
+++ b/src/verbs.cpp
@@ -1461,10 +1461,10 @@ void LayerVerb::perform(SPAction *action, void *data)
survivor = Inkscape::previous_layer(dt->currentRoot(), old_layer);
}
- if (survivor == old_layer->lastChild()) {
- //oops: layer_fns messed up. BADLY.
- survivor = nullptr;
- }
+ if (survivor != nullptr && survivor->parent != old_layer->parent) {
+ // force survivor to have the same depth as the deleted layer
+ survivor = nullptr;
After writing all this, I realised that there exists raiseOne() and lowerOne(), but this comment still seems is true after all these years (okay, I don't know how long, but the link is dead afaik).
// Deleting the old layer before switching layers is a hack to trigger the
// listeners of the deletion event (as happens when old_layer is deleted using the
// xml editor). See
// http://sourceforge.net/tracker/index.php?func=detail&aid=1339397&group_id=93438&atid=604306
//