Skip to content

Commit 0886ef9

Browse files
nemaakhileshdanmar
authored andcommitted
Fixed cppcheck-opensource#3192 (GUI: Allow opening project file without extra parameter from CLI)
1 parent 34449ae commit 0886ef9

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

gui/mainwindow.cpp

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -214,21 +214,26 @@ MainWindow::~MainWindow()
214214

215215
void MainWindow::HandleCLIParams(const QStringList &params)
216216
{
217+
int index;
217218
if (params.contains("-p")) {
218-
const int ind = params.indexOf("-p");
219-
if ((ind + 1) < params.length())
220-
LoadProjectFile(params[ind + 1]);
219+
index = params.indexOf("-p");
220+
if ((index + 1) < params.length())
221+
LoadProjectFile(params[index + 1]);
222+
} else if ((index = params.indexOf(QRegExp(".*\\.cppcheck$", Qt::CaseInsensitive), 0)) >= 0 && index < params.length() && QFile(params[index]).exists()) {
223+
LoadProjectFile(params[index]);
224+
} else if ((index = params.indexOf(QRegExp(".*\\.xml$", Qt::CaseInsensitive), 0)) >= 0 && index < params.length() && QFile(params[index]).exists()) {
225+
LoadResults(params[index]);
221226
} else if (params.contains("-l")) {
222227
QString logFile;
223-
const int ind = params.indexOf("-l");
224-
if ((ind + 1) < params.length())
225-
logFile = params[ind + 1];
228+
index = params.indexOf("-l");
229+
if ((index + 1) < params.length())
230+
logFile = params[index + 1];
226231

227232
if (params.contains("-d")) {
228233
QString checkedDir;
229-
const int ind = params.indexOf("-d");
230-
if ((ind + 1) < params.length())
231-
checkedDir = params[ind + 1];
234+
index = params.indexOf("-d");
235+
if ((index + 1) < params.length())
236+
checkedDir = params[index + 1];
232237

233238
LoadResults(logFile, checkedDir);
234239
} else {

0 commit comments

Comments
 (0)