diff --git a/src/avatarimageprovider.h b/src/avatarimageprovider.h index 3351684ad021d092b775fd0ef7075c265661942a..9340c952c83c1e3b0905ea58beca159caefb1ddd 100644 --- a/src/avatarimageprovider.h +++ b/src/avatarimageprovider.h @@ -38,6 +38,11 @@ public: { Q_UNUSED(size) + if (requestedSize == QSize(0, 0)) { + qWarning() << Q_FUNC_INFO << "Image request has no dimensions"; + return {}; + } + // the first string is the item uri and the second is a uid // that is used for trigger a reload of the underlying image // data and can be discarded at this point diff --git a/src/mainview/components/ParticipantOverlay.qml b/src/mainview/components/ParticipantOverlay.qml index c7ebb70b78ae2a7422ee76bebb23583dee1be99d..169b7958d2ee24b1c332ddbd5ee370ce84a85ade 100644 --- a/src/mainview/components/ParticipantOverlay.qml +++ b/src/mainview/components/ParticipantOverlay.qml @@ -54,16 +54,11 @@ Item { function setAvatar(show, uri, isLocal) { if (!show) - avatar.visible = false + avatar.active = false else { - if (isLocal) { - avatar.mode = Avatar.Mode.Account - avatar.imageId = LRCInstance.currentAccountId - } else { - avatar.mode = Avatar.Mode.Contact - avatar.imageId = uri - } - avatar.visible = true + avatar.mode_ = isLocal ? Avatar.Mode.Account : Avatar.Mode.Contact + avatar.imageId_ = isLocal ? LRCInstance.currentAccountId : uri + avatar.active = true } } @@ -167,22 +162,31 @@ Item { } } - Avatar { + Loader { id: avatar anchors.centerIn: parent - property real size: Math.min(parent.width / 2, parent.height / 2) - height: size - width: size + active: false + + property real size_: Math.min(parent.width / 2, parent.height / 2) + height: size_ + width: size_ - // round the avatar source size up to some nearest multiple - readonly property real step: 96 - property real imageSize: Math.floor((size + step - 1) / step) * step - sourceSize: Qt.size(imageSize, imageSize) + property int mode_ + property string imageId_ - visible: false - showPresenceIndicator: false + sourceComponent: Component { + Avatar { + // round the avatar source size up to some nearest multiple + readonly property real step: 96 + property real size: Math.floor((size_ + step - 1) / step) * step + sourceSize: Qt.size(size, size) + mode: mode_ + imageId: size_ ? imageId_ : "" + showPresenceIndicator: false + } + } } // Participant background and buttons for moderation