Fix text body lingering under image preview

PreviewPane set bodyText from onResultChanged, reading derived/entry that
are themselves bindings on result. Depending on evaluation order the
handler saw the previous entry, leaving a stale text body visible under
the image column. Derive bodyText declaratively and gate the text body on
the textual types.
This commit is contained in:
2026-09-07 16:28:06 +01:00
parent 4662c8002d
commit 8127ae4bba
+14 -17
View File
@@ -21,22 +21,19 @@ Item {
readonly property color chipBg: Util.alpha(fg, 0.07) readonly property color chipBg: Util.alpha(fg, 0.07)
readonly property color lineColor: Util.alpha(fg, 0.16) readonly property color lineColor: Util.alpha(fg, 0.16)
property string bodyText: "" // Textual types render in the scrollable body; every other type has its
// own block below. Derived as bindings (not set from onResultChanged) so
onResultChanged: prepare() // the body text and the type can never disagree mid-update, which used to
// leave a stale text body visible underneath an image preview.
function prepare() { readonly property bool textual: derived === "text" || derived === "code"
bodyText = "" || derived === "email" || derived === "number"
if (!entry) return || derived === "json" || derived === "html"
var t = derived readonly property string bodyText: {
if (t === "json") { if (!entry || !textual) return ""
var pretty = Classify.prettyJson(String(entry.text || ""), 200000) var raw = String(entry.text || "")
bodyText = pretty || String(entry.text || "") if (derived === "json") return Classify.prettyJson(raw, 200000) || raw
} else if (t === "html") { if (derived === "html") return Classify.stripHtml(raw) || raw
bodyText = Classify.stripHtml(String(entry.text || "")) || String(entry.text || "") return raw
} else if (t === "text" || t === "code" || t === "email" || t === "number") {
bodyText = String(entry.text || "")
}
} }
function rawSafe() { function rawSafe() {
@@ -197,7 +194,7 @@ Item {
anchors.right: parent.right anchors.right: parent.right
anchors.topMargin: Style.space(10) anchors.topMargin: Style.space(10)
anchors.bottomMargin: Style.space(10) anchors.bottomMargin: Style.space(10)
visible: root.bodyText !== "" visible: root.textual && root.bodyText !== ""
clip: true clip: true
contentWidth: width contentWidth: width
contentHeight: bodyEdit.implicitHeight contentHeight: bodyEdit.implicitHeight