From b72632e01e81ab1317f11d93b3ba25f483e1a77e Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Thu, 10 Mar 2022 12:44:59 +0100 Subject: [PATCH] tests: fix DefaultCompositor::surface() when index > 0 This amends c98bbc549557b1e0e7c972687ac2760204dff2a5. Pick-to: 6.3 Change-Id: Id0759ebab699d762c134246d0ec9f72b03923bac Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/wayland/shared/mockcompositor.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/auto/wayland/shared/mockcompositor.cpp b/tests/auto/wayland/shared/mockcompositor.cpp index d3742e0947b..c62ddfab4a3 100644 --- a/tests/auto/wayland/shared/mockcompositor.cpp +++ b/tests/auto/wayland/shared/mockcompositor.cpp @@ -81,23 +81,25 @@ DefaultCompositor::DefaultCompositor(CompositorType t) Surface *DefaultCompositor::surface(int i) { - Surface *result = nullptr; + QList surfaces; switch (m_type) { case CompositorType::Default: - result = get()->m_surfaces.value(i, nullptr); - break; + return get()->m_surfaces.value(i, nullptr); case CompositorType::Legacy: { - QList surfaces = get()->m_surfaces; - for (Surface *surface : surfaces) { + QList msurfaces = get()->m_surfaces; + for (Surface *surface : msurfaces) { if (surface->isMapped()) { - result = surface; - break; + surfaces << surface; } } } break; } - return result; + + if (i >= 0 && i < surfaces.size()) + return surfaces[i]; + + return nullptr; } uint DefaultCompositor::sendXdgShellPing()