qtbug-67150.patch 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. From 26a6372bb0c6528358e34f8175a14ff0be47fb12 Mon Sep 17 00:00:00 2001
  2. From: Johan Klokkhammer Helsing <johan.helsing@qt.io>
  3. Date: Mon, 19 Mar 2018 10:21:47 +0100
  4. Subject: xdg-shell v5,v6 shell integrations: Fix crash when showing popups
  5. If a popup was shown without any input events happening first, it would cause
  6. nullptr dereferences in both xdg-shell v5 and v6.
  7. Fixes crashes in:
  8. - tst_QAccessibility::comboBoxTest
  9. - tst_QAccessibility::menuTest
  10. - tst_QWindow::touchInterruptedByPopup
  11. - tst_QFocusEvent::checkReason_Popup
  12. Task-number: QTBUG-67150
  13. Change-Id: Ib3e06326f71e4ab5f74727cb4f79626a21c34d55
  14. Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
  15. ---
  16. src/client/qwaylandxdgshell.cpp | 3 +--
  17. src/client/qwaylandxdgshell_p.h | 2 +-
  18. src/client/qwaylandxdgshellintegration.cpp | 5 +++--
  19. src/client/qwaylandxdgshellv6.cpp | 5 +++--
  20. 4 files changed, 8 insertions(+), 7 deletions(-)
  21. diff --git a/src/client/qwaylandxdgshell.cpp b/src/client/qwaylandxdgshell.cpp
  22. index 8b252b95..9a34e72d 100644
  23. --- a/src/client/qwaylandxdgshell.cpp
  24. +++ b/src/client/qwaylandxdgshell.cpp
  25. @@ -73,12 +73,11 @@ QWaylandXdgSurface *QWaylandXdgShell::createXdgSurface(QWaylandWindow *window)
  26. return new QWaylandXdgSurface(this, window);
  27. }
  28. -QWaylandXdgPopup *QWaylandXdgShell::createXdgPopup(QWaylandWindow *window)
  29. +QWaylandXdgPopup *QWaylandXdgShell::createXdgPopup(QWaylandWindow *window, QWaylandInputDevice *inputDevice)
  30. {
  31. QWaylandWindow *parentWindow = m_popups.empty() ? window->transientParent() : m_popups.last();
  32. ::wl_surface *parentSurface = parentWindow->object();
  33. - QWaylandInputDevice *inputDevice = window->display()->lastInputDevice();
  34. if (m_popupSerial == 0)
  35. m_popupSerial = inputDevice->serial();
  36. ::wl_seat *seat = inputDevice->wl_seat();
  37. diff --git a/src/client/qwaylandxdgshell_p.h b/src/client/qwaylandxdgshell_p.h
  38. index afbd9c59..761f2521 100644
  39. --- a/src/client/qwaylandxdgshell_p.h
  40. +++ b/src/client/qwaylandxdgshell_p.h
  41. @@ -79,7 +79,7 @@ public:
  42. ~QWaylandXdgShell() override;
  43. QWaylandXdgSurface *createXdgSurface(QWaylandWindow *window);
  44. - QWaylandXdgPopup *createXdgPopup(QWaylandWindow *window);
  45. + QWaylandXdgPopup *createXdgPopup(QWaylandWindow *window, QWaylandInputDevice *inputDevice);
  46. private:
  47. void xdg_shell_ping(uint32_t serial) override;
  48. diff --git a/src/client/qwaylandxdgshellintegration.cpp b/src/client/qwaylandxdgshellintegration.cpp
  49. index 5fa4385d..ee72c2d5 100644
  50. --- a/src/client/qwaylandxdgshellintegration.cpp
  51. +++ b/src/client/qwaylandxdgshellintegration.cpp
  52. @@ -74,8 +74,9 @@ bool QWaylandXdgShellIntegration::initialize(QWaylandDisplay *display)
  53. QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWindow *window)
  54. {
  55. - if (window->window()->type() == Qt::WindowType::Popup)
  56. - return m_xdgShell->createXdgPopup(window);
  57. + QWaylandInputDevice *inputDevice = window->display()->lastInputDevice();
  58. + if (window->window()->type() == Qt::WindowType::Popup && inputDevice)
  59. + return m_xdgShell->createXdgPopup(window, inputDevice);
  60. else
  61. return m_xdgShell->createXdgSurface(window);
  62. }
  63. diff --git a/src/client/qwaylandxdgshellv6.cpp b/src/client/qwaylandxdgshellv6.cpp
  64. index c89c8316..a166a3bc 100644
  65. --- a/src/client/qwaylandxdgshellv6.cpp
  66. +++ b/src/client/qwaylandxdgshellv6.cpp
  67. @@ -165,8 +165,9 @@ void QWaylandXdgSurfaceV6::setAppId(const QString &appId)
  68. void QWaylandXdgSurfaceV6::setType(Qt::WindowType type, QWaylandWindow *transientParent)
  69. {
  70. - if ((type == Qt::Popup || type == Qt::ToolTip) && transientParent) {
  71. - setPopup(transientParent, m_window->display()->lastInputDevice(), m_window->display()->lastInputSerial(), type == Qt::Popup);
  72. + QWaylandDisplay *display = m_window->display();
  73. + if ((type == Qt::Popup || type == Qt::ToolTip) && transientParent && display->lastInputDevice()) {
  74. + setPopup(transientParent, display->lastInputDevice(), display->lastInputSerial(), type == Qt::Popup);
  75. } else {
  76. setToplevel();
  77. if (transientParent) {
  78. --
  79. cgit v1.2.1