From e69a007b8f52eea012417c5bfe576e935bf9044c Mon Sep 17 00:00:00 2001 From: Yappa Date: Sun, 19 Feb 2023 23:10:11 -0800 Subject: [PATCH] Fix "New Function" Dialog (#3102) --- src/menus/DisassemblyContextMenu.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/menus/DisassemblyContextMenu.cpp b/src/menus/DisassemblyContextMenu.cpp index ab54328da2..918a63fad4 100644 --- a/src/menus/DisassemblyContextMenu.cpp +++ b/src/menus/DisassemblyContextMenu.cpp @@ -314,8 +314,7 @@ void DisassemblyContextMenu::addDebugMenu() QVector DisassemblyContextMenu::getThingUsedHere(RVA offset) { RzCoreLocked core(Core()); - auto p = fromOwned( - rz_core_analysis_name(core, offset), rz_core_analysis_name_free); + auto p = fromOwned(rz_core_analysis_name(core, offset), rz_core_analysis_name_free); if (!p) { return {}; } @@ -799,7 +798,6 @@ void DisassemblyContextMenu::on_actionAddComment_triggered() void DisassemblyContextMenu::on_actionAnalyzeFunction_triggered() { - bool ok; RVA flagOffset; QString name = Core()->nearestFlag(offset, &flagOffset); if (name.isEmpty() || flagOffset != offset) { @@ -812,12 +810,20 @@ void DisassemblyContextMenu::on_actionAnalyzeFunction_triggered() } // Create dialog - QString functionName = - QInputDialog::getText(this, tr("New function at %1").arg(RzAddressString(offset)), - tr("Function name:"), QLineEdit::Normal, name, &ok); + QInputDialog inputDialog(this->mainWindow); + inputDialog.resize(500, 100); + inputDialog.setWindowTitle(tr("New function at %1").arg(RzAddressString(offset))); + inputDialog.setLabelText(tr("Function name:")); + inputDialog.setTextValue(name); + inputDialog.setWindowFlags(Qt::Window | Qt::WindowMinimizeButtonHint); + + if (inputDialog.exec() != QDialog::Accepted) { + return; + } + + QString functionName = inputDialog.textValue().trimmed(); - // If user accepted - if (ok && !functionName.isEmpty()) { + if (!functionName.isEmpty()) { Core()->createFunctionAt(offset, functionName); } }