diff options
author | Paul Olav Tvete <paul.tvete@theqtcompany.com> | 2016-05-26 15:52:12 +0200 |
---|---|---|
committer | Paul Olav Tvete <paul.tvete@theqtcompany.com> | 2016-05-31 08:03:22 +0000 |
commit | a90de9b657591fd75110c465a96edde4b1899ca3 (patch) | |
tree | f145b3017b857b02981cfb2dbd2c0e19a4ec383c /src | |
parent | fd9eefba8089ff9cd0bfe986dc527bbdb0630b02 (diff) |
Fix potential crash on surface destruction
Make sure we don't try use the surface object after we get the
surfaceDestroyed signal.
Change-Id: I9b266bdb7c6ba1b4d1cb738e0c1bd79ca031a4fc
Reviewed-by: Johan Helsing <johan.helsing@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/compositor/extensions/qwaylandwlshellintegration.cpp | 57 | ||||
-rw-r--r-- | src/compositor/extensions/qwaylandwlshellintegration_p.h | 4 |
2 files changed, 34 insertions, 27 deletions
diff --git a/src/compositor/extensions/qwaylandwlshellintegration.cpp b/src/compositor/extensions/qwaylandwlshellintegration.cpp index 5c0fe7c9d..a1ef5f32a 100644 --- a/src/compositor/extensions/qwaylandwlshellintegration.cpp +++ b/src/compositor/extensions/qwaylandwlshellintegration.cpp @@ -95,11 +95,38 @@ void WlShellIntegration::handleSetPopup(QWaylandInputDevice *inputDevice, QWayla m_item->setParentItem(parentItem); } - setIsPopup(true); + isPopup = true; + QWaylandQuickShellEventFilter::startFilter(m_shellSurface->surface()->client(), &closePopups); + + if (!popupShellSurfaces.contains(m_shellSurface)) { + popupShellSurfaces.append(m_shellSurface); + QObject::connect(m_shellSurface->surface(), &QWaylandSurface::mappedChanged, + this, &WlShellIntegration::handleSurfaceUnmapped); + } +} + +void WlShellIntegration::handlePopupClosed() +{ + handlePopupRemoved(); + if (m_shellSurface) + QObject::disconnect(m_shellSurface->surface(), &QWaylandSurface::mappedChanged, + this, &WlShellIntegration::handleSurfaceUnmapped); +} + +void WlShellIntegration::handlePopupRemoved() +{ + if (m_shellSurface) + popupShellSurfaces.removeOne(m_shellSurface); + if (popupShellSurfaces.isEmpty()) + QWaylandQuickShellEventFilter::cancelFilter(); + isPopup = false; } -void WlShellIntegration::handleShellSurfaceDestroyed() { - setIsPopup(false); + +void WlShellIntegration::handleShellSurfaceDestroyed() +{ + if (isPopup) + handlePopupRemoved(); m_shellSurface = nullptr; } @@ -107,7 +134,7 @@ void WlShellIntegration::handleSurfaceUnmapped() { if (!m_shellSurface || !m_shellSurface->surface()->size().isEmpty()) return; - setIsPopup(false); + handlePopupClosed(); } void WlShellIntegration::adjustOffsetForNextFrame(const QPointF &offset) @@ -168,28 +195,6 @@ void WlShellIntegration::closePopups() } } -void WlShellIntegration::setIsPopup(bool popup) -{ - isPopup = popup; - if (popup) { - QWaylandQuickShellEventFilter::startFilter(m_shellSurface->surface()->client(), &closePopups); - - if (!popupShellSurfaces.contains(m_shellSurface)) { - popupShellSurfaces.append(m_shellSurface); - QObject::connect(m_shellSurface->surface(), &QWaylandSurface::mappedChanged, - this, &WlShellIntegration::handleSurfaceUnmapped); - } - } else { - if (m_shellSurface) { - popupShellSurfaces.removeOne(m_shellSurface); - QObject::disconnect(m_shellSurface->surface(), &QWaylandSurface::mappedChanged, - this, &WlShellIntegration::handleSurfaceUnmapped); - } - if (popupShellSurfaces.isEmpty()) - QWaylandQuickShellEventFilter::cancelFilter(); - } -} - } QT_END_NAMESPACE diff --git a/src/compositor/extensions/qwaylandwlshellintegration_p.h b/src/compositor/extensions/qwaylandwlshellintegration_p.h index 07bbc63cb..3f063af39 100644 --- a/src/compositor/extensions/qwaylandwlshellintegration_p.h +++ b/src/compositor/extensions/qwaylandwlshellintegration_p.h @@ -79,7 +79,9 @@ private: Move }; - void setIsPopup(bool popup); + void handlePopupClosed(); + void handlePopupRemoved(); + static void closePopups(); QWaylandQuickShellSurfaceItem *m_item; |