BUG:365400 Don't crash when merging layers gives an inconsistent result
This way the user can at least still save their image. I can easily reproduce the warning messages Raghukamath pasted into the bug report, though.