Client xdg-shell v5: Fix crash when creating a popup without a valid parent

Fixes: QTBUG-72696
Change-Id: I43f0a02a4447238aa93142981d22597c452790fd
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
This commit is contained in:
Johan Klokkhammer Helsing 2018-12-21 15:24:49 +01:00 committed by Johan Helsing
parent 11e0fc58b6
commit 2df3b8a814
2 changed files with 12 additions and 4 deletions

View File

@ -71,6 +71,9 @@ QWaylandXdgSurfaceV5 *QWaylandXdgShellV5::createXdgSurface(QWaylandWindow *windo
QWaylandXdgPopupV5 *QWaylandXdgShellV5::createXdgPopup(QWaylandWindow *window, QWaylandInputDevice *inputDevice)
{
QWaylandWindow *parentWindow = m_popups.empty() ? window->transientParent() : m_popups.last();
if (!parentWindow)
return nullptr;
::wl_surface *parentSurface = parentWindow->object();
if (m_popupSerial == 0)

View File

@ -73,10 +73,15 @@ bool QWaylandXdgShellV5Integration::initialize(QWaylandDisplay *display)
QWaylandShellSurface *QWaylandXdgShellV5Integration::createShellSurface(QWaylandWindow *window)
{
QWaylandInputDevice *inputDevice = window->display()->lastInputDevice();
if (window->window()->type() == Qt::WindowType::Popup && inputDevice)
return m_xdgShell->createXdgPopup(window, inputDevice);
else
return m_xdgShell->createXdgSurface(window);
if (window->window()->type() == Qt::WindowType::Popup && inputDevice) {
if (auto *popup = m_xdgShell->createXdgPopup(window, inputDevice))
return popup;
qWarning(lcQpaWayland) << "Failed to create xdg-popup v5 for window" << window->window()
<< "falling back to creating an xdg-surface";
}
return m_xdgShell->createXdgSurface(window);
}
void QWaylandXdgShellV5Integration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) {