mirror of
https://github.com/rizinorg/cutter.git
synced 2025-02-21 14:16:08 +00:00
Some micro optimizations (#1346)
This commit is contained in:
parent
fa6e465bd4
commit
40452c9826
@ -40,7 +40,7 @@ int main(int argc, char *argv[])
|
|||||||
UpdateWorker *updateWorker = new UpdateWorker;
|
UpdateWorker *updateWorker = new UpdateWorker;
|
||||||
QObject::connect(updateWorker, &UpdateWorker::checkComplete,
|
QObject::connect(updateWorker, &UpdateWorker::checkComplete,
|
||||||
[=](const QVersionNumber &version, const QString & error) {
|
[=](const QVersionNumber &version, const QString & error) {
|
||||||
if (error == "" && version > UpdateWorker::currentVersionNumber()) {
|
if (error.isEmpty() && version > UpdateWorker::currentVersionNumber()) {
|
||||||
updateWorker->showUpdateDialog(true);
|
updateWorker->showUpdateDialog(true);
|
||||||
}
|
}
|
||||||
updateWorker->deleteLater();
|
updateWorker->deleteLater();
|
||||||
|
@ -47,7 +47,7 @@ void AsyncTask::run()
|
|||||||
|
|
||||||
running = true;
|
running = true;
|
||||||
|
|
||||||
logBuffer = "";
|
logBuffer.clear();
|
||||||
emit logChanged(logBuffer);
|
emit logChanged(logBuffer);
|
||||||
runTask();
|
runTask();
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ void AsyncTask::run()
|
|||||||
|
|
||||||
void AsyncTask::log(QString s)
|
void AsyncTask::log(QString s)
|
||||||
{
|
{
|
||||||
logBuffer += s + "\n";
|
logBuffer += s.append(QLatin1Char('\n'));
|
||||||
emit logChanged(logBuffer);
|
emit logChanged(logBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@ BasicBlockHighlighter::BasicBlockHighlighter()
|
|||||||
|
|
||||||
BasicBlockHighlighter::~BasicBlockHighlighter()
|
BasicBlockHighlighter::~BasicBlockHighlighter()
|
||||||
{
|
{
|
||||||
for (BasicBlockIt itr = bbMap.begin(); itr != bbMap.end(); itr++) {
|
for (BasicBlockIt itr = bbMap.begin(); itr != bbMap.end(); ++itr) {
|
||||||
delete itr->second;
|
delete itr->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ RichTextPainter::List RichTextPainter::fromTextDocument(const QTextDocument &doc
|
|||||||
List r;
|
List r;
|
||||||
|
|
||||||
for (QTextBlock block = doc.begin(); block != doc.end(); block = block.next()) {
|
for (QTextBlock block = doc.begin(); block != doc.end(); block = block.next()) {
|
||||||
for (QTextBlock::iterator it = block.begin(); it != block.end(); it++) {
|
for (QTextBlock::iterator it = block.begin(); it != block.end(); ++it) {
|
||||||
QTextFragment fragment = it.fragment();
|
QTextFragment fragment = it.fragment();
|
||||||
QTextCharFormat format = fragment.charFormat();
|
QTextCharFormat format = fragment.charFormat();
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
TempConfig::~TempConfig()
|
TempConfig::~TempConfig()
|
||||||
{
|
{
|
||||||
for (auto i = resetValues.constBegin(); i != resetValues.constEnd(); i++) {
|
for (auto i = resetValues.constBegin(); i != resetValues.constEnd(); ++i) {
|
||||||
switch (i.value().type()) {
|
switch (i.value().type()) {
|
||||||
case QVariant::String:
|
case QVariant::String:
|
||||||
Core()->setConfig(i.key(), i.value().toString());
|
Core()->setConfig(i.key(), i.value().toString());
|
||||||
|
@ -96,7 +96,7 @@ void UpdateWorker::showUpdateDialog(bool showDontCheckForUpdatesButton)
|
|||||||
QStandardPaths::writableLocation(QStandardPaths::HomeLocation) +
|
QStandardPaths::writableLocation(QStandardPaths::HomeLocation) +
|
||||||
QDir::separator() + getRepositoryFileName(),
|
QDir::separator() + getRepositoryFileName(),
|
||||||
QString("%1 (*.%1)").arg(getRepositeryExt()));
|
QString("%1 (*.%1)").arg(getRepositeryExt()));
|
||||||
if (fullFileName != "") {
|
if (!fullFileName.isEmpty()) {
|
||||||
QProgressDialog progressDial(tr("Downloading update..."),
|
QProgressDialog progressDial(tr("Downloading update..."),
|
||||||
tr("Cancel"),
|
tr("Cancel"),
|
||||||
0, 100);
|
0, 100);
|
||||||
|
@ -226,7 +226,7 @@ QString CutterCore::sdbGet(QString path, QString key)
|
|||||||
if (val && *val)
|
if (val && *val)
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
return QString("");
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CutterCore::sdbSet(QString path, QString key, QString val)
|
bool CutterCore::sdbSet(QString path, QString key, QString val)
|
||||||
@ -859,7 +859,7 @@ QString CutterCore::getDecompiledCodePDC(RVA addr)
|
|||||||
|
|
||||||
bool CutterCore::getR2DecAvailable()
|
bool CutterCore::getR2DecAvailable()
|
||||||
{
|
{
|
||||||
return cmd("e cmd.pdc=?").split('\n').contains(QStringLiteral("r2dec"));
|
return cmdList("e cmd.pdc=?").contains(QStringLiteral("r2dec"));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CutterCore::getDecompiledCodeR2Dec(RVA addr)
|
QString CutterCore::getDecompiledCodeR2Dec(RVA addr)
|
||||||
@ -1332,13 +1332,8 @@ bool CutterCore::isGraphEmpty()
|
|||||||
|
|
||||||
void CutterCore::getOpcodes()
|
void CutterCore::getOpcodes()
|
||||||
{
|
{
|
||||||
QString opcodes = cmd("?O");
|
this->opcodes = cmdList("?O");
|
||||||
this->opcodes = opcodes.split("\n");
|
this->regs = cmdList("drp~[1]");
|
||||||
// Remove the last empty element
|
|
||||||
this->opcodes.removeLast();
|
|
||||||
QString registers = cmd("drp~[1]");
|
|
||||||
this->regs = registers.split("\n");
|
|
||||||
this->regs.removeLast();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CutterCore::setSettings()
|
void CutterCore::setSettings()
|
||||||
@ -1587,7 +1582,7 @@ QList<SymbolDescription> CutterCore::getAllSymbols()
|
|||||||
SymbolDescription symbol;
|
SymbolDescription symbol;
|
||||||
symbol.vaddr = entry->vaddr;
|
symbol.vaddr = entry->vaddr;
|
||||||
symbol.name = QString("entry") + QString::number(n++);
|
symbol.name = QString("entry") + QString::number(n++);
|
||||||
symbol.bind = "";
|
symbol.bind.clear();
|
||||||
symbol.type = "entry";
|
symbol.type = "entry";
|
||||||
ret << symbol;
|
ret << symbol;
|
||||||
}
|
}
|
||||||
@ -2333,7 +2328,7 @@ QList<SearchDescription> CutterCore::getAllSearch(QString search_for, QString sp
|
|||||||
|
|
||||||
SearchDescription exp;
|
SearchDescription exp;
|
||||||
|
|
||||||
exp.code = QString("");
|
exp.code.clear();
|
||||||
for (const QJsonValue &value2 : searchObject[RJsonKey::opcodes].toArray()) {
|
for (const QJsonValue &value2 : searchObject[RJsonKey::opcodes].toArray()) {
|
||||||
QJsonObject gadget = value2.toObject();
|
QJsonObject gadget = value2.toObject();
|
||||||
exp.code += gadget[RJsonKey::opcode].toString() + "; ";
|
exp.code += gadget[RJsonKey::opcode].toString() + "; ";
|
||||||
|
@ -56,7 +56,7 @@ public:
|
|||||||
QString cmdRaw(const QString &str);
|
QString cmdRaw(const QString &str);
|
||||||
QJsonDocument cmdj(const char *str);
|
QJsonDocument cmdj(const char *str);
|
||||||
QJsonDocument cmdj(const QString &str) { return cmdj(str.toUtf8().constData()); }
|
QJsonDocument cmdj(const QString &str) { return cmdj(str.toUtf8().constData()); }
|
||||||
QStringList cmdList(const char *str) { return cmd(str).split('\n', QString::SkipEmptyParts); }
|
QStringList cmdList(const char *str) { return cmd(str).split(QLatin1Char('\n'), QString::SkipEmptyParts); }
|
||||||
QStringList cmdList(const QString &str) { return cmdList(str.toUtf8().constData()); }
|
QStringList cmdList(const QString &str) { return cmdList(str.toUtf8().constData()); }
|
||||||
QString cmdTask(const QString &str);
|
QString cmdTask(const QString &str);
|
||||||
QJsonDocument cmdjTask(const QString &str);
|
QJsonDocument cmdjTask(const QString &str);
|
||||||
|
@ -92,7 +92,7 @@ void AboutDialog::on_checkForUpdatesButton_clicked()
|
|||||||
connect(&updateWorker, &UpdateWorker::checkComplete, &waitDialog, &QProgressDialog::cancel);
|
connect(&updateWorker, &UpdateWorker::checkComplete, &waitDialog, &QProgressDialog::cancel);
|
||||||
connect(&updateWorker, &UpdateWorker::checkComplete,
|
connect(&updateWorker, &UpdateWorker::checkComplete,
|
||||||
[&updateWorker](const QVersionNumber &version, const QString & error) {
|
[&updateWorker](const QVersionNumber &version, const QString & error) {
|
||||||
if (error != "") {
|
if (!error.isEmpty()) {
|
||||||
QMessageBox::critical(nullptr, tr("Error!"), error);
|
QMessageBox::critical(nullptr, tr("Error!"), error);
|
||||||
} else {
|
} else {
|
||||||
if (version <= UpdateWorker::currentVersionNumber()) {
|
if (version <= UpdateWorker::currentVersionNumber()) {
|
||||||
|
@ -119,7 +119,7 @@ ProcessBeingAnalysedProxyModel::ProcessBeingAnalysedProxyModel(ProcessModel *sou
|
|||||||
QString ProcessBeingAnalysedProxyModel::processPathToFilename(const QString &path) const
|
QString ProcessBeingAnalysedProxyModel::processPathToFilename(const QString &path) const
|
||||||
{
|
{
|
||||||
// removes the arguments and gets filename from the process path
|
// removes the arguments and gets filename from the process path
|
||||||
return path.split(" ").first().split("/").last();
|
return path.section(QLatin1Char(' '), 0, 0).section(QLatin1Char('/'), -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ProcessBeingAnalysedProxyModel::filterAcceptsRow(int row, const QModelIndex &parent) const
|
bool ProcessBeingAnalysedProxyModel::filterAcceptsRow(int row, const QModelIndex &parent) const
|
||||||
@ -329,4 +329,4 @@ void AttachProcDialog::on_procBeingAnalyzedView_doubleClicked(const QModelIndex
|
|||||||
Q_UNUSED(index);
|
Q_UNUSED(index);
|
||||||
|
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
@ -55,11 +55,11 @@ void EditFunctionDialog::setStackSizeText(const QString &stackSize)
|
|||||||
ui->stackSizeLineEdit->setText(stackSize);
|
ui->stackSizeLineEdit->setText(stackSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditFunctionDialog::setCallConList(const QStringList callConList) {
|
void EditFunctionDialog::setCallConList(const QStringList &callConList) {
|
||||||
ui->callConComboBox->addItems(callConList);
|
ui->callConComboBox->addItems(callConList);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditFunctionDialog::setCallConSelected(const QString selected) {
|
void EditFunctionDialog::setCallConSelected(const QString &selected) {
|
||||||
ui->callConComboBox->setCurrentText(selected);
|
ui->callConComboBox->setCurrentText(selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@ public:
|
|||||||
void setEndAddrText(const QString &endAddr);
|
void setEndAddrText(const QString &endAddr);
|
||||||
QString getStackSizeText();
|
QString getStackSizeText();
|
||||||
void setStackSizeText(const QString &stackSize);
|
void setStackSizeText(const QString &stackSize);
|
||||||
void setCallConList(const QStringList callConList);
|
void setCallConList(const QStringList &callConList);
|
||||||
void setCallConSelected(const QString selected);
|
void setCallConSelected(const QString &selected);
|
||||||
QString getCallConSelected();
|
QString getCallConSelected();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
@ -50,7 +50,7 @@ void EditInstructionDialog::updatePreview(const QString &input)
|
|||||||
result = Core()->assemble(input).trimmed();
|
result = Core()->assemble(input).trimmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.isEmpty() || result.contains("\n")) {
|
if (result.isEmpty() || result.contains(QLatin1Char('\n'))) {
|
||||||
ui->instructionLabel->setText("Unknown Instruction");
|
ui->instructionLabel->setText("Unknown Instruction");
|
||||||
} else {
|
} else {
|
||||||
ui->instructionLabel->setText(result);
|
ui->instructionLabel->setText(result);
|
||||||
|
@ -37,7 +37,7 @@ void EditVariablesDialog::applyFields()
|
|||||||
|
|
||||||
Core()->cmdRaw(QString("afvt %1 %2").arg(desc.name).arg(ui->typeComboBox->currentText()));
|
Core()->cmdRaw(QString("afvt %1 %2").arg(desc.name).arg(ui->typeComboBox->currentText()));
|
||||||
|
|
||||||
QString newName = ui->nameEdit->text().replace(" ", "_");
|
QString newName = ui->nameEdit->text().replace(QLatin1Char(' '), QLatin1Char('_'));
|
||||||
if (newName != desc.name) {
|
if (newName != desc.name) {
|
||||||
Core()->cmdRaw(QString("afvn %1 %2").arg(newName).arg(desc.name));
|
Core()->cmdRaw(QString("afvn %1 %2").arg(newName).arg(desc.name));
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ QString LinkTypeDialog::findLinkedType(RVA address)
|
|||||||
|
|
||||||
// Extract the given type from returned data
|
// Extract the given type from returned data
|
||||||
// TODO: Implement "tlsj" in radare2 or some other function to directly get linked type
|
// TODO: Implement "tlsj" in radare2 or some other function to directly get linked type
|
||||||
QString s = ret.split("\n").first();
|
QString s = ret.section(QLatin1Char('\n'), 0, 0);
|
||||||
return s.mid(1, s.size() - 2);
|
return s.mid(1, s.size() - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,9 +267,7 @@ bool NewFileDialog::fillRecentFilesList()
|
|||||||
// Get stored files
|
// Get stored files
|
||||||
|
|
||||||
// Remove all but the file name
|
// Remove all but the file name
|
||||||
const QString sep = QDir::separator();
|
const QString name = file.section(QDir::separator(), -1);
|
||||||
const QStringList name_list = file.split(sep);
|
|
||||||
const QString name = name_list.last();
|
|
||||||
|
|
||||||
// Get file info
|
// Get file info
|
||||||
QFileInfo info(file);
|
QFileInfo info(file);
|
||||||
|
@ -86,17 +86,12 @@ void XrefsDialog::on_toTreeWidget_itemDoubleClicked(QTreeWidgetItem *item, int c
|
|||||||
|
|
||||||
QString XrefsDialog::normalizeAddr(const QString &addr) const
|
QString XrefsDialog::normalizeAddr(const QString &addr) const
|
||||||
{
|
{
|
||||||
QString r = addr;
|
QString ret = addr;
|
||||||
QString base = addr.split("0x")[1].trimmed();
|
if (addr.length() < 10) {
|
||||||
int len = base.length();
|
ret = ret.mid(3).rightJustified(8, QLatin1Char('0'));
|
||||||
if (len < 8) {
|
ret.prepend(QLatin1Literal("0x"));
|
||||||
int padding = 8 - len;
|
|
||||||
QString zero = "0";
|
|
||||||
QString zeroes = zero.repeated(padding);
|
|
||||||
r = "0x" + zeroes + base;
|
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void XrefsDialog::setupPreviewFont()
|
void XrefsDialog::setupPreviewFont()
|
||||||
@ -196,7 +191,7 @@ QString XrefsDialog::xrefTypeString(const QString &type)
|
|||||||
case R_ANAL_REF_TYPE_DATA:
|
case R_ANAL_REF_TYPE_DATA:
|
||||||
return QString("Data");
|
return QString("Data");
|
||||||
case R_ANAL_REF_TYPE_NULL:
|
case R_ANAL_REF_TYPE_NULL:
|
||||||
return QString("");
|
return QString();
|
||||||
case R_ANAL_REF_TYPE_STRING:
|
case R_ANAL_REF_TYPE_STRING:
|
||||||
return QString("String");
|
return QString("String");
|
||||||
default:
|
default:
|
||||||
|
@ -290,8 +290,8 @@ void DisassemblyContextMenu::aboutToShowSlot()
|
|||||||
|
|
||||||
// Get the possible offsets using the "tas" command
|
// Get the possible offsets using the "tas" command
|
||||||
// TODO: add tasj command to radare2 and then use it here
|
// TODO: add tasj command to radare2 and then use it here
|
||||||
QString ret = Core()->cmd("tas " + memDisp.toString());
|
QStringList ret = Core()->cmdList("tas " + memDisp.toString());
|
||||||
for (QString val: ret.split("\n")) {
|
for (const QString &val : ret) {
|
||||||
if (val.isEmpty()) {
|
if (val.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -111,8 +111,7 @@ void PluginManager::loadPythonPlugins(const QDir &directory)
|
|||||||
}
|
}
|
||||||
QString moduleName;
|
QString moduleName;
|
||||||
if (fileName.endsWith(".py")) {
|
if (fileName.endsWith(".py")) {
|
||||||
QStringList l = fileName.split(".py");
|
moduleName = fileName.chopped(3);
|
||||||
moduleName = l[0];
|
|
||||||
} else {
|
} else {
|
||||||
moduleName = fileName;
|
moduleName = fileName;
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ void BreakpointWidget::addBreakpointDialog()
|
|||||||
if (dialog.exec()) {
|
if (dialog.exec()) {
|
||||||
QString bps = dialog.getBreakpoints();
|
QString bps = dialog.getBreakpoints();
|
||||||
if (!bps.isEmpty()) {
|
if (!bps.isEmpty()) {
|
||||||
QStringList bpList = bps.split(' ', QString::SkipEmptyParts);
|
QStringList bpList = bps.split(QLatin1Char(' '), QString::SkipEmptyParts);
|
||||||
for (const QString &bp : bpList) {
|
for (const QString &bp : bpList) {
|
||||||
Core()->toggleBreakpoint(bp);
|
Core()->toggleBreakpoint(bp);
|
||||||
}
|
}
|
||||||
|
@ -430,7 +430,7 @@ void ColorSchemePrefWidget::apply()
|
|||||||
} else {
|
} else {
|
||||||
scheme += "ec ";
|
scheme += "ec ";
|
||||||
}
|
}
|
||||||
scheme += curr.optionName + " rgb:" + curr.color.name().remove("#").toLower() + "\n";
|
scheme += curr.optionName + " rgb:" + curr.color.name().remove(QLatin1Char('#')).toLower() + "\n";
|
||||||
}
|
}
|
||||||
ColorSchemeFileWorker().save(scheme, Config()->getColorTheme());
|
ColorSchemeFileWorker().save(scheme, Config()->getColorTheme());
|
||||||
Config()->setColorTheme(Config()->getColorTheme());
|
Config()->setColorTheme(Config()->getColorTheme());
|
||||||
|
@ -56,7 +56,7 @@ void Dashboard::updateContents()
|
|||||||
this->ui->bitsEdit->setText(QString::number(item2["bits"].toDouble()));
|
this->ui->bitsEdit->setText(QString::number(item2["bits"].toDouble()));
|
||||||
|
|
||||||
if (!item2["relro"].isUndefined()) {
|
if (!item2["relro"].isUndefined()) {
|
||||||
QString relro = item2["relro"].toString().split(" ").at(0);
|
QString relro = item2["relro"].toString().section(QLatin1Char(' '), 0, 0);
|
||||||
relro[0] = relro[0].toUpper();
|
relro[0] = relro[0].toUpper();
|
||||||
this->ui->relroEdit->setText(relro);
|
this->ui->relroEdit->setText(relro);
|
||||||
}
|
}
|
||||||
@ -110,11 +110,10 @@ void Dashboard::updateContents()
|
|||||||
ui->md5Edit->setText(md5);
|
ui->md5Edit->setText(md5);
|
||||||
ui->sha1Edit->setText(sha1);
|
ui->sha1Edit->setText(sha1);
|
||||||
|
|
||||||
QString libs = Core()->cmd("il");
|
QStringList libs = Core()->cmdList("il");
|
||||||
QStringList lines = libs.split("\n", QString::SkipEmptyParts);
|
if (!libs.isEmpty()) {
|
||||||
if (!lines.isEmpty()) {
|
libs.removeFirst();
|
||||||
lines.removeFirst();
|
libs.removeLast();
|
||||||
lines.removeLast();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// dunno: why not label->setText(lines.join("\n")?
|
// dunno: why not label->setText(lines.join("\n")?
|
||||||
@ -130,7 +129,7 @@ void Dashboard::updateContents()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const QString &lib : lines) {
|
for (const QString &lib : libs) {
|
||||||
QLabel *label = new QLabel(this);
|
QLabel *label = new QLabel(this);
|
||||||
label->setText(lib);
|
label->setText(lib);
|
||||||
label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||||
|
@ -117,7 +117,7 @@ DebugActions::DebugActions(QToolBar *toolBar, MainWindow *main) :
|
|||||||
connect(actionStep, &QAction::triggered, Core(), &CutterCore::stepDebug);
|
connect(actionStep, &QAction::triggered, Core(), &CutterCore::stepDebug);
|
||||||
connect(actionStart, &QAction::triggered, [ = ]() {
|
connect(actionStart, &QAction::triggered, [ = ]() {
|
||||||
// check if file is executable before starting debug
|
// check if file is executable before starting debug
|
||||||
QString filename = Core()->getConfig("file.path").split(" ").first();
|
QString filename = Core()->getConfig("file.path").section(QLatin1Char(' '), 0, 0);
|
||||||
QFileInfo info(filename);
|
QFileInfo info(filename);
|
||||||
if (!Core()->currentlyDebugging && !info.isExecutable()) {
|
if (!Core()->currentlyDebugging && !info.isExecutable()) {
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
|
@ -181,8 +181,10 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
case Qt::DecorationRole:
|
case Qt::DecorationRole:
|
||||||
if (importAddresses->contains(function.offset) &&
|
if (importAddresses->contains(function.offset) &&
|
||||||
(nested ? false : index.column() == ImportColumn))
|
(nested ? false : index.column() == ImportColumn)) {
|
||||||
return QIcon(":/img/icons/import_light.svg");
|
const static QIcon importIcon(":/img/icons/import_light.svg");
|
||||||
|
return importIcon;
|
||||||
|
}
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
case Qt::FontRole:
|
case Qt::FontRole:
|
||||||
@ -225,7 +227,7 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList &summary = Core()->cmd(QString("pdsf @ %1").arg(function.offset)).split("\n", QString::SkipEmptyParts);
|
const QStringList &summary = Core()->cmdList(QString("pdsf @ %1").arg(function.offset));
|
||||||
|
|
||||||
const QFont &fnt = Config()->getFont();
|
const QFont &fnt = Config()->getFont();
|
||||||
QFontMetrics fm{ fnt };
|
QFontMetrics fm{ fnt };
|
||||||
@ -252,7 +254,7 @@ QVariant FunctionModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
if (!highlights.isEmpty()) {
|
if (!highlights.isEmpty()) {
|
||||||
toolTipContent += tr("<div><strong>Highlights</strong>:<br>%1</div>")
|
toolTipContent += tr("<div><strong>Highlights</strong>:<br>%1</div>")
|
||||||
.arg(highlights.join("\n").toHtmlEscaped().replace("\n", "<br>"));
|
.arg(highlights.join(QLatin1Char('\n')).toHtmlEscaped().replace(QLatin1Char('\n'), "<br>"));
|
||||||
}
|
}
|
||||||
toolTipContent += "</div></html>";
|
toolTipContent += "</div></html>";
|
||||||
return toolTipContent;
|
return toolTipContent;
|
||||||
|
@ -14,7 +14,7 @@ SdbWidget::SdbWidget(MainWindow *main, QAction *action) :
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
path = "";
|
path.clear();
|
||||||
|
|
||||||
connect(Core(), SIGNAL(refreshAll()), this, SLOT(reload()));
|
connect(Core(), SIGNAL(refreshAll()), this, SLOT(reload()));
|
||||||
reload(nullptr);
|
reload(nullptr);
|
||||||
@ -64,19 +64,19 @@ void SdbWidget::on_treeWidget_itemDoubleClicked(QTreeWidgetItem *item, int colum
|
|||||||
|
|
||||||
if (column == 0) {
|
if (column == 0) {
|
||||||
if (item->text(0) == "../") {
|
if (item->text(0) == "../") {
|
||||||
int idx = path.lastIndexOf("/");
|
int idx = path.lastIndexOf(QLatin1Char('/'));
|
||||||
if (idx != -1) {
|
if (idx != -1) {
|
||||||
newpath = path.mid(0, idx);
|
newpath = path.mid(0, idx);
|
||||||
} else {
|
} else {
|
||||||
newpath = "";
|
newpath.clear();
|
||||||
}
|
}
|
||||||
reload(newpath);
|
reload(newpath);
|
||||||
|
|
||||||
} else if (item->text(0).indexOf("/") != -1) {
|
} else if (item->text(0).indexOf(QLatin1Char('/')) != -1) {
|
||||||
if (path != "") {
|
if (!path.isEmpty()) {
|
||||||
newpath = path + "/" + item->text(0).replace("/", "");
|
newpath = path + "/" + item->text(0).remove(QLatin1Char('/'));
|
||||||
} else {
|
} else {
|
||||||
newpath = path + item->text(0).replace("/", "");
|
newpath = path + item->text(0).remove(QLatin1Char('/'));
|
||||||
}
|
}
|
||||||
// enter directory
|
// enter directory
|
||||||
reload(newpath);
|
reload(newpath);
|
||||||
|
@ -420,12 +420,12 @@ void AddrDockScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
|
|
||||||
RVA AddrDockScene::getAddrFromPos(int posY, bool seek)
|
RVA AddrDockScene::getAddrFromPos(int posY, bool seek)
|
||||||
{
|
{
|
||||||
QHash<QString, int>::const_iterator i = namePosYMap.constBegin();
|
QHash<QString, int>::const_iterator it;
|
||||||
QHash<QString, RVA> addrMap = seek ? seekAddrMap : nameAddrMap;
|
QHash<QString, RVA> addrMap = seek ? seekAddrMap : nameAddrMap;
|
||||||
QHash<QString, int> addrSizeMap = seek ? seekAddrSizeMap : nameAddrSizeMap;
|
QHash<QString, int> addrSizeMap = seek ? seekAddrSizeMap : nameAddrSizeMap;
|
||||||
while (i != namePosYMap.constEnd()) {
|
for (it = namePosYMap.constBegin(); it != namePosYMap.constEnd(); ++it) {
|
||||||
QString name = i.key();
|
QString name = it.key();
|
||||||
int y = i.value();
|
int y = it.value();
|
||||||
int h = nameHeightMap[name];
|
int h = nameHeightMap[name];
|
||||||
if (posY >= y && y + h >= posY) {
|
if (posY >= y && y + h >= posY) {
|
||||||
if (h == 0) {
|
if (h == 0) {
|
||||||
@ -433,7 +433,6 @@ RVA AddrDockScene::getAddrFromPos(int posY, bool seek)
|
|||||||
}
|
}
|
||||||
return addrMap[name] + (float)addrSizeMap[name] * ((float)(posY - y) / (float)h);
|
return addrMap[name] + (float)addrSizeMap[name] * ((float)(posY - y) / (float)h);
|
||||||
}
|
}
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -456,17 +455,19 @@ void RawAddrDock::updateDock()
|
|||||||
int y = 0;
|
int y = 0;
|
||||||
int validMinSize = getValidMinSize();
|
int validMinSize = getValidMinSize();
|
||||||
proxyModel->sort(2, Qt::AscendingOrder);
|
proxyModel->sort(2, Qt::AscendingOrder);
|
||||||
for (int i = 0; i < proxyModel->rowCount(); i++) {
|
for (int i = 0; i < proxyModel->rowCount(); ++i) {
|
||||||
QModelIndex idx = proxyModel->index(i, 0);
|
QModelIndex idx = proxyModel->index(i, 0);
|
||||||
QString name = idx.data(SectionsModel::SectionDescriptionRole).value<SectionDescription>().name;
|
auto desc = idx.data(SectionsModel::SectionDescriptionRole).value<SectionDescription>();
|
||||||
|
|
||||||
RVA vaddr = idx.data(SectionsModel::SectionDescriptionRole).value<SectionDescription>().vaddr;
|
QString name = desc.name;
|
||||||
int vsize = idx.data(SectionsModel::SectionDescriptionRole).value<SectionDescription>().vsize;
|
|
||||||
|
RVA vaddr = desc.vaddr;
|
||||||
|
int vsize = desc.vsize;
|
||||||
addrDockScene->seekAddrMap[name] = vaddr;
|
addrDockScene->seekAddrMap[name] = vaddr;
|
||||||
addrDockScene->seekAddrSizeMap[name] = vsize;
|
addrDockScene->seekAddrSizeMap[name] = vsize;
|
||||||
|
|
||||||
RVA addr = idx.data(SectionsModel::SectionDescriptionRole).value<SectionDescription>().paddr;
|
RVA addr = desc.paddr;
|
||||||
int size = idx.data(SectionsModel::SectionDescriptionRole).value<SectionDescription>().size;
|
int size = desc.size;
|
||||||
addrDockScene->nameAddrMap[name] = addr;
|
addrDockScene->nameAddrMap[name] = addr;
|
||||||
addrDockScene->nameAddrSizeMap[name] = size;
|
addrDockScene->nameAddrSizeMap[name] = size;
|
||||||
|
|
||||||
|
@ -297,7 +297,7 @@ QString VisualNavbar::toolTipForAddress(RVA address)
|
|||||||
bool first = true;
|
bool first = true;
|
||||||
for (const QString §ion : sections) {
|
for (const QString §ion : sections) {
|
||||||
if (!first) {
|
if (!first) {
|
||||||
ret += "\n";
|
ret.append(QLatin1Char('\n'));
|
||||||
} else {
|
} else {
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user