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
Branches
Tags
No related merge requests found
...@@ -40,12 +40,12 @@ Loader { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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)
......
...@@ -31,7 +31,7 @@ import "../../../src/app/commoncomponents" ...@@ -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 { ...@@ -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)
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment