Keep PwNode objects out of the audio panel's Repeater models
The panel handed its three Repeaters snapshots of live PwNode objects, and Quickshell deletes a node the moment PipeWire drops it. Qt then dereferences that row without a null check in VDMListDelegateDataType::createMissingProperties (qqmldmlistaccessordata_p.h:222, unchanged in 6.11.2), so any teardown that emptied the graph with the panel open segfaulted the shell: a USB DAC unplugged, a Bluetooth profile switch, omarchy-restart-audio, a WirePlumber restart, or a laptop suspend. Rows now carry the node's id and name rather than the node, and each delegate resolves its own PwNode through nodeFor(), so labels, glyphs and stream volumes stay live. The name is what pins a row to the node it came from, since PipeWire reuses object ids; it is CONSTANT on PwNode for as long as the node exists. This is the projection the bluetooth panel already uses against the same crash class. Filtering the snapshot instead does not work, which is worth recording because it is the obvious thing to reach for: the node is usually alive when the snapshot is taken and dies while Qt is incubating the delegate, so nothing visible at snapshot time identifies the row that will dangle. Co-Authored-By: Codex XHigh <codex@openai.com>
This commit is contained in:
1 parent
2c593dbbaa
commit
c9faea7c55
3 files changed
+74
-24
No files matched your search
@@ -18,8 +18,31 @@ function isAudioSource(node) {
|
||||
|| mediaClass.indexOf("Source") !== -1
|
||||
}
|
||||
|
||||
function listSnapshot(list) {
|
||||
return list && list.slice ? list.slice() : []
|
||||
// Project a node list to the primitive rows a Repeater model can hold. A row
|
||||
// holding the PwNode itself is a QObject that Qt dereferences without a null
|
||||
// check while it builds the delegate, and PipeWire deletes nodes outright, so a
|
||||
// graph teardown segfaults the shell. Primitives cannot dangle, which is what
|
||||
// closes that race -- not the check below, since the node usually dies after the
|
||||
// snapshot is taken. That is also why filtering the list here never worked.
|
||||
//
|
||||
// The name rides along because PipeWire reuses object ids: without it a row
|
||||
// could resolve to whatever inherited its id. PwNode.name is CONSTANT, so it
|
||||
// identifies the node it was taken from for as long as that node lives.
|
||||
function nodeRow(node) {
|
||||
if (!node) return null
|
||||
var id = node.id
|
||||
if (id === undefined || id === null) return null
|
||||
return { id: id, name: String(node.name || "") }
|
||||
}
|
||||
|
||||
function rowSnapshot(list) {
|
||||
var values = list && list.length ? list : []
|
||||
var rows = []
|
||||
for (var i = 0; i < values.length; i++) {
|
||||
var row = nodeRow(values[i])
|
||||
if (row) rows.push(row)
|
||||
}
|
||||
return rows
|
||||
}
|
||||
|
||||
function outputVolumeName(volume, muted) {
|
||||
@@ -237,7 +260,8 @@ if (typeof module !== "undefined") {
|
||||
module.exports = {
|
||||
isPlaybackStream: isPlaybackStream,
|
||||
isAudioSource: isAudioSource,
|
||||
listSnapshot: listSnapshot,
|
||||
nodeRow: nodeRow,
|
||||
rowSnapshot: rowSnapshot,
|
||||
outputVolumeName: outputVolumeName,
|
||||
parseSinkAvailability: parseSinkAvailability,
|
||||
friendlyDeviceLabel: friendlyDeviceLabel,
|
||||
|
||||
Reference in new issue
Block a user