From baa49a2c55e91b0598abfae6a991bb7a8d29b69c Mon Sep 17 00:00:00 2001 From: Lieven Hey Date: Tue, 21 May 2024 15:32:59 +0200 Subject: [PATCH 1/4] fix: can't select directory in unwind->sysroot Sysroot is usually a directory so it should be selectable fixes: #645 --- src/unwindsettingspage.ui | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/unwindsettingspage.ui b/src/unwindsettingspage.ui index 5c044135..4789d242 100644 --- a/src/unwindsettingspage.ui +++ b/src/unwindsettingspage.ui @@ -6,7 +6,7 @@ 0 0 - 556 + 564 656 @@ -22,6 +22,9 @@ Path to the sysroot. Leave empty to use the local machine. + + KFile::Directory|KFile::ExistingOnly|KFile::LocalOnly + local machine From 2ff437c66fcb6161238e6980a7f26c8ea3b269d7 Mon Sep 17 00:00:00 2001 From: Lieven Hey Date: Tue, 21 May 2024 16:33:03 +0200 Subject: [PATCH 2/4] fix: don't show ansi escape sequences in tooltip --- src/models/highlightedtext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/highlightedtext.cpp b/src/models/highlightedtext.cpp index aabf2439..27766778 100644 --- a/src/models/highlightedtext.cpp +++ b/src/models/highlightedtext.cpp @@ -331,7 +331,7 @@ void HighlightedText::setText(const QStringList& text) updateTabWidth(m_tabWidth); m_cleanedLines = text; - std::for_each(m_cleanedLines.begin(), m_cleanedLines.end(), Util::removeAnsi); + std::transform(m_cleanedLines.begin(), m_cleanedLines.end(), m_cleanedLines.begin(), Util::removeAnsi); } void HighlightedText::setDefinition(const KSyntaxHighlighting::Definition& definition) From 39d72d513bbf25d1c44c502775d76326c41376cb Mon Sep 17 00:00:00 2001 From: Lieven Hey Date: Fri, 24 May 2024 09:43:18 +0200 Subject: [PATCH 3/4] chore: remove unused include --- src/models/disassemblymodel.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/models/disassemblymodel.h b/src/models/disassemblymodel.h index 7c65a546..2cba0ad9 100644 --- a/src/models/disassemblymodel.h +++ b/src/models/disassemblymodel.h @@ -8,7 +8,6 @@ #pragma once -#include #include #include From 5f929be21aa6c157a53ab45a814c043906cd3d15 Mon Sep 17 00:00:00 2001 From: Lieven Hey Date: Fri, 24 May 2024 09:43:37 +0200 Subject: [PATCH 4/4] fix: crash in disassembler on hover When hovering the disassembler tries to create an tooltip. If the user hovers on the disassembly column or an earlier one, the model calculates a negative cost type which will cause an out of bounds access error in the cost array, even if the cost is not shown. This patch changes the order of operations and adds an check to make sure no out of bound access happens. fixes: #642 --- src/models/disassemblymodel.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/models/disassemblymodel.cpp b/src/models/disassemblymodel.cpp index 5daec8d4..a1f458d1 100644 --- a/src/models/disassemblymodel.cpp +++ b/src/models/disassemblymodel.cpp @@ -132,8 +132,17 @@ QVariant DisassemblyModel::data(const QModelIndex& index, int role) const auto it = entry.offsetMap.find(data.addr); if (it != entry.offsetMap.end()) { const auto event = index.column() - COLUMN_COUNT; - const auto& locationCost = it.value(); + + if (role == Qt::ToolTipRole) { + auto tooltip = tr("addr: %1
assembly: %2
disassembly: %3") + .arg(QString::number(data.addr, 16), line); + return Util::formatTooltip(tooltip, locationCost, m_results.selfCosts); + } + + if (event < 0) + return {}; + const auto& costLine = locationCost.selfCost[event]; const auto totalCost = m_results.selfCosts.totalCost(event); @@ -141,19 +150,13 @@ QVariant DisassemblyModel::data(const QModelIndex& index, int role) const return costLine; } else if (role == TotalCostRole) { return totalCost; - } else if (role == Qt::ToolTipRole) { - auto tooltip = tr("addr: %1
assembly: %2
disassembly: %3") - .arg(QString::number(data.addr, 16), line); - return Util::formatTooltip(tooltip, locationCost, m_results.selfCosts); - } - - if (!costLine) + } else if (!costLine) return {}; return Util::formatCostRelative(costLine, totalCost, true); } else { - if (role == Qt::ToolTipRole) + if (role == Qt::ToolTipRole) { return tr("%1
No samples at this location.
").arg(line.toHtmlEscaped()); - else + } else return QString(); } } else if (role == DisassemblyModel::HighlightRole) {