mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-24 05:45:27 +00:00
Various code cleaning (#907)
This commit is contained in:
parent
71765a5d19
commit
b1e9db15fc
@ -1967,10 +1967,11 @@ QList<XrefDescription> CutterCore::getXRefs(RVA addr, bool to, bool whole_functi
|
||||
|
||||
QJsonArray xrefsArray;
|
||||
|
||||
if (to)
|
||||
if (to) {
|
||||
xrefsArray = cmdj("axtj@" + QString::number(addr)).array();
|
||||
else
|
||||
} else {
|
||||
xrefsArray = cmdj("axfj@" + QString::number(addr)).array();
|
||||
}
|
||||
|
||||
for (QJsonValue value : xrefsArray) {
|
||||
QJsonObject xrefObject = value.toObject();
|
||||
@ -1994,13 +1995,15 @@ QList<XrefDescription> CutterCore::getXRefs(RVA addr, bool to, bool whole_functi
|
||||
}
|
||||
}
|
||||
|
||||
if (!whole_function && !to && xref.from != addr)
|
||||
if (!whole_function && !to && xref.from != addr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (to && !xrefObject.contains("to"))
|
||||
if (to && !xrefObject.contains("to")) {
|
||||
xref.to = addr;
|
||||
else
|
||||
} else {
|
||||
xref.to = xrefObject["to"].toVariant().toULongLong();
|
||||
}
|
||||
xref.to_str = Core()->cmd("fd " + QString::number(xref.to)).trimmed();
|
||||
|
||||
ret << xref;
|
||||
@ -2141,8 +2144,9 @@ QList<QString> CutterCore::getColorThemes()
|
||||
{
|
||||
QList<QString> r;
|
||||
QJsonDocument themes = cmdj("ecoj");
|
||||
for (auto s : themes.array())
|
||||
for (auto s : themes.array()) {
|
||||
r << s.toString();
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -236,8 +236,9 @@ void CutterApplication::loadPlugins()
|
||||
pluginsDir.cdUp();
|
||||
}
|
||||
#endif
|
||||
if (!pluginsDir.cd("plugins"))
|
||||
if (!pluginsDir.cd("plugins")) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (QString fileName, pluginsDir.entryList(QDir::Files)) {
|
||||
QPluginLoader pluginLoader(pluginsDir.absoluteFilePath(fileName));
|
||||
|
@ -274,7 +274,7 @@ void DisassemblyContextMenu::aboutToShowSlot()
|
||||
actionRename.setVisible(false);
|
||||
}
|
||||
|
||||
//only show retype for local vars if in a function
|
||||
// Only show retype for local vars if in a function
|
||||
if (in_fcn) {
|
||||
actionSetFunctionVarTypes.setVisible(true);
|
||||
actionEditFunction.setVisible(true);
|
||||
@ -285,7 +285,7 @@ void DisassemblyContextMenu::aboutToShowSlot()
|
||||
}
|
||||
|
||||
|
||||
// only show "rename X used here" if there is something to rename
|
||||
// Only show "rename X used here" if there is something to rename
|
||||
QJsonArray thingUsedHereArray = Core()->cmdj("anj @ " + QString::number(offset)).array();
|
||||
if (!thingUsedHereArray.isEmpty()) {
|
||||
actionRenameUsedHere.setVisible(true);
|
||||
@ -305,10 +305,10 @@ void DisassemblyContextMenu::aboutToShowSlot()
|
||||
actionRenameUsedHere.setVisible(false);
|
||||
}
|
||||
|
||||
// decide to show Reverse jmp option
|
||||
// Decide to show Reverse jmp option
|
||||
showReverseJmpQuery();
|
||||
|
||||
// only show debug options if we are currently debugging
|
||||
// Only show debug options if we are currently debugging
|
||||
debugMenu->menuAction()->setVisible(Core()->currentlyDebugging);
|
||||
QString progCounterName = Core()->getRegisterName("PC");
|
||||
actionSetPC.setText("Set " + progCounterName + " here");
|
||||
@ -390,7 +390,7 @@ void DisassemblyContextMenu::on_actionEditInstruction_triggered()
|
||||
if (userInstructionOpcode != oldInstructionOpcode) {
|
||||
Core()->editInstruction(offset, userInstructionOpcode);
|
||||
|
||||
// check if the write failed
|
||||
// Check if the write failed
|
||||
auto newInstructionBytes = Core()->getInstructionBytes(offset);
|
||||
if (newInstructionBytes == oldInstructionBytes) {
|
||||
if (!writeFailed()) {
|
||||
|
@ -9,7 +9,6 @@
|
||||
SideBar::SideBar(MainWindow *main) :
|
||||
QWidget(main),
|
||||
ui(new Ui::SideBar),
|
||||
// Radare core found in:
|
||||
main(main)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
@ -130,10 +130,7 @@ void SidebarWidget::on_regInfoToolButton_clicked()
|
||||
|
||||
void SidebarWidget::updateRefs(RVA addr)
|
||||
{
|
||||
// refs = calls q hace esa funcion
|
||||
QList<XrefDescription> refs = Core()->getXRefs(addr, false, false);
|
||||
|
||||
// xrefs = calls a esa funcion
|
||||
QList<XrefDescription> xrefs = Core()->getXRefs(addr, true, false);
|
||||
|
||||
// Update disasm side bar
|
||||
@ -171,12 +168,9 @@ void SidebarWidget::fillRefs(QList<XrefDescription> refs, QList<XrefDescription>
|
||||
tempItem->setData(0, Qt::UserRole, QVariant::fromValue(xref));
|
||||
QString tooltip = Core()->cmd("pdi 10 @ " + QString::number(xref.from)).trimmed();
|
||||
|
||||
// TODO wtf is this?
|
||||
//tempItem->setToolTip(0, this->core->cmd("pdi 10 @ " + tooltip).trimmed());
|
||||
//tempItem->setToolTip(1, this->core->cmd("pdi 10 @ " + tooltip).trimmed());
|
||||
|
||||
ui->xrefToTreeWidget->insertTopLevelItem(0, tempItem);
|
||||
}
|
||||
|
||||
// Adjust columns to content
|
||||
qhelpers::adjustColumns(ui->xrefToTreeWidget, 0);
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ StackWidget::StackWidget(MainWindow *main, QAction *action) :
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
// setup stack model
|
||||
// Setup stack model
|
||||
modelStack->setHorizontalHeaderItem(0, new QStandardItem(tr("Offset")));
|
||||
modelStack->setHorizontalHeaderItem(1, new QStandardItem(tr("Value")));
|
||||
modelStack->setHorizontalHeaderItem(2, new QStandardItem(tr("Reference")));
|
||||
@ -97,7 +97,7 @@ void StackWidget::onDoubleClicked(const QModelIndex &index)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
// check if we are clicking on the offset or value columns and seek if it is the case
|
||||
// Check if we are clicking on the offset or value columns and seek if it is the case
|
||||
if (index.column() <= 1) {
|
||||
QString item = index.data().toString();
|
||||
Core()->seek(item);
|
||||
@ -132,7 +132,7 @@ void StackWidget::editStack()
|
||||
if (e->exec()) {
|
||||
QString bytes = e->getInstruction();
|
||||
if (bytes != oldBytes) {
|
||||
Core()->editBytesEndian((RVA)offset.toULongLong(&ok, 16), bytes);
|
||||
Core()->editBytesEndian(offset.toULongLong(&ok, 16), bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -185,8 +185,9 @@ StringsWidget::~StringsWidget() {}
|
||||
|
||||
void StringsWidget::on_stringsTreeView_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
if (!index.isValid())
|
||||
if (!index.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
StringDescription str = index.data(StringsModel::StringDescriptionRole).value<StringDescription>();
|
||||
Core()->seek(str.vaddr);
|
||||
@ -253,10 +254,11 @@ void StringsWidget::on_actionCopy()
|
||||
|
||||
QModelIndex index;
|
||||
|
||||
if(sender() == ui->actionCopy_String)
|
||||
if (sender() == ui->actionCopy_String) {
|
||||
index = ui->stringsTreeView->model()->index(row, 1);
|
||||
else if(sender() == ui->actionCopy_Address)
|
||||
} else if (sender() == ui->actionCopy_Address) {
|
||||
index = ui->stringsTreeView->model()->index(row, 0);
|
||||
}
|
||||
|
||||
QClipboard *clipboard = QApplication::clipboard();
|
||||
clipboard->setText(index.data().toString());
|
||||
|
@ -22,8 +22,9 @@ int SymbolsModel::columnCount(const QModelIndex &) const
|
||||
|
||||
QVariant SymbolsModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (index.row() >= symbols->count())
|
||||
if (index.row() >= symbols->count()) {
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
const SymbolDescription &symbol = symbols->at(index.row());
|
||||
|
||||
@ -143,8 +144,9 @@ SymbolsWidget::~SymbolsWidget() {}
|
||||
|
||||
void SymbolsWidget::on_symbolsTreeView_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
if (!index.isValid())
|
||||
if (!index.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto symbol = index.data(SymbolsModel::SymbolDescriptionRole).value<SymbolDescription>();
|
||||
Core()->seek(symbol.vaddr);
|
||||
|
@ -130,12 +130,3 @@ void TypesWidget::setScrollMode()
|
||||
{
|
||||
qhelpers::setVerticalScrollMode(ui->typesTreeView);
|
||||
}
|
||||
|
||||
void TypesWidget::on_typesTreeView_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
// TypeDescription exp = index.data(TypesModel::TypeDescriptionRole).value<TypeDescription>();
|
||||
// Core()->seek(exp.vaddr);
|
||||
}
|
||||
|
@ -69,8 +69,6 @@ public:
|
||||
~TypesWidget();
|
||||
|
||||
private slots:
|
||||
void on_typesTreeView_doubleClicked(const QModelIndex &index);
|
||||
|
||||
void refreshTypes();
|
||||
|
||||
private:
|
||||
|
@ -182,14 +182,16 @@ void VTablesWidget::refreshVTables()
|
||||
|
||||
void VTablesWidget::on_vTableTreeView_doubleClicked(const QModelIndex &index)
|
||||
{
|
||||
if (!index.isValid())
|
||||
if (!index.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QModelIndex parent = index.parent();
|
||||
if (parent.isValid())
|
||||
if (parent.isValid()) {
|
||||
Core()->seek(index.data(
|
||||
VTableModel::VTableDescriptionRole).value<ClassMethodDescription>().addr);
|
||||
else
|
||||
} else {
|
||||
Core()->seek(index.data(
|
||||
VTableModel::VTableDescriptionRole).value<VTableDescription>().addr);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user