xdg-shell v5,v6 shell integrations: Fix crash when showing popups
If a popup was shown without any input events happening first, it would cause nullptr dereferences in both xdg-shell v5 and v6. Fixes crashes in: - tst_QAccessibility::comboBoxTest - tst_QAccessibility::menuTest - tst_QWindow::touchInterruptedByPopup - tst_QFocusEvent::checkReason_Popup Task-number: QTBUG-67150 Change-Id: Ib3e06326f71e4ab5f74727cb4f79626a21c34d55 Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
parent
bfb8f07065
commit
2804d35cb4
@ -73,12 +73,11 @@ QWaylandXdgSurface *QWaylandXdgShell::createXdgSurface(QWaylandWindow *window)
|
|||||||
return new QWaylandXdgSurface(this, window);
|
return new QWaylandXdgSurface(this, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWaylandXdgPopup *QWaylandXdgShell::createXdgPopup(QWaylandWindow *window)
|
QWaylandXdgPopup *QWaylandXdgShell::createXdgPopup(QWaylandWindow *window, QWaylandInputDevice *inputDevice)
|
||||||
{
|
{
|
||||||
QWaylandWindow *parentWindow = m_popups.empty() ? window->transientParent() : m_popups.last();
|
QWaylandWindow *parentWindow = m_popups.empty() ? window->transientParent() : m_popups.last();
|
||||||
::wl_surface *parentSurface = parentWindow->object();
|
::wl_surface *parentSurface = parentWindow->object();
|
||||||
|
|
||||||
QWaylandInputDevice *inputDevice = window->display()->lastInputDevice();
|
|
||||||
if (m_popupSerial == 0)
|
if (m_popupSerial == 0)
|
||||||
m_popupSerial = inputDevice->serial();
|
m_popupSerial = inputDevice->serial();
|
||||||
::wl_seat *seat = inputDevice->wl_seat();
|
::wl_seat *seat = inputDevice->wl_seat();
|
||||||
|
@ -79,7 +79,7 @@ public:
|
|||||||
~QWaylandXdgShell() override;
|
~QWaylandXdgShell() override;
|
||||||
|
|
||||||
QWaylandXdgSurface *createXdgSurface(QWaylandWindow *window);
|
QWaylandXdgSurface *createXdgSurface(QWaylandWindow *window);
|
||||||
QWaylandXdgPopup *createXdgPopup(QWaylandWindow *window);
|
QWaylandXdgPopup *createXdgPopup(QWaylandWindow *window, QWaylandInputDevice *inputDevice);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void xdg_shell_ping(uint32_t serial) override;
|
void xdg_shell_ping(uint32_t serial) override;
|
||||||
|
@ -74,8 +74,9 @@ bool QWaylandXdgShellIntegration::initialize(QWaylandDisplay *display)
|
|||||||
|
|
||||||
QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWindow *window)
|
QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWindow *window)
|
||||||
{
|
{
|
||||||
if (window->window()->type() == Qt::WindowType::Popup)
|
QWaylandInputDevice *inputDevice = window->display()->lastInputDevice();
|
||||||
return m_xdgShell->createXdgPopup(window);
|
if (window->window()->type() == Qt::WindowType::Popup && inputDevice)
|
||||||
|
return m_xdgShell->createXdgPopup(window, inputDevice);
|
||||||
else
|
else
|
||||||
return m_xdgShell->createXdgSurface(window);
|
return m_xdgShell->createXdgSurface(window);
|
||||||
}
|
}
|
||||||
|
@ -165,8 +165,9 @@ void QWaylandXdgSurfaceV6::setAppId(const QString &appId)
|
|||||||
|
|
||||||
void QWaylandXdgSurfaceV6::setType(Qt::WindowType type, QWaylandWindow *transientParent)
|
void QWaylandXdgSurfaceV6::setType(Qt::WindowType type, QWaylandWindow *transientParent)
|
||||||
{
|
{
|
||||||
if ((type == Qt::Popup || type == Qt::ToolTip) && transientParent) {
|
QWaylandDisplay *display = m_window->display();
|
||||||
setPopup(transientParent, m_window->display()->lastInputDevice(), m_window->display()->lastInputSerial(), type == Qt::Popup);
|
if ((type == Qt::Popup || type == Qt::ToolTip) && transientParent && display->lastInputDevice()) {
|
||||||
|
setPopup(transientParent, display->lastInputDevice(), display->lastInputSerial(), type == Qt::Popup);
|
||||||
} else {
|
} else {
|
||||||
setToplevel();
|
setToplevel();
|
||||||
if (transientParent) {
|
if (transientParent) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user