Skip to content

Commit dfb18ef

Browse files
committed
Fix cppcheck-opensource#378 (GUI doesn't start application if path contains spaces)
In Windows we must surround paths including spaces with quotation marks. This patch fixes application path when it is read from Browse-dialog.
1 parent 9cbf9e7 commit dfb18ef

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

gui/applicationdialog.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ ApplicationDialog::~ApplicationDialog()
8282
//dtor
8383
}
8484

85-
8685
void ApplicationDialog::Browse()
8786
{
8887
QFileDialog dialog(this);
@@ -93,7 +92,18 @@ void ApplicationDialog::Browse()
9392
QStringList list = dialog.selectedFiles();
9493
if (list.size() > 0)
9594
{
96-
mPath->setText(QDir::toNativeSeparators(list[0]));
95+
QString path(QDir::toNativeSeparators(list[0]));
96+
97+
// In Windows we must surround paths including spaces with quotation marks.
98+
#ifdef Q_WS_WIN
99+
if (path.indexOf(" ") > -1)
100+
{
101+
path.insert(0, "\"");
102+
path.append("\"");
103+
}
104+
#endif // Q_WS_WIN
105+
106+
mPath->setText(path);
97107
}
98108
}
99109
}

0 commit comments

Comments
 (0)