Skip to content
Snippets Groups Projects
Commit 99d415b1 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Sébastien Blin
Browse files

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
parent 4edc2d63
No related branches found
Tags beta/202402071743
No related merge requests found
......@@ -40,12 +40,12 @@ Loader {
property int seq: MsgSeq.single
property string author: Author
property string body: Body
property var status: Status
property var transferStatus: Status
width: ListView.view ? ListView.view.width : 0
sourceComponent: {
if (root.status === Interaction.Status.TRANSFER_FINISHED) {
if (root.transferStatus === Interaction.Status.TRANSFER_FINISHED) {
mediaInfo = MessagesAdapter.getMediaInfo(root.body)
if (Object.keys(mediaInfo).length !== 0 && WITH_WEBENGINE)
return localMediaMsgComp
......@@ -64,8 +64,8 @@ Loader {
id: dataTransferItem
transferId: Id
property var transferStats: MessagesAdapter.getTransferStats(transferId, root.Status)
property bool canOpen: root.status === Interaction.Status.TRANSFER_FINISHED || isOutgoing
property var transferStats: MessagesAdapter.getTransferStats(transferId, root.transferStatus)
property bool canOpen: root.transferStatus === Interaction.Status.TRANSFER_FINISHED || isOutgoing
property real maxMsgWidth: root.width - senderMargin -
2 * hPadding - avatarBlockWidth
- buttonsLoader.width - 24 - 6 - 24
......@@ -110,7 +110,7 @@ Loader {
Layout.margins: 8
sourceComponent: {
switch (root.status) {
switch (root.transferStatus) {
case Interaction.Status.TRANSFER_CREATED:
case Interaction.Status.TRANSFER_FINISHED:
iconSource = JamiResources.link_black_24dp_svg
......@@ -157,7 +157,7 @@ Loader {
normalColor: JamiTheme.chatviewBgColor
imageColor: JamiTheme.chatviewButtonColor
onClicked: {
if (root.status === Interaction.Status.TRANSFER_ONGOING) {
if (root.transferStatus === Interaction.Status.TRANSFER_ONGOING) {
return MessagesAdapter.cancelFile(transferId)
} else {
return MessagesAdapter.acceptFile(transferId)
......@@ -226,7 +226,7 @@ Loader {
,ProgressBar {
id: progressBar
visible: root.status === Interaction.Status.TRANSFER_ONGOING
visible: root.transferStatus === Interaction.Status.TRANSFER_ONGOING
height: visible * implicitHeight
value: transferStats.progress / transferStats.totalSize
width: transferItem.width
......@@ -244,7 +244,7 @@ Loader {
isOutgoing: Author === CurrentAccount.uri
transferId: Id
property var transferStats: MessagesAdapter.getTransferStats(transferId, root.status)
property var transferStats: MessagesAdapter.getTransferStats(transferId, root.transferStatus)
showTime: root.showTime
seq: root.seq
author: Author
......@@ -398,7 +398,7 @@ Loader {
readonly property real aspectRatio: paintedWidth / paintedHeight
readonly property real idealWidth: innerContent.width - senderMargin
onStatusChanged: {
if (root.status == Image.Ready && aspectRatio) {
if (img.status == Image.Ready && aspectRatio) {
height = Qt.binding(() => JamiQmlUtils.clamp(idealWidth / aspectRatio, 64, 256))
width = Qt.binding(() => height * aspectRatio)
......
......@@ -31,7 +31,7 @@ import "../../../src/app/commoncomponents"
DataTransferMessageDelegate {
id: uut
timestamp: 0
status: Interaction.Status.TRANSFER_FINISHED
transferStatus: Interaction.Status.TRANSFER_FINISHED
author: ""
body: ""
......@@ -39,9 +39,9 @@ DataTransferMessageDelegate {
name: "Check basic visibility for header buttons"
function test_checkBasicVisibility() {
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)
uut.status = Interaction.Status.TRANSFER_FINISHED
uut.transferStatus = Interaction.Status.TRANSFER_FINISHED
compare(buttonsLoader.iconSource, JamiResources.link_black_24dp_svg)
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment