Skip to content

Issue #11732: Fix Raise and Lower actions for Multi-Layer selections

Before this patch: gimp_image_get_selected_layers returns a GList of selected layers, in the specific order of bottom to top. Suppose we have 2 layers, Layer1 and Layer2, Layer1 is above Layer2. If we click raise, the for loop would first operate on Layer2 (bottom layer) and raise it above Layer1. Then the loop would raise Layer1, and it would again replace Layer2, thus creating a cycle. Also, if multiple layers are selected, and the top/bottom layer is selected, the Raise button is sensitive and causes an internal swap of the selected layers, which is not desirable.

After this patch: In case of Raise action, we simple reverse the GList from gimp_image_get_selected_layers, so that the for loop operates in the right direction and we do not create a cycle. Also, if any of the selected layers are top/bottom layers, the raise/lower button gets disabled, so that GIMP treats the selection as one.

During testing, if I pressed the buttons very fast, the button sensitivity would not catch up to the raise commands. So I added an else condition just to be safe, and prevent any race conditions.

Requesting maintainers to test 😀

Closes: #11732 (closed)

Merge request reports

Loading