Crash on failed assertion when moving an object to the layer it's currently in

Summary:

An assertion fails on debug builds of 1.2-alpha when attempting to move an object to its current layer (which should be a no-op).

Steps to reproduce:

  • open Inkscape
  • draw a rectangle and right-click on it
  • in the context menu, choose Move to Layer...
  • press Move in the dialog that shows up.

What happened?

The debug build crashes on the following failed assertion:

inkscape: src/selection-chemistry.cpp:337: std::vector<Inkscape::XML::Node*> sp_selection_paste_impl(SPDocument*, SPObject*, std::vector<Inkscape::XML::Node*>&, Inkscape::XML::Node*): Assertion `!after || after->parent() == parent->getRepr()' failed.

Backtrace: move-to-self.txt

What should have happened?

No crash and no effects (the object is already in the layer we're trying to move it to).

Version info

Inkscape 1.2-alpha (21fccfbd1c, 2022-02-12)

    GLib version:     2.70.3
    GTK version:      3.24.31
    glibmm version:   2.66.2
    gtkmm version:    3.24.5
    libxml2 version:  2.9.12
    libxslt version:  1.1.34
    Cairo version:    1.17.4
    Pango version:    1.50.3
    HarfBuzz version: 3.3.1

    OS version:       Arch Linux

Note: inkscape#3032 (closed) is a similar issue but involving a segfault.