From 78b52f7ec06bd1aa00f4aa28c490e40eacec10b7 Mon Sep 17 00:00:00 2001 From: Mr-Auto <36127424+Mr-Auto@users.noreply.github.com> Date: Sat, 25 May 2024 21:00:24 +0200 Subject: [PATCH] compare float and double as integers to avoid infinity comparisons with always return false --- src/QtHelpers/TreeViewMemoryFields.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/QtHelpers/TreeViewMemoryFields.cpp b/src/QtHelpers/TreeViewMemoryFields.cpp index d118978..355cdb0 100644 --- a/src/QtHelpers/TreeViewMemoryFields.cpp +++ b/src/QtHelpers/TreeViewMemoryFields.cpp @@ -752,13 +752,18 @@ void S2Plugin::TreeViewMemoryFields::updateRow(int row, std::optional } case MemoryFieldType::Float: { - std::optional value; - value = updateField(itemField, valueMemoryOffset, itemValue, "%f", itemValueHex, isPointer, "0x%08X", true, !pointerUpdate, highlightColor); + std::optional value; + value = updateField(itemField, valueMemoryOffset, itemValue, nullptr, itemValueHex, isPointer, "0x%08X", true, !pointerUpdate, highlightColor); + if (value.has_value()) + itemValue->setData(QString::asprintf("%f", reinterpret_cast(value.value())), Qt::DisplayRole); if (comparisonActive) { - std::optional comparisonValue; - comparisonValue = updateField(itemField, valueComparisonMemoryOffset, itemComparisonValue, "%f", itemComparisonValueHex, isPointer, "0x%08X", false, false, highlightColor); + std::optional comparisonValue; + comparisonValue = + updateField(itemField, valueComparisonMemoryOffset, itemComparisonValue, nullptr, itemComparisonValueHex, isPointer, "0x%08X", false, false, highlightColor); + if (comparisonValue.has_value()) + itemComparisonValue->setData(QString::asprintf("%f", reinterpret_cast(comparisonValue.value())), Qt::DisplayRole); itemComparisonValue->setBackground(value != comparisonValue ? comparisonDifferenceColor : Qt::transparent); if (isPointer == false) @@ -768,13 +773,18 @@ void S2Plugin::TreeViewMemoryFields::updateRow(int row, std::optional } case MemoryFieldType::Double: { - std::optional value; - value = updateField(itemField, valueMemoryOffset, itemValue, "%lf", itemValueHex, isPointer, "0x%016llX", true, !pointerUpdate, highlightColor); + std::optional value; + value = updateField(itemField, valueMemoryOffset, itemValue, nullptr, itemValueHex, isPointer, "0x%016llX", true, !pointerUpdate, highlightColor); + if (value.has_value()) + itemValue->setData(QString::asprintf("%lf", reinterpret_cast(value.value())), Qt::DisplayRole); if (comparisonActive) { - std::optional comparisonValue; - comparisonValue = updateField(itemField, valueComparisonMemoryOffset, itemComparisonValue, "%lf", itemComparisonValueHex, isPointer, "0x%016llX", false, false, highlightColor); + std::optional comparisonValue; + comparisonValue = + updateField(itemField, valueComparisonMemoryOffset, itemComparisonValue, nullptr, itemComparisonValueHex, isPointer, "0x%016llX", false, false, highlightColor); + if (comparisonValue.has_value()) + itemComparisonValue->setData(QString::asprintf("%lf", reinterpret_cast(comparisonValue.value())), Qt::DisplayRole); itemComparisonValue->setBackground(value != comparisonValue ? comparisonDifferenceColor : Qt::transparent); if (isPointer == false)