From befe57530ad5b74f503d143fdfa4052db703e6c6 Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Fri, 30 Jan 2026 08:10:51 -0700 Subject: [PATCH] C++ 20 --- CMakeLists.txt | 2 +- gui/WarpGraphModel.cpp | 50 ++++++++++++------------------------------ src/warppipe.cpp | 10 ++++----- 3 files changed, 20 insertions(+), 42 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb7f35d..23580ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ target_include_directories(warppipe $ ) -target_compile_features(warppipe PUBLIC cxx_std_17) +target_compile_features(warppipe PUBLIC cxx_std_20) target_link_libraries(warppipe PUBLIC PkgConfig::PIPEWIRE PRIVATE nlohmann_json::nlohmann_json) if(WARPPIPE_BUILD_EXAMPLES) diff --git a/gui/WarpGraphModel.cpp b/gui/WarpGraphModel.cpp index fa447d2..0b8d5e1 100644 --- a/gui/WarpGraphModel.cpp +++ b/gui/WarpGraphModel.cpp @@ -361,23 +361,13 @@ void WarpGraphModel::refreshFromClient() { } if (m_ghostNodes.erase(qtId)) { - std::vector gcToRemove; - for (auto gcIt = m_ghostConnections.begin(); - gcIt != m_ghostConnections.end();) { - if (gcIt->outNodeId == qtId || gcIt->inNodeId == qtId) { - gcToRemove.push_back(*gcIt); - gcIt = m_ghostConnections.erase(gcIt); - } else { - ++gcIt; - } - } - for (const auto &gc : gcToRemove) { - auto cIt = m_connections.find(gc); - if (cIt != m_connections.end()) { - m_connections.erase(cIt); - Q_EMIT connectionDeleted(gc); - } - } + std::erase_if(m_ghostConnections, [&](const auto &gc) { + if (gc.outNodeId != qtId && gc.inNodeId != qtId) + return false; + m_connections.erase(gc); + Q_EMIT connectionDeleted(gc); + return true; + }); Q_EMIT nodeUpdated(qtId); } continue; @@ -396,25 +386,13 @@ void WarpGraphModel::refreshFromClient() { if (ghostMatch != 0) { m_ghostNodes.erase(ghostMatch); - { - std::vector gcToRemove; - for (auto gcIt = m_ghostConnections.begin(); - gcIt != m_ghostConnections.end();) { - if (gcIt->outNodeId == ghostMatch || gcIt->inNodeId == ghostMatch) { - gcToRemove.push_back(*gcIt); - gcIt = m_ghostConnections.erase(gcIt); - } else { - ++gcIt; - } - } - for (const auto &gc : gcToRemove) { - auto cIt = m_connections.find(gc); - if (cIt != m_connections.end()) { - m_connections.erase(cIt); - Q_EMIT connectionDeleted(gc); - } - } - } + std::erase_if(m_ghostConnections, [&](const auto &gc) { + if (gc.outNodeId != ghostMatch && gc.inNodeId != ghostMatch) + return false; + m_connections.erase(gc); + Q_EMIT connectionDeleted(gc); + return true; + }); m_pwToQt.emplace(nodeInfo.id.value, ghostMatch); auto &data = m_nodes[ghostMatch]; data.info = nodeInfo; diff --git a/src/warppipe.cpp b/src/warppipe.cpp index 6c10935..83391a6 100644 --- a/src/warppipe.cpp +++ b/src/warppipe.cpp @@ -158,7 +158,7 @@ void LinkProxyError(void* data, int, int res, const char* message) { } static const pw_proxy_events kLinkProxyEvents = { - PW_VERSION_PROXY_EVENTS, + .version = PW_VERSION_PROXY_EVENTS, .bound = LinkProxyBound, .removed = LinkProxyRemoved, .error = LinkProxyError, @@ -234,7 +234,7 @@ void StreamStateChanged(void* data, } static const pw_stream_events kStreamEvents = { - PW_VERSION_STREAM_EVENTS, + .version = PW_VERSION_STREAM_EVENTS, .state_changed = StreamStateChanged, .process = StreamProcess, }; @@ -390,7 +390,7 @@ void Client::Impl::RegistryGlobal(void* data, PW_VERSION_METADATA, 0)); if (impl->metadata_proxy) { static const pw_metadata_events metadata_events = { - PW_VERSION_METADATA_EVENTS, + .version = PW_VERSION_METADATA_EVENTS, .property = MetadataProperty, }; pw_metadata_add_listener( @@ -700,7 +700,7 @@ Status Client::Impl::ConnectLocked() { } static const pw_core_events core_events = { - PW_VERSION_CORE_EVENTS, + .version = PW_VERSION_CORE_EVENTS, .done = CoreDone, .error = CoreError, }; @@ -713,7 +713,7 @@ Status Client::Impl::ConnectLocked() { } static const pw_registry_events registry_events = { - PW_VERSION_REGISTRY_EVENTS, + .version = PW_VERSION_REGISTRY_EVENTS, .global = RegistryGlobal, .global_remove = RegistryGlobalRemove, };