diff --git a/src/InternalUtils.vala b/src/InternalUtils.vala index ff32204e..9177d7cb 100644 --- a/src/InternalUtils.vala +++ b/src/InternalUtils.vala @@ -143,6 +143,9 @@ namespace Gala { unowned WindowClone id; } + /** + * Careful: List windows will be modified in place and shouldn't be used afterwards. + */ #if HAS_MUTTER45 public static List calculate_grid_placement (Mtk.Rectangle area, List windows) { #else @@ -172,9 +175,8 @@ namespace Gala { } // Assign each window to the closest available slot - var tmplist = windows.copy (); - while (tmplist.length () > 0) { - unowned List link = tmplist.nth (0); + while (windows.length () > 0) { + unowned List link = windows.nth (0); var window = link.data; var rect = window.rect; @@ -207,9 +209,9 @@ namespace Gala { continue; if (taken_slots[slot_candidate] != null) - tmplist.prepend (taken_slots[slot_candidate]); + windows.prepend (taken_slots[slot_candidate]); - tmplist.remove_link (link); + windows.remove_link (link); taken_slots[slot_candidate] = window; }