summaryrefslogtreecommitdiff
path: root/plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.cpp')
-rw-r--r--plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.cpp b/plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.cpp
index 6bc81cac64..58fa6d0c47 100644
--- a/plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.cpp
+++ b/plugins/clangstaticanalyzer/clangstaticanalyzerconfigwidget.cpp
@@ -40,11 +40,31 @@ ClangStaticAnalyzerConfigWidget::ClangStaticAnalyzerConfigWidget(
chooser->setHistoryCompleter(QLatin1String("ClangStaticAnalyzer.ClangCommand.History"));
chooser->setPromptDialogTitle(tr("Clang Command"));
const auto validator = [chooser](Utils::FancyLineEdit *edit, QString *errorMessage) {
- return chooser->defaultValidationFunction()(edit, errorMessage)
- && isClangExecutableUsable(chooser->fileName().toString(), errorMessage);
+ const QString currentFilePath = chooser->fileName().toString();
+ Utils::PathChooser pc;
+ Utils::PathChooser *helperPathChooser;
+ if (currentFilePath.isEmpty()) {
+ pc.setExpectedKind(chooser->expectedKind());
+ pc.setPath(edit->placeholderText());
+ helperPathChooser = &pc;
+ } else {
+ helperPathChooser = chooser;
+ }
+ return chooser->defaultValidationFunction()(helperPathChooser->lineEdit(), errorMessage)
+ && isClangExecutableUsable(helperPathChooser->fileName().toString(), errorMessage);
};
chooser->setValidationFunction(validator);
- chooser->setPath(settings->clangExecutable());
+ bool clangExeIsSet;
+ const QString clangExe = settings->clangExecutable(&clangExeIsSet);
+ chooser->lineEdit()->setPlaceholderText(settings->defaultClangExecutable());
+ if (clangExeIsSet) {
+ chooser->setPath(clangExe);
+ } else {
+ // Setting an empty string does not trigger the validator, as that is the initial value
+ // in the line edit.
+ chooser->setPath(QLatin1String(" "));
+ chooser->lineEdit()->clear();
+ }
connect(m_ui->clangExecutableChooser, &Utils::PathChooser::changed,
[settings](const QString &path) { settings->setClangExecutable(path); });