Guard against _prev_range pointers in Layers dialog dangling

Fixes one half of #5454 (closed), the other half being left to #5454 (comment 2341779643).

Merge request reports

Loading