diff --git a/gui/BezierConnectionPainter.cpp b/gui/BezierConnectionPainter.cpp index 93e3414..423d48e 100644 --- a/gui/BezierConnectionPainter.cpp +++ b/gui/BezierConnectionPainter.cpp @@ -43,8 +43,9 @@ void BezierConnectionPainter::paint( auto *model = dynamic_cast(&scene->graphModel()); if (model) { auto cId = cgo.connectionId(); - peakLevel = std::max(model->nodePeakLevel(cId.outNodeId), - model->nodePeakLevel(cId.inNodeId)); + if (model->connectionExists(cId)) { + peakLevel = model->nodePeakLevel(cId.outNodeId); + } } } diff --git a/gui/SquareConnectionPainter.cpp b/gui/SquareConnectionPainter.cpp index 5139e3e..8d449a8 100644 --- a/gui/SquareConnectionPainter.cpp +++ b/gui/SquareConnectionPainter.cpp @@ -66,16 +66,17 @@ QPainterPath SquareConnectionPainter::orthogonalPath( constexpr double kNodePad = 15.0; auto const cId = cgo.connectionId(); + auto *sceneForChannel = cgo.nodeScene(); + auto *mdl = sceneForChannel + ? dynamic_cast(&sceneForChannel->graphModel()) + : nullptr; + bool connectionAlive = mdl ? mdl->connectionExists(cId) : true; double spread = static_cast(cId.outPortIndex) * kSpacing; - auto *sceneForChannel = cgo.nodeScene(); - if (sceneForChannel) { - auto *mdl = dynamic_cast(&sceneForChannel->graphModel()); - if (mdl) { - auto ch = mdl->connectionChannel(cId); - spread = (static_cast(ch.index) - (ch.count - 1) / 2.0) - * kSpacing; - } + if (mdl && connectionAlive) { + auto ch = mdl->connectionChannel(cId); + spread = (static_cast(ch.index) - (ch.count - 1) / 2.0) + * kSpacing; } double const dy = in.y() - out.y(); @@ -125,12 +126,9 @@ QPainterPath SquareConnectionPainter::orthogonalPath( // double railOffset = 0.0; - if (sceneForChannel) { - auto *mdl2 = dynamic_cast(&sceneForChannel->graphModel()); - if (mdl2) { - auto ch = mdl2->connectionChannel(cId); - railOffset = static_cast(ch.index) * kSpacing; - } + if (mdl && connectionAlive) { + auto ch = mdl->connectionChannel(cId); + railOffset = static_cast(ch.index) * kSpacing; } double rightX = out.x() + kMinStub + railOffset; @@ -205,8 +203,9 @@ void SquareConnectionPainter::paint( auto *model = dynamic_cast(&scene->graphModel()); if (model) { auto cId = cgo.connectionId(); - peakLevel = std::max(model->nodePeakLevel(cId.outNodeId), - model->nodePeakLevel(cId.inNodeId)); + if (model->connectionExists(cId)) { + peakLevel = model->nodePeakLevel(cId.outNodeId); + } } } diff --git a/gui/WarpGraphModel.cpp b/gui/WarpGraphModel.cpp index addf025..101e97e 100644 --- a/gui/WarpGraphModel.cpp +++ b/gui/WarpGraphModel.cpp @@ -343,6 +343,8 @@ bool WarpGraphModel::deleteConnection( } m_connections.erase(it); + m_connectionChannels.erase(connectionId); + recomputeConnectionChannels(); Q_EMIT connectionDeleted(connectionId); return true; } @@ -374,6 +376,7 @@ bool WarpGraphModel::deleteNode(QtNodes::NodeId const nodeId) { m_positions.erase(nodeId); m_sizes.erase(nodeId); m_volumeStates.erase(nodeId); + m_peakLevels.erase(nodeId); m_styleCache.erase(nodeId); m_volumeWidgets.erase(nodeId); Q_EMIT nodeDeleted(nodeId); diff --git a/src/warppipe.cpp b/src/warppipe.cpp index ac92d3e..b8d6806 100644 --- a/src/warppipe.cpp +++ b/src/warppipe.cpp @@ -329,10 +329,12 @@ void NodeMeterProcess(void* data) { had_data = true; pw_stream_queue_buffer(meter->stream, buf); } - if (had_data) { - meter->peak_left.store(left, std::memory_order_relaxed); - meter->peak_right.store(right, std::memory_order_relaxed); + if (!had_data) { + left = 0.0f; + right = 0.0f; } + meter->peak_left.store(left, std::memory_order_relaxed); + meter->peak_right.store(right, std::memory_order_relaxed); } static const pw_stream_events kNodeMeterEvents = {