From eaaa8b6242cc2926193932dd47843dee2c19ec65 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Thu, 10 Mar 2022 12:44:59 +0100 Subject: tests: fix DefaultCompositor::surface() when index > 0 This amends 0154d0b65b139c4919a020c29846f56697b5b42c. Pick-to: 6.3 Change-Id: Id0759ebab699d762c134246d0ec9f72b03923bac Reviewed-by: Eskil Abrahamsen Blomfeldt --- tests/auto/client/shared/mockcompositor.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'tests/auto/client/shared') diff --git a/tests/auto/client/shared/mockcompositor.cpp b/tests/auto/client/shared/mockcompositor.cpp index d3742e094..c62ddfab4 100644 --- a/tests/auto/client/shared/mockcompositor.cpp +++ b/tests/auto/client/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() -- cgit v1.2.3