diff --git a/src/Cutter.cpp b/src/Cutter.cpp index 14f4b0e7..05aa9ea2 100644 --- a/src/Cutter.cpp +++ b/src/Cutter.cpp @@ -2533,19 +2533,11 @@ QList CutterCore::disassembleLines(RVA offset, int lines) offset)).array(); QList r; - for (const QJsonValue &value : array) { + for (const QJsonValueRef &value : array) { QJsonObject object = value.toObject(); - char *html = r_cons_html_filter(object[RJsonKey::text].toString().toUtf8(), nullptr); - if (!html) { - continue; - } - DisassemblyLine line; - line.offset = object[RJsonKey::offset].toVariant().toULongLong(); - line.text = QString::fromUtf8(html); - free (html); - + line.text = ansiEscapeToHtml(object[RJsonKey::text].toString()); r << line; } @@ -2629,3 +2621,14 @@ QList CutterCore::getCutterPlugins() return plugins; } +QString CutterCore::ansiEscapeToHtml(const QString &text) +{ + int len; + char *html = r_cons_html_filter(text.toUtf8().constData(), &len); + if (!html) { + return QString(); + } + QString r = QString::fromUtf8(html, len); + free(html); + return r; +} \ No newline at end of file diff --git a/src/Cutter.h b/src/Cutter.h index 1fbd666d..bf4363de 100644 --- a/src/Cutter.h +++ b/src/Cutter.h @@ -730,6 +730,8 @@ public: RCoreLocked core() const; + static QString ansiEscapeToHtml(const QString &text); + signals: void refreshAll(); diff --git a/src/widgets/DisassemblerGraphView.cpp b/src/widgets/DisassemblerGraphView.cpp index 241f91cd..a231fa6b 100644 --- a/src/widgets/DisassemblerGraphView.cpp +++ b/src/widgets/DisassemblerGraphView.cpp @@ -290,11 +290,7 @@ void DisassemblerGraphView::loadCurrentGraph() i.size -= 1; QTextDocument textDoc; - char *html = r_cons_html_filter(op["text"].toString().toUtf8().constData(), nullptr); - if (html) { - textDoc.setHtml(QString::fromUtf8(html)); - free (html); - } + textDoc.setHtml(CutterCore::ansiEscapeToHtml(op["text"].toString())); i.plainText = textDoc.toPlainText(); diff --git a/src/widgets/FunctionsWidget.cpp b/src/widgets/FunctionsWidget.cpp index 48e5024e..a58299d1 100644 --- a/src/widgets/FunctionsWidget.cpp +++ b/src/widgets/FunctionsWidget.cpp @@ -196,7 +196,7 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const return static_cast(Qt::AlignLeft | Qt::AlignVCenter); case Qt::ToolTipRole: { - QJsonArray jDisasmEntries; + QList disassemblyLines; { // temporarily simplify the disasm output to get it colorful and simple to read TempConfig tempConfig; @@ -209,21 +209,17 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const .set("asm.lines.fcn", false) .set("asm.lines.out", false) .set("asm.lines.bb", false) - .set("asm.bbline", false); + .set("asm.bbline", false) + .set("asm.stackptr", false); - jDisasmEntries = Core()->cmdj(QString("pdJ %1 @ %2") - .arg(kMaxTooltipDisasmPreviewLines + 1) - .arg(function.offset)).array(); + disassemblyLines = Core()->disassembleLines(function.offset, kMaxTooltipDisasmPreviewLines + 1); } QStringList disasmPreview; - for (const QJsonValue &value : jDisasmEntries) { - const QJsonObject &object = value.toObject(); - - const RVA insnOffset = object["offset"].toVariant().toULongLong(); - if (!function.contains(insnOffset)) { + for (const DisassemblyLine &line : disassemblyLines) { + if (!function.contains(line.offset)) { break; } - disasmPreview << object["text"].toString(); + disasmPreview << line.text; if (disasmPreview.length() >= kMaxTooltipDisasmPreviewLines) { disasmPreview << "..."; break; diff --git a/src/widgets/HexdumpWidget.cpp b/src/widgets/HexdumpWidget.cpp index fac521cd..eafb8b64 100644 --- a/src/widgets/HexdumpWidget.cpp +++ b/src/widgets/HexdumpWidget.cpp @@ -213,7 +213,7 @@ void HexdumpWidget::setupScrollSync() asciiHexFunc); } -void HexdumpWidget::onSeekChanged(RVA addr) +void HexdumpWidget::onSeekChanged(RVA) { if (sent_seek) { sent_seek = false;