From f636ee22460a3e81f2ca7437d9ad11618554339d Mon Sep 17 00:00:00 2001 From: Liu Zhangjian Date: Tue, 5 Nov 2024 19:54:08 +0800 Subject: [PATCH] fix: Open settings dialog the program crash as title Log: fix issue --- src/plugins/cxx/cmake/settings/compileroptionwidget.cpp | 4 ++++ src/plugins/cxx/cmake/settings/debuggeroptionwidget.cpp | 2 ++ src/plugins/cxx/cmake/settings/tooloptionwidget.cpp | 2 ++ src/plugins/python/python/option/interpreterwidget.cpp | 4 +++- 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/plugins/cxx/cmake/settings/compileroptionwidget.cpp b/src/plugins/cxx/cmake/settings/compileroptionwidget.cpp index 6f234e9e7..65dd9b149 100644 --- a/src/plugins/cxx/cmake/settings/compileroptionwidget.cpp +++ b/src/plugins/cxx/cmake/settings/compileroptionwidget.cpp @@ -70,11 +70,15 @@ void CompilerOptionWidgetPrivate::initCompilers() const auto &data = toolCD.getToolChanins(); ToolChainData::Params cParams = data.value(kCCompilers); for (const auto ¶m : cParams) { + if (param.name.isEmpty() || param.path.isEmpty()) + continue; appendCompiler(param.name, param.path, DetectedCCompiler); } ToolChainData::Params cxxParams = data.value(kCXXCompilers); for (const auto ¶m : cxxParams) { + if (param.name.isEmpty() || param.path.isEmpty()) + continue; appendCompiler(param.name, param.path, DetectedCXXCompiler); } } diff --git a/src/plugins/cxx/cmake/settings/debuggeroptionwidget.cpp b/src/plugins/cxx/cmake/settings/debuggeroptionwidget.cpp index 9247a205c..ef695e981 100644 --- a/src/plugins/cxx/cmake/settings/debuggeroptionwidget.cpp +++ b/src/plugins/cxx/cmake/settings/debuggeroptionwidget.cpp @@ -55,6 +55,8 @@ void DebuggerOptionWidgetPrivate::initDebuggers() const auto &data = toolCD.getToolChanins(); ToolChainData::Params params = data.value(kCCXXDebuggers); for (const auto ¶m : params) { + if (param.name.isEmpty() || param.path.isEmpty()) + continue; appendDebugger(param.name, param.path, Detected); } } diff --git a/src/plugins/cxx/cmake/settings/tooloptionwidget.cpp b/src/plugins/cxx/cmake/settings/tooloptionwidget.cpp index d8d6b4daf..a013e250f 100644 --- a/src/plugins/cxx/cmake/settings/tooloptionwidget.cpp +++ b/src/plugins/cxx/cmake/settings/tooloptionwidget.cpp @@ -55,6 +55,8 @@ void ToolOptionWidgetPrivate::initTools() const auto &data = toolCD.getToolChanins(); ToolChainData::Params params = data.value(kCCXXBuildSystems); for (const auto ¶m : params) { + if (param.name.isEmpty() || param.path.isEmpty()) + continue; appendTool(param.name, param.path, Detected); } } diff --git a/src/plugins/python/python/option/interpreterwidget.cpp b/src/plugins/python/python/option/interpreterwidget.cpp index 9a746d89b..797744b4a 100644 --- a/src/plugins/python/python/option/interpreterwidget.cpp +++ b/src/plugins/python/python/option/interpreterwidget.cpp @@ -120,6 +120,7 @@ class InterpreterWidgetPrivate InterpreterModel *model = nullptr; QSharedPointer toolChainData; + QMutex mutex; }; InterpreterWidget::InterpreterWidget(QWidget *parent) @@ -264,7 +265,7 @@ void InterpreterWidget::findPackages(const QString &cmd) { QProcess process; connect(&process, static_cast(&QProcess::finished), - [&](int exitcode, QProcess::ExitStatus exitStatus) { + &process, [&](int exitcode, QProcess::ExitStatus exitStatus) { if (0 == exitcode && exitStatus == QProcess::ExitStatus::NormalExit) { QString output = QString(process.readAllStandardOutput()); @@ -282,6 +283,7 @@ void InterpreterWidget::findPackages(const QString &cmd) dataVector.append(QPair(sublist.at(0).trimmed(), sublist.at(1).trimmed())); } } + QMutexLocker lk(&d->mutex); d->model->setCustomData(dataVector); } else { qInfo() << "Error" << exitcode << exitStatus;