The code in KoShapeReorderCommand::createCommand() works incorrectly if zIndex of one of the shapes has maximum or minimum value (it is stored in qint16). The algorithm should safely handle the case by adjusting the indexes of all the shapes when necessary
IMPORTANT: the algorithm should change zIndex of shapes as little as possible, it should happen only when necessary. If we just renumber the shapes every time, then the user will lack ability of copy-paste shapes smoothly.