qtbug-62044.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. From fd9fec4fc7f43fb939e8e5a946c7858390bbd9d3 Mon Sep 17 00:00:00 2001
  2. From: Johan Klokkhammer Helsing <johan.helsing@qt.io>
  3. Date: Thu, 8 Feb 2018 16:53:39 +0100
  4. Subject: [PATCH] Fix crash when connecting a new screen
  5. In QWaylandWindow::virtualSiblings, don't include screens that have not been
  6. added yet. I.e. QWaylandScreens for which QPlatformIntegration::screenAdded has
  7. not yet been called.
  8. There are two reasons why this crash wasn't covered by the
  9. removePrimaryScreen() test. First of all, the mock output didn't send
  10. wl_output.done events when updating the mode/geometry. These wayland events are
  11. what causes QWindowSystemInterface::handleScreenGeometryChange() to be called
  12. (where virtualSiblings are called).
  13. Furthermore, virtualSiblings is only called when the geometry actually changes,
  14. so add a new test that changes the screen geometry of the existing screen while
  15. a new one is being added (i.e. moves it to the right).
  16. Task-number: QTBUG-62044
  17. Change-Id: I623fbf8799d21c6b9293e7120ded301277639cc6
  18. Reviewed-by: David Edmundson <davidedmundson@kde.org>
  19. Reviewed-by: Aleix Pol
  20. Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
  21. ---
  22. src/client/qwaylandscreen.cpp | 6 ++++--
  23. tests/auto/client/client/tst_client.cpp | 25 +++++++++++++++++++++++++
  24. tests/auto/client/shared/mockcompositor.cpp | 8 ++++++++
  25. tests/auto/client/shared/mockcompositor.h | 2 ++
  26. tests/auto/client/shared/mockoutput.cpp | 27 +++++++++++++++++++++++++--
  27. tests/auto/client/shared/mockoutput.h | 1 +
  28. 6 files changed, 65 insertions(+), 4 deletions(-)
  29. diff --git a/src/client/qwaylandscreen.cpp b/src/client/qwaylandscreen.cpp
  30. index fba75557..1c9ce23b 100644
  31. --- a/src/client/qwaylandscreen.cpp
  32. +++ b/src/client/qwaylandscreen.cpp
  33. @@ -138,8 +138,10 @@ QList<QPlatformScreen *> QWaylandScreen::virtualSiblings() const
  34. QList<QPlatformScreen *> list;
  35. const QList<QWaylandScreen*> screens = mWaylandDisplay->screens();
  36. list.reserve(screens.count());
  37. - foreach (QWaylandScreen *screen, screens)
  38. - list << screen;
  39. + for (QWaylandScreen *screen : qAsConst(screens)) {
  40. + if (screen->screen())
  41. + list << screen;
  42. + }
  43. return list;
  44. }