From c1b59e3a547f6c52f8ae32e65387356bc5d05697 Mon Sep 17 00:00:00 2001 From: Christian Rohlfs Date: Mon, 13 Feb 2023 03:19:32 +0500 Subject: [PATCH 1/2] Fix a crash on the "layer from group" action Adds a test whether a selection is a group. --- src/actions/actions-layer.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/actions/actions-layer.cpp b/src/actions/actions-layer.cpp index 65be710139..ad955c4a02 100644 --- a/src/actions/actions-layer.cpp +++ b/src/actions/actions-layer.cpp @@ -404,16 +404,18 @@ layer_from_group (InkscapeWindow* win) show_output("layer_to_group: only one selected item allowed!"); return; } - - auto group = cast(items[0]); - if (group && group->isLayer()) { - dt->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Group already layer.")); - return; + + if (auto group = cast(items[0])) { + if (!group->isLayer()) { + group->setLayerMode(SPGroup::LAYER); + group->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT); + Inkscape::DocumentUndo::done(dt->getDocument(), _("Group to layer"), INKSCAPE_ICON("dialog-objects")); + } else { + dt->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Group already layer.")); + } + } else { + dt->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Selection is not a group.")); } - - group->setLayerMode(SPGroup::LAYER); - group->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT); - Inkscape::DocumentUndo::done(dt->getDocument(), _("Group to layer"), INKSCAPE_ICON("dialog-objects")); } // Does not change XML. -- GitLab From b1fcc39bdce6467f8b31c0c7cb0d3f98d37aa9fb Mon Sep 17 00:00:00 2001 From: Christian Rohlfs Date: Tue, 14 Feb 2023 23:53:23 +0500 Subject: [PATCH 2/2] Fix "Layer to/from group" actions status message update --- src/actions/actions-layer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/actions/actions-layer.cpp b/src/actions/actions-layer.cpp index ad955c4a02..e97e8dfdaa 100644 --- a/src/actions/actions-layer.cpp +++ b/src/actions/actions-layer.cpp @@ -390,6 +390,7 @@ layer_to_group (InkscapeWindow* win) layer->setLayerMode(SPGroup::GROUP); layer->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT); + dt->getSelection()->set(layer); Inkscape::DocumentUndo::done(dt->getDocument(), _("Layer to group"), INKSCAPE_ICON("dialog-objects")); } @@ -409,6 +410,7 @@ layer_from_group (InkscapeWindow* win) if (!group->isLayer()) { group->setLayerMode(SPGroup::LAYER); group->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT); + selection->set(group); Inkscape::DocumentUndo::done(dt->getDocument(), _("Group to layer"), INKSCAPE_ICON("dialog-objects")); } else { dt->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("Group already layer.")); -- GitLab