Skip to content

Commit

Permalink
add cmd argument for source code search path
Browse files Browse the repository at this point in the history
  • Loading branch information
lievenhey authored and milianw committed Aug 3, 2023
1 parent 35871ad commit 4d8f993
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ int main(int argc, char** argv)

QCommandLineOption sourcePath(
QStringLiteral("sourcePaths"),
QCoreApplication::translate("main", "Colon separated list of extra paths to the source code."),
QCoreApplication::translate("main", "Colon separated list of search paths for the source code."),
QStringLiteral("paths"));
parser.addOption(sourcePath);

Expand Down
10 changes: 6 additions & 4 deletions src/models/sourcecodemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "highlighter.hpp"
#include "search.h"
#include <climits>

Q_LOGGING_CATEGORY(sourcecodemodel, "hotspot.sourcecodemodel", QtWarningMsg)

Expand Down Expand Up @@ -50,13 +51,14 @@ void SourceCodeModel::setDisassembly(const DisassemblyOutput& disassemblyOutput,
m_inclusiveCosts = {};
m_numLines = 0;

if (disassemblyOutput.mainSourceFileName.isEmpty())
if (disassemblyOutput.mainSourceFileName.isEmpty()) {
return;
}

QFile file(m_sysroot + QDir::separator() + disassemblyOutput.realSourceFileName);

if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
QFile file(disassemblyOutput.realSourceFileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
return;
}

QString sourceCode = QString::fromUtf8(file.readAll());

Expand Down
2 changes: 1 addition & 1 deletion src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ void Settings::loadFromFile()
sharedConfig->group("PathSettings").writeEntry("userPaths", this->userPaths());
sharedConfig->group("PathSettings").writeEntry("systemPaths", this->systemPaths());
});
m_sourceCodePaths = sharedConfig->group("PathSettings").readEntry("sourceCodePaths", QString());
setSourceCodePaths(sharedConfig->group("PathSettings").readEntry("sourceCodePaths", QString()));
connect(this, &Settings::sourceCodePathsChanged, this, [sharedConfig](const QString& paths) {
sharedConfig->group("PathSettings").writeEntry("sourceCodePaths", paths);
});
Expand Down

0 comments on commit 4d8f993

Please sign in to comment.