summaryrefslogtreecommitdiff
path: root/src/protocols/Screencopy.cpp
diff options
context:
space:
mode:
authorIkalco <73481042+ikalco@users.noreply.github.com>2024-10-07 19:23:48 -0500
committerGitHub <noreply@github.com>2024-10-08 01:23:48 +0100
commit0d70c442538ba0d1efc63558c859c184367c95ad (patch)
tree40d2716125df08246cd6fc4283d19680868bfc17 /src/protocols/Screencopy.cpp
parenta364df4c9e9a73f0460665463028539e3abe4a8b (diff)
screencopy: fix screencopy frames not being cleaned up (#8017)
--------- Co-authored-by: Vaxry <vaxry@vaxry.net>
Diffstat (limited to 'src/protocols/Screencopy.cpp')
-rw-r--r--src/protocols/Screencopy.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/protocols/Screencopy.cpp b/src/protocols/Screencopy.cpp
index 63024541..1b06a1fa 100644
--- a/src/protocols/Screencopy.cpp
+++ b/src/protocols/Screencopy.cpp
@@ -394,12 +394,12 @@ void CScreencopyProtocol::bindManager(wl_client* client, void* data, uint32_t ve
void CScreencopyProtocol::destroyResource(CScreencopyClient* client) {
std::erase_if(m_vClients, [&](const auto& other) { return other.get() == client; });
std::erase_if(m_vFrames, [&](const auto& other) { return other->client.get() == client; });
- std::erase_if(m_vFramesAwaitingWrite, [&](const auto& other) { return other->client.get() == client; });
+ std::erase_if(m_vFramesAwaitingWrite, [&](const auto& other) { return !other || other->client.get() == client; });
}
void CScreencopyProtocol::destroyResource(CScreencopyFrame* frame) {
std::erase_if(m_vFrames, [&](const auto& other) { return other.get() == frame; });
- std::erase_if(m_vFramesAwaitingWrite, [&](const auto& other) { return other.get() == frame; });
+ std::erase_if(m_vFramesAwaitingWrite, [&](const auto& other) { return !other || other.get() == frame; });
}
void CScreencopyProtocol::onOutputCommit(CMonitor* pMonitor) {
@@ -412,8 +412,11 @@ void CScreencopyProtocol::onOutputCommit(CMonitor* pMonitor) {
// share frame if correct output
for (auto const& f : m_vFramesAwaitingWrite) {
+ if (!f)
+ continue;
+
if (!f->pMonitor || !f->buffer) {
- framesToRemove.push_back(f);
+ framesToRemove.emplace_back(f);
continue;
}
@@ -425,10 +428,10 @@ void CScreencopyProtocol::onOutputCommit(CMonitor* pMonitor) {
f->client->lastFrame.reset();
++f->client->frameCounter;
- framesToRemove.push_back(f);
+ framesToRemove.emplace_back(f);
}
for (auto const& f : framesToRemove) {
- destroyResource(f.get());
+ std::erase(m_vFramesAwaitingWrite, f);
}
}