Fix perf issues zoomed in again

This commit is contained in:
Joey Yakimowich-Payne 2026-02-06 11:17:15 -07:00
commit 5fa5a63d1a
3 changed files with 26 additions and 6 deletions

View file

@ -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,8 +711,10 @@ void WarpGraphModel::refreshFromClient() {
}
m_refreshing = false;
if (sceneChanged) {
Q_EMIT endBatchUpdate();
}
}
const WarpNodeData *
WarpGraphModel::warpNodeData(QtNodes::NodeId nodeId) const {

View file

@ -9,6 +9,8 @@
#include <QScrollBar>
#include <QWheelEvent>
#include <QtNodes/internal/ConnectionGraphicsObject.hpp>
#include <cmath>
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);
}
}

View file

@ -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();