Improve codebase (#20)

This commit is contained in:
Tim Siebels 2017-10-01 20:08:12 +02:00 committed by xarkes
parent 675ca69976
commit 1f0aede403
20 changed files with 51 additions and 53 deletions

View File

@ -211,8 +211,8 @@ QJsonDocument CutterCore::cmdj(const QString &str)
bool CutterCore::loadFile(QString path, uint64_t loadaddr, uint64_t mapaddr, bool rw, int va, int idx, bool loadbin, const QString &forceBinPlugin) bool CutterCore::loadFile(QString path, uint64_t loadaddr, uint64_t mapaddr, bool rw, int va, int idx, bool loadbin, const QString &forceBinPlugin)
{ {
CUTTERNOTUSED(loadaddr); Q_UNUSED(loadaddr);
CUTTERNOTUSED(idx); Q_UNUSED(idx);
CORE_LOCK(); CORE_LOCK();
RCoreFile *f; RCoreFile *f;
@ -541,7 +541,7 @@ QString CutterCore::getConfig(const QString &k)
void CutterCore::setOptions(QString key) void CutterCore::setOptions(QString key)
{ {
CUTTERNOTUSED(key); Q_UNUSED(key);
// va // va
// lowercase // lowercase

View File

@ -44,8 +44,6 @@ public:
RCore *operator->() const; RCore *operator->() const;
}; };
#define CUTTERNOTUSED(x) do { (void)(x); } while ( 0 );
typedef ut64 RVA; typedef ut64 RVA;
#define RVA_INVALID UT64_MAX #define RVA_INVALID UT64_MAX

View File

@ -30,8 +30,7 @@ void RenameDialog::setFunctionName(QString fcnName)
ui->nameEdit->setText(fcnName); ui->nameEdit->setText(fcnName);
} }
QString RenameDialog::getFunctionName() QString RenameDialog::getFunctionName() const
{ {
QString ret = ui->nameEdit->text(); return ui->nameEdit->text();
return ret;
} }

View File

@ -17,7 +17,7 @@ public:
~RenameDialog(); ~RenameDialog();
void setFunctionName(QString fcnName); void setFunctionName(QString fcnName);
QString getFunctionName(); QString getFunctionName() const;
private slots: private slots:
void on_buttonBox_accepted(); void on_buttonBox_accepted();

View File

@ -7,14 +7,13 @@
XrefsDialog::XrefsDialog(MainWindow *main, QWidget *parent) : XrefsDialog::XrefsDialog(MainWindow *main, QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::XrefsDialog) addr(0),
func_name(QString::null),
ui(new Ui::XrefsDialog),
main(main)
{ {
addr = 0;
func_name = QString::null;
ui->setupUi(this); ui->setupUi(this);
setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint)); setWindowFlags(windowFlags() & (~Qt::WindowContextHelpButtonHint));
this->main = main;
// Increase asm text edit margin // Increase asm text edit margin
QTextDocument *asm_docu = ui->previewTextEdit->document(); QTextDocument *asm_docu = ui->previewTextEdit->document();
@ -80,7 +79,7 @@ void XrefsDialog::fillRefs(QList<XrefDescription> refs, QList<XrefDescription> x
void XrefsDialog::on_fromTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column) void XrefsDialog::on_fromTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{ {
CUTTERNOTUSED(column); Q_UNUSED(column);
XrefDescription xref = item->data(0, Qt::UserRole).value<XrefDescription>(); XrefDescription xref = item->data(0, Qt::UserRole).value<XrefDescription>();
RAnalFunction *fcn = this->main->core->functionAt(xref.to); RAnalFunction *fcn = this->main->core->functionAt(xref.to);
@ -91,7 +90,7 @@ void XrefsDialog::on_fromTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int
void XrefsDialog::on_toTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column) void XrefsDialog::on_toTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{ {
CUTTERNOTUSED(column); Q_UNUSED(column);
XrefDescription xref = item->data(0, Qt::UserRole).value<XrefDescription>(); XrefDescription xref = item->data(0, Qt::UserRole).value<XrefDescription>();
RAnalFunction *fcn = this->main->core->functionAt(xref.from); RAnalFunction *fcn = this->main->core->functionAt(xref.from);
@ -100,7 +99,7 @@ void XrefsDialog::on_toTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int c
this->close(); this->close();
} }
QString XrefsDialog::normalizeAddr(QString addr) QString XrefsDialog::normalizeAddr(const QString& addr) const
{ {
QString base = addr.split("0x")[1].trimmed(); QString base = addr.split("0x")[1].trimmed();
int len = base.length(); int len = base.length();
@ -198,4 +197,4 @@ void XrefsDialog::fillRefsForAddress(RVA addr, QString name, bool whole_function
QList<XrefDescription> xrefs = main->core->getXRefs(addr, true, whole_function); QList<XrefDescription> xrefs = main->core->getXRefs(addr, true, whole_function);
fillRefs(refs, xrefs); fillRefs(refs, xrefs);
} }

View File

@ -29,7 +29,7 @@ private slots:
void on_toTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column); void on_toTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column);
QString normalizeAddr(QString addr); QString normalizeAddr(const QString& addr) const;
void highlightCurrentLine(); void highlightCurrentLine();
void on_fromTreeWidget_itemSelectionChanged(); void on_fromTreeWidget_itemSelectionChanged();

View File

@ -10,9 +10,9 @@
const int NewFileDialog::MaxRecentFiles; const int NewFileDialog::MaxRecentFiles;
static QColor getColorFor(QString str, int pos) static QColor getColorFor(const QString& str, int pos)
{ {
CUTTERNOTUSED(str); Q_UNUSED(str);
QList<QColor> Colors; QList<QColor> Colors;
Colors << QColor(29, 188, 156); // Turquoise Colors << QColor(29, 188, 156); // Turquoise
@ -26,7 +26,7 @@ static QColor getColorFor(QString str, int pos)
} }
static QIcon getIconFor(QString str, int pos) static QIcon getIconFor(const QString& str, int pos)
{ {
// Add to the icon list // Add to the icon list
int w = 64; int w = 64;

View File

@ -11,17 +11,17 @@
DisassemblerGraphView::DisassemblerGraphView(QWidget *parent, CutterCore *core) DisassemblerGraphView::DisassemblerGraphView(QWidget *parent, CutterCore *core)
: QAbstractScrollArea(parent), : QAbstractScrollArea(parent),
mFontMetrics(nullptr),
//currentGraph(duint(0)), //currentGraph(duint(0)),
//disasm(ConfigUint("Disassembler", "MaxModuleSize")), //disasm(ConfigUint("Disassembler", "MaxModuleSize")),
mCip(0), mCore(core),
mGoto(nullptr), mFontMetrics(nullptr),
syncOrigin(false), syncOrigin(false),
mCip(0),
forceCenter(false), forceCenter(false),
layoutType(LayoutType::Medium),
mHistoryLock(false), mHistoryLock(false),
mXrefDlg(nullptr), layoutType(LayoutType::Medium),
mCore(core) mGoto(nullptr),
mXrefDlg(nullptr)
{ {
this->status = "Loading..."; this->status = "Loading...";
@ -533,6 +533,8 @@ duint DisassemblerGraphView::getInstrForMouseEvent(QMouseEvent* event)
bool DisassemblerGraphView::getTokenForMouseEvent(QMouseEvent* event, Token & tokenOut) bool DisassemblerGraphView::getTokenForMouseEvent(QMouseEvent* event, Token & tokenOut)
{ {
Q_UNUSED(event);
Q_UNUSED(tokenOut);
/* TODO /* TODO
//Convert coordinates to system used in blocks //Convert coordinates to system used in blocks
int xofs = this->horizontalScrollBar()->value(); int xofs = this->horizontalScrollBar()->value();
@ -715,6 +717,7 @@ void DisassemblerGraphView::mouseReleaseEvent(QMouseEvent* event)
void DisassemblerGraphView::mouseDoubleClickEvent(QMouseEvent* event) void DisassemblerGraphView::mouseDoubleClickEvent(QMouseEvent* event)
{ {
Q_UNUSED(event);
if(drawOverview) if(drawOverview)
{ {
toggleOverviewSlot(); toggleOverviewSlot();
@ -1717,6 +1720,7 @@ void DisassemblerGraphView::loadCurrentGraph()
void DisassemblerGraphView::graphAtSlot(duint addr) void DisassemblerGraphView::graphAtSlot(duint addr)
{ {
Q_UNUSED(addr);
//Bridge::getBridge()->setResult(this->navigate(addr) ? this->currentGraph.entryPoint : 0); //Bridge::getBridge()->setResult(this->navigate(addr) ? this->currentGraph.entryPoint : 0);
} }
@ -1727,6 +1731,8 @@ void DisassemblerGraphView::updateGraphSlot()
void DisassemblerGraphView::addReferenceAction(QMenu* menu, duint addr) void DisassemblerGraphView::addReferenceAction(QMenu* menu, duint addr)
{ {
Q_UNUSED(menu);
Q_UNUSED(addr);
/*QAction* action = new QAction(menu); /*QAction* action = new QAction(menu);
action->setData(ToPtrString(addr)); action->setData(ToPtrString(addr));
action->setText(getSymbolicName(addr)); action->setText(getSymbolicName(addr));
@ -1837,6 +1843,7 @@ void DisassemblerGraphView::setupContextMenu()
void DisassemblerGraphView::keyPressEvent(QKeyEvent* event) void DisassemblerGraphView::keyPressEvent(QKeyEvent* event)
{ {
Q_UNUSED(event);
/* /*
if(event->modifiers() != 0) if(event->modifiers() != 0)
return; return;

View File

@ -12,9 +12,11 @@
#include <QJsonParseError> #include <QJsonParseError>
GraphicsBar::GraphicsBar(MainWindow *main, QWidget *parent) : GraphicsBar::GraphicsBar(MainWindow *main, QWidget *parent) :
QToolBar(main) QToolBar(main),
codeGraphic(new QGraphicsView),
main(main)
{ {
CUTTERNOTUSED(parent); Q_UNUSED(parent);
setObjectName("codeGraphics"); setObjectName("codeGraphics");
setWindowTitle(tr("Code bar")); setWindowTitle(tr("Code bar"));
@ -24,9 +26,6 @@ GraphicsBar::GraphicsBar(MainWindow *main, QWidget *parent) :
// and the result is wrong. Something to do with overwriting the style sheet :/ // and the result is wrong. Something to do with overwriting the style sheet :/
//setStyleSheet("QToolBar { border: 0px; border-bottom: 0px; border-top: 0px; border-width: 0px;}"); //setStyleSheet("QToolBar { border: 0px; border-bottom: 0px; border-top: 0px; border-width: 0px;}");
this->codeGraphic = new QGraphicsView();
// Radare core found in:
this->main = main;
this->codeGraphic->setAlignment(Qt::AlignLeft); this->codeGraphic->setAlignment(Qt::AlignLeft);
this->codeGraphic->setMinimumHeight(20); this->codeGraphic->setMinimumHeight(20);
this->codeGraphic->setMaximumHeight(20); this->codeGraphic->setMaximumHeight(20);
@ -44,7 +43,7 @@ GraphicsBar::GraphicsBar(MainWindow *main, QWidget *parent) :
void GraphicsBar::paintEvent(QPaintEvent *event) void GraphicsBar::paintEvent(QPaintEvent *event)
{ {
CUTTERNOTUSED(event); Q_UNUSED(event);
QPainter painter(this); QPainter painter(this);
this->fillData(); this->fillData();

View File

@ -49,7 +49,7 @@ void CommentsWidget::refresh()
void CommentsWidget::on_commentsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column) void CommentsWidget::on_commentsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{ {
CUTTERNOTUSED(column); Q_UNUSED(column);
// Get offset and name of item double clicked // Get offset and name of item double clicked
CommentDescription comment = item->data(0, Qt::UserRole).value<CommentDescription>(); CommentDescription comment = item->data(0, Qt::UserRole).value<CommentDescription>();

View File

@ -14,13 +14,11 @@
Dashboard::Dashboard(MainWindow *main, QWidget *parent) : Dashboard::Dashboard(MainWindow *main, QWidget *parent) :
DockWidget(parent), DockWidget(parent),
ui(new Ui::Dashboard) ui(new Ui::Dashboard),
main(main)
{ {
ui->setupUi(this); ui->setupUi(this);
// Radare core found in:
this->main = main;
//this->updateContents(); //this->updateContents();
} }

View File

@ -14,13 +14,11 @@
EntrypointWidget::EntrypointWidget(MainWindow *main, QWidget *parent) : EntrypointWidget::EntrypointWidget(MainWindow *main, QWidget *parent) :
DockWidget(parent), DockWidget(parent),
ui(new Ui::EntrypointWidget) ui(new Ui::EntrypointWidget),
main(main)
{ {
ui->setupUi(this); ui->setupUi(this);
// Radare core found in:
this->main = main;
// Delegate // Delegate
//CMyDelegate* delegate = new CMyDelegate(ui->importsTreeWidget); //CMyDelegate* delegate = new CMyDelegate(ui->importsTreeWidget);
//ui->importsTreeWidget->setItemDelegate(delegate); //ui->importsTreeWidget->setItemDelegate(delegate);

View File

@ -165,7 +165,7 @@ void FlagsWidget::on_flagsTreeView_doubleClicked(const QModelIndex &index)
void FlagsWidget::on_flagspaceCombo_currentTextChanged(const QString &arg1) void FlagsWidget::on_flagspaceCombo_currentTextChanged(const QString &arg1)
{ {
CUTTERNOTUSED(arg1); Q_UNUSED(arg1);
refreshFlags(); refreshFlags();
} }

View File

@ -225,7 +225,7 @@ void Notepad::on_searchEdit_returnPressed()
void Notepad::on_searchEdit_textEdited(const QString &arg1) void Notepad::on_searchEdit_textEdited(const QString &arg1)
{ {
CUTTERNOTUSED(arg1); Q_UNUSED(arg1);
QString searchString = ui->searchEdit->text(); QString searchString = ui->searchEdit->text();
QTextDocument *document = ui->notepadTextEdit->document(); QTextDocument *document = ui->notepadTextEdit->document();
@ -264,7 +264,7 @@ void Notepad::on_searchEdit_textEdited(const QString &arg1)
void Notepad::on_searchEdit_textChanged(const QString &arg1) void Notepad::on_searchEdit_textChanged(const QString &arg1)
{ {
CUTTERNOTUSED(arg1); Q_UNUSED(arg1);
QString searchString = ui->searchEdit->text(); QString searchString = ui->searchEdit->text();
QTextDocument *document = ui->notepadTextEdit->document(); QTextDocument *document = ui->notepadTextEdit->document();

View File

@ -486,7 +486,7 @@ void PieView::scrollTo(const QModelIndex &index, ScrollHint)
void PieView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command) void PieView::setSelection(const QRect &rect, QItemSelectionModel::SelectionFlags command)
{ {
CUTTERNOTUSED(command); Q_UNUSED(command);
// Use content widget coordinates because we will use the itemRegion() // Use content widget coordinates because we will use the itemRegion()
// function to check for intersections. // function to check for intersections.
@ -600,7 +600,7 @@ QRegion PieView::visualRegionForSelection(const QItemSelection &selection) const
} }
/*Function to find minimum of x and y*/ /*Function to find minimum of x and y*/
int PieView::getMin(int x, int y) int PieView::getMin(int x, int y) const
{ {
return y ^ ((x ^ y) & -(x < y)); return y ^ ((x ^ y) & -(x < y));
} }

View File

@ -92,7 +92,7 @@ private:
QRegion itemRegion(const QModelIndex &index) const; QRegion itemRegion(const QModelIndex &index) const;
int rows(const QModelIndex &index = QModelIndex()) const; int rows(const QModelIndex &index = QModelIndex()) const;
void updateGeometries() override; void updateGeometries() override;
int getMin(int x, int y); int getMin(int x, int y) const;
int margin; int margin;
int totalSize; int totalSize;

View File

@ -36,7 +36,7 @@ void RelocsWidget::refresh()
void RelocsWidget::on_relocsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column) void RelocsWidget::on_relocsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{ {
CUTTERNOTUSED(column); Q_UNUSED(column);
// Get offset and name of item double clicked // Get offset and name of item double clicked
RelocDescription reloc = item->data(0, Qt::UserRole).value<RelocDescription>(); RelocDescription reloc = item->data(0, Qt::UserRole).value<RelocDescription>();

View File

@ -11,7 +11,7 @@ SectionsWidget::SectionsWidget(MainWindow *main, QWidget *parent) :
QSplitter(main), QSplitter(main),
main(main) main(main)
{ {
CUTTERNOTUSED(parent); Q_UNUSED(parent);
setupViews(); setupViews();
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);

View File

@ -36,7 +36,7 @@ void StringsWidget::refresh()
void StringsWidget::on_stringsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column) void StringsWidget::on_stringsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{ {
CUTTERNOTUSED(column); Q_UNUSED(column);
// Get offset and name of item double clicked // Get offset and name of item double clicked
// TODO: use this info to change disasm contents // TODO: use this info to change disasm contents

View File

@ -36,7 +36,7 @@ void SymbolsWidget::refresh()
void SymbolsWidget::on_symbolsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column) void SymbolsWidget::on_symbolsTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int column)
{ {
CUTTERNOTUSED(column); Q_UNUSED(column);
// Get offset and name of item double clicked // Get offset and name of item double clicked
SymbolDescription symbol = item->data(0, Qt::UserRole).value<SymbolDescription>(); SymbolDescription symbol = item->data(0, Qt::UserRole).value<SymbolDescription>();