From 88b2e6c9728d01a9aa334026629fbb1ce85fe197 Mon Sep 17 00:00:00 2001 From: Zhang Liang Date: Mon, 1 Feb 2021 19:29:43 +0800 Subject: [PATCH 14/40] Fix: remove listener Add the operation for removing the listener form listener list Change-Id: Ief2ff1303b607eee499543303fe80e51f8f10cc5 Reviewed-by: David Edmundson (cherry picked from commit 16760280fd04cf70255bab16d9acecad254fdd8f) --- src/client/qwaylanddisplay.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client/qwaylanddisplay.cpp b/src/client/qwaylanddisplay.cpp index f10c1f79..e0dfe8b2 100644 --- a/src/client/qwaylanddisplay.cpp +++ b/src/client/qwaylanddisplay.cpp @@ -452,9 +452,10 @@ void QWaylandDisplay::addRegistryListener(RegistryListener listener, void *data) void QWaylandDisplay::removeListener(RegistryListener listener, void *data) { - std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){ + auto iter = std::remove_if(mRegistryListeners.begin(), mRegistryListeners.end(), [=](Listener l){ return (l.listener == listener && l.data == data); }); + mRegistryListeners.erase(iter, mRegistryListeners.end()); } uint32_t QWaylandDisplay::currentTimeMillisec() -- 2.35.1