From 5fa5a63d1aca3a31761517990ff6638ef33ccda0 Mon Sep 17 00:00:00 2001 From: Joey Yakimowich-Payne Date: Fri, 6 Feb 2026 11:17:15 -0700 Subject: [PATCH] Fix perf issues zoomed in again --- gui/WarpGraphModel.cpp | 23 ++++++++++++++++++++--- gui/ZoomGraphicsView.h | 5 ++++- tests/gui/warppipe_gui_tests.cpp | 4 ++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/gui/WarpGraphModel.cpp b/gui/WarpGraphModel.cpp index 2e4d022..03d1679 100644 --- a/gui/WarpGraphModel.cpp +++ b/gui/WarpGraphModel.cpp @@ -352,12 +352,11 @@ void WarpGraphModel::refreshFromClient() { return; } - Q_EMIT beginBatchUpdate(); m_refreshing = true; + bool sceneChanged = false; auto nodesResult = m_client->ListNodes(); if (!nodesResult.ok()) { m_refreshing = false; - Q_EMIT endBatchUpdate(); return; } @@ -512,6 +511,10 @@ void WarpGraphModel::refreshFromClient() { m_volumeStates[qtId] = {}; } + if (!sceneChanged) { + sceneChanged = true; + Q_EMIT beginBatchUpdate(); + } Q_EMIT nodeCreated(qtId); } @@ -526,6 +529,10 @@ void WarpGraphModel::refreshFromClient() { if (it == m_pwToQt.end()) { continue; } + if (!sceneChanged) { + sceneChanged = true; + Q_EMIT beginBatchUpdate(); + } QtNodes::NodeId qtId = it->second; auto nodeIt = m_nodes.find(qtId); if (nodeIt == m_nodes.end()) { @@ -581,6 +588,10 @@ void WarpGraphModel::refreshFromClient() { QtNodes::ConnectionId connId{outNodeIt->second, outPortIdx, inNodeIt->second, inPortIdx}; if (m_connections.find(connId) == m_connections.end()) { + if (!sceneChanged) { + sceneChanged = true; + Q_EMIT beginBatchUpdate(); + } m_connections.insert(connId); m_linkIdToConn.emplace(link.id.value, connId); Q_EMIT connectionCreated(connId); @@ -609,6 +620,10 @@ void WarpGraphModel::refreshFromClient() { { auto connIt = m_connections.find(connId); if (connIt != m_connections.end()) { + if (!sceneChanged) { + sceneChanged = true; + Q_EMIT beginBatchUpdate(); + } m_connections.erase(connIt); Q_EMIT connectionDeleted(connId); } @@ -696,7 +711,9 @@ void WarpGraphModel::refreshFromClient() { } m_refreshing = false; - Q_EMIT endBatchUpdate(); + if (sceneChanged) { + Q_EMIT endBatchUpdate(); + } } const WarpNodeData * diff --git a/gui/ZoomGraphicsView.h b/gui/ZoomGraphicsView.h index 01f3c0b..53106df 100644 --- a/gui/ZoomGraphicsView.h +++ b/gui/ZoomGraphicsView.h @@ -9,6 +9,8 @@ #include #include +#include + #include class ZoomGraphicsView : public QtNodes::GraphicsView { @@ -39,7 +41,8 @@ public: auto cacheMode = highZoom ? QGraphicsItem::DeviceCoordinateCache : QGraphicsItem::NoCache; for (QGraphicsItem *item : scene()->items()) { - if (item->type() == QGraphicsProxyWidget::Type) + if (item->type() == QGraphicsProxyWidget::Type || + item->type() == QtNodes::ConnectionGraphicsObject::Type) item->setCacheMode(cacheMode); } } diff --git a/tests/gui/warppipe_gui_tests.cpp b/tests/gui/warppipe_gui_tests.cpp index 51b2fd2..93949c8 100644 --- a/tests/gui/warppipe_gui_tests.cpp +++ b/tests/gui/warppipe_gui_tests.cpp @@ -2371,7 +2371,7 @@ TEST_CASE("ZoomGraphicsView wheel zoom honors sensitivity and zero delta") { REQUIRE(view.transform().m11() == Catch::Approx(beforeFlat)); } -TEST_CASE("ZoomGraphicsView updateProxyCacheMode toggles proxy and leaves connection uncached") { +TEST_CASE("ZoomGraphicsView updateProxyCacheMode toggles proxy and connection cache") { auto tc = TestClient::Create(); if (!tc.available()) { SUCCEED("PipeWire unavailable"); return; } ensureApp(); @@ -2393,7 +2393,7 @@ TEST_CASE("ZoomGraphicsView updateProxyCacheMode toggles proxy and leaves connec view.setupScale(1.6); view.updateProxyCacheMode(); REQUIRE(proxy->cacheMode() == QGraphicsItem::DeviceCoordinateCache); - REQUIRE(connection->cacheMode() == QGraphicsItem::NoCache); + REQUIRE(connection->cacheMode() == QGraphicsItem::DeviceCoordinateCache); view.setupScale(1.0); view.updateProxyCacheMode();