Skip to content

Commit

Permalink
Device List: ensure service-specific delegates are created
Browse files Browse the repository at this point in the history
Instead of only setting the Loader source from
on_LoadCustomDelegateChanged, also set it from
Component.onCompleted. Otherwise, if the value of loadCustomDelegate
never changes from its initial value, the Loader source will never be
set, and the service-specific delegate (or the 'Not connected' default
delegate) will never be set, and the item will be blank.

Fixes #1925
  • Loading branch information
blammit committed Feb 21, 2025
1 parent 4761dd7 commit afc14d0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pages/settings/devicelist/DeviceListPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@ Page {

readonly property bool _loadCustomDelegate: connected && !!device

// Only set width; height is sized to the loaded item, in case preferredVisible=false and the
// item should not be visible.
width: parent ? parent.width : 0

on_LoadCustomDelegateChanged: {
function _resetSource() {
let delegateUri
if (_loadCustomDelegate) {
const serviceType = BackendConnection.serviceTypeFromUid(device.serviceUid)
Expand All @@ -47,13 +43,20 @@ Page {
}
}

// Only set width; height is sized to the loaded item, in case preferredVisible=false and the
// item should not be visible.
width: parent ? parent.width : 0

onStatusChanged: {
if (status === Loader.Error) {
console.log("Failed to load Device List delegate for '%1' service from file: %2"
.arg(BackendConnection.serviceTypeFromUid(device.serviceUid))
.arg(source))
}
}

on_LoadCustomDelegateChanged: _resetSource()
Component.onCompleted: _resetSource()
}

footer: Column {
Expand Down

0 comments on commit afc14d0

Please sign in to comment.