1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-08-05 23:35:50 +02:00

chat view: don't attempt to redefine a Loader's final property

We can't define a property called `status` for a Loader as it exists already. At best, the app will crash as it should be unable to create the chat view. At worst, this will introduce undefined behavior by confounding transfer/loader status assignments and comparisons.

Gitlab: #1537 (crash)
Change-Id: I66fb6da25cae695f7f1f520200f6eed8a2c93d03
This commit is contained in:
Andreas Traczyk 2024-01-22 13:30:39 -05:00 committed by Sébastien Blin
parent 4edc2d6369
commit 99d415b1fe
2 changed files with 12 additions and 12 deletions

View file

@ -40,12 +40,12 @@ Loader {
property int seq: MsgSeq.single property int seq: MsgSeq.single
property string author: Author property string author: Author
property string body: Body property string body: Body
property var status: Status property var transferStatus: Status
width: ListView.view ? ListView.view.width : 0 width: ListView.view ? ListView.view.width : 0
sourceComponent: { sourceComponent: {
if (root.status === Interaction.Status.TRANSFER_FINISHED) { if (root.transferStatus === Interaction.Status.TRANSFER_FINISHED) {
mediaInfo = MessagesAdapter.getMediaInfo(root.body) mediaInfo = MessagesAdapter.getMediaInfo(root.body)
if (Object.keys(mediaInfo).length !== 0 && WITH_WEBENGINE) if (Object.keys(mediaInfo).length !== 0 && WITH_WEBENGINE)
return localMediaMsgComp return localMediaMsgComp
@ -64,8 +64,8 @@ Loader {
id: dataTransferItem id: dataTransferItem
transferId: Id transferId: Id
property var transferStats: MessagesAdapter.getTransferStats(transferId, root.Status) property var transferStats: MessagesAdapter.getTransferStats(transferId, root.transferStatus)
property bool canOpen: root.status === Interaction.Status.TRANSFER_FINISHED || isOutgoing property bool canOpen: root.transferStatus === Interaction.Status.TRANSFER_FINISHED || isOutgoing
property real maxMsgWidth: root.width - senderMargin - property real maxMsgWidth: root.width - senderMargin -
2 * hPadding - avatarBlockWidth 2 * hPadding - avatarBlockWidth
- buttonsLoader.width - 24 - 6 - 24 - buttonsLoader.width - 24 - 6 - 24
@ -110,7 +110,7 @@ Loader {
Layout.margins: 8 Layout.margins: 8
sourceComponent: { sourceComponent: {
switch (root.status) { switch (root.transferStatus) {
case Interaction.Status.TRANSFER_CREATED: case Interaction.Status.TRANSFER_CREATED:
case Interaction.Status.TRANSFER_FINISHED: case Interaction.Status.TRANSFER_FINISHED:
iconSource = JamiResources.link_black_24dp_svg iconSource = JamiResources.link_black_24dp_svg
@ -157,7 +157,7 @@ Loader {
normalColor: JamiTheme.chatviewBgColor normalColor: JamiTheme.chatviewBgColor
imageColor: JamiTheme.chatviewButtonColor imageColor: JamiTheme.chatviewButtonColor
onClicked: { onClicked: {
if (root.status === Interaction.Status.TRANSFER_ONGOING) { if (root.transferStatus === Interaction.Status.TRANSFER_ONGOING) {
return MessagesAdapter.cancelFile(transferId) return MessagesAdapter.cancelFile(transferId)
} else { } else {
return MessagesAdapter.acceptFile(transferId) return MessagesAdapter.acceptFile(transferId)
@ -226,7 +226,7 @@ Loader {
,ProgressBar { ,ProgressBar {
id: progressBar id: progressBar
visible: root.status === Interaction.Status.TRANSFER_ONGOING visible: root.transferStatus === Interaction.Status.TRANSFER_ONGOING
height: visible * implicitHeight height: visible * implicitHeight
value: transferStats.progress / transferStats.totalSize value: transferStats.progress / transferStats.totalSize
width: transferItem.width width: transferItem.width
@ -244,7 +244,7 @@ Loader {
isOutgoing: Author === CurrentAccount.uri isOutgoing: Author === CurrentAccount.uri
transferId: Id transferId: Id
property var transferStats: MessagesAdapter.getTransferStats(transferId, root.status) property var transferStats: MessagesAdapter.getTransferStats(transferId, root.transferStatus)
showTime: root.showTime showTime: root.showTime
seq: root.seq seq: root.seq
author: Author author: Author
@ -398,7 +398,7 @@ Loader {
readonly property real aspectRatio: paintedWidth / paintedHeight readonly property real aspectRatio: paintedWidth / paintedHeight
readonly property real idealWidth: innerContent.width - senderMargin readonly property real idealWidth: innerContent.width - senderMargin
onStatusChanged: { onStatusChanged: {
if (root.status == Image.Ready && aspectRatio) { if (img.status == Image.Ready && aspectRatio) {
height = Qt.binding(() => JamiQmlUtils.clamp(idealWidth / aspectRatio, 64, 256)) height = Qt.binding(() => JamiQmlUtils.clamp(idealWidth / aspectRatio, 64, 256))
width = Qt.binding(() => height * aspectRatio) width = Qt.binding(() => height * aspectRatio)

View file

@ -31,7 +31,7 @@ import "../../../src/app/commoncomponents"
DataTransferMessageDelegate { DataTransferMessageDelegate {
id: uut id: uut
timestamp: 0 timestamp: 0
status: Interaction.Status.TRANSFER_FINISHED transferStatus: Interaction.Status.TRANSFER_FINISHED
author: "" author: ""
body: "" body: ""
@ -39,9 +39,9 @@ DataTransferMessageDelegate {
name: "Check basic visibility for header buttons" name: "Check basic visibility for header buttons"
function test_checkBasicVisibility() { function test_checkBasicVisibility() {
var buttonsLoader = findChild(uut, "buttonsLoader") var buttonsLoader = findChild(uut, "buttonsLoader")
uut.status = Interaction.Status.TRANSFER_AWAITING_HOST uut.transferStatus = Interaction.Status.TRANSFER_AWAITING_HOST
compare(buttonsLoader.iconSource, JamiResources.download_black_24dp_svg) compare(buttonsLoader.iconSource, JamiResources.download_black_24dp_svg)
uut.status = Interaction.Status.TRANSFER_FINISHED uut.transferStatus = Interaction.Status.TRANSFER_FINISHED
compare(buttonsLoader.iconSource, JamiResources.link_black_24dp_svg) compare(buttonsLoader.iconSource, JamiResources.link_black_24dp_svg)
} }
} }