Skip to content

Commit 3504cfa

Browse files
committed
Fixed command-line arguments parsing
1 parent a7938d6 commit 3504cfa

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/fhex.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ bool Fhex::loadFile(QString path) {
368368
this->setWindowTitle("Fhex - " + QString(this->hexEditor->getCurrentPath().c_str()));
369369
loadBinChart();
370370
} else {
371-
this->statusBar.setText("Error while opening " + QString(this->hexEditor->getCurrentPath().c_str()));
371+
this->statusBar.setText("Error while opening " + path);
372372
}
373373
return res;
374374
}

src/main.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ int main(int argc, char *argv[])
99
QString filepath = "";
1010

1111
if (argc > 1) {
12-
for (int i = 0; i < argc; i++) {
13-
if (QFile::exists(argv[i])) {
14-
filepath = argv[i];
12+
for (int i = 1; i < argc; i++) {
13+
filepath = argv[i];
14+
if (QFile::exists(filepath)) {
1515
Fhex *window = new Fhex(nullptr, &a, filepath);
1616
window->show();
17+
} else {
18+
cout << "Error: Cannot load file '" << filepath.toStdString() << "'" << endl;
19+
return 1;
1720
}
1821
}
1922
} else {

0 commit comments

Comments
 (0)