Skip to content

Commit

Permalink
Fix "New Function" Dialog (rizinorg#3102)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yappa authored and XVilka committed Feb 24, 2023
1 parent 68ec5a3 commit e69a007
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/menus/DisassemblyContextMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,7 @@ void DisassemblyContextMenu::addDebugMenu()
QVector<DisassemblyContextMenu::ThingUsedHere> 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 {};
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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);
}
}
Expand Down

0 comments on commit e69a007

Please sign in to comment.