From a8eb924a2a662db6c2264a2496269621aaea1857 Mon Sep 17 00:00:00 2001 From: hjk <hjk@theqtcompany.com> Date: Tue, 31 May 2016 16:09:48 +0200 Subject: [PATCH] Debugger: Dissolve AnalyzerUtils::logToIssuesPane() If the Error + popup combo is generic it should live in TaskHub. If it is not, end user code should decide when to popup. Not an intermediate level. Change-Id: I195ba8c17c5cc192ff9762ed6f45629143bcbb35 Reviewed-by: Christian Stenger <christian.stenger@qt.io> --- .../clangstaticanalyzerruncontrol.cpp | 17 ++++++++++------- src/plugins/debugger/analyzer/analyzerutils.cpp | 11 ----------- src/plugins/debugger/analyzer/analyzerutils.h | 4 ---- src/plugins/valgrind/callgrindtool.cpp | 6 ++++-- src/plugins/valgrind/memchecktool.cpp | 11 +++++++---- 5 files changed, 21 insertions(+), 28 deletions(-) diff --git a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp index 223a0ee9813..c286a22c017 100644 --- a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp +++ b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp @@ -30,7 +30,7 @@ #include "clangstaticanalyzersettings.h" #include "clangstaticanalyzerutils.h" -#include <debugger/analyzer/analyzerutils.h> +#include <debugger/analyzer/analyzerconstants.h> #include <clangcodemodel/clangutils.h> @@ -419,7 +419,8 @@ void ClangStaticAnalyzerRunControl::start() const QString errorMessage = tr("Clang Static Analyzer: Invalid executable \"%1\", stop.") .arg(executable); appendMessage(errorMessage + QLatin1Char('\n'), Utils::ErrorMessageFormat); - AnalyzerUtils::logToIssuesPane(Task::Error, errorMessage); + TaskHub::addTask(Task::Error, errorMessage, Debugger::Constants::ANALYZERTASK_ID); + TaskHub::requestPopup(); emit finished(); return; } @@ -432,7 +433,8 @@ void ClangStaticAnalyzerRunControl::start() const QString errorMessage = tr("Clang Static Analyzer: Failed to create temporary dir, stop."); appendMessage(errorMessage + QLatin1Char('\n'), Utils::ErrorMessageFormat); - AnalyzerUtils::logToIssuesPane(Task::Error, errorMessage); + TaskHub::addTask(Task::Error, errorMessage, Debugger::Constants::ANALYZERTASK_ID); + TaskHub::requestPopup(); emit finished(); return; } @@ -571,8 +573,8 @@ void ClangStaticAnalyzerRunControl::onRunnerFinishedWithFailure(const QString &e + QLatin1Char('\n') , Utils::StdErrFormat); appendMessage(errorDetails, Utils::StdErrFormat); - AnalyzerUtils::logToIssuesPane(Task::Warning, errorMessage); - AnalyzerUtils::logToIssuesPane(Task::Warning, errorDetails); + TaskHub::addTask(Task::Warning, errorMessage, Debugger::Constants::ANALYZERTASK_ID); + TaskHub::addTask(Task::Warning, errorDetails, Debugger::Constants::ANALYZERTASK_ID); handleFinished(); } @@ -605,8 +607,9 @@ void ClangStaticAnalyzerRunControl::finalize() Utils::NormalMessageFormat); if (m_filesNotAnalyzed != 0) { - AnalyzerUtils::logToIssuesPane(Task::Error, - tr("Clang Static Analyzer: Not all files could be analyzed.")); + QString msg = tr("Clang Static Analyzer: Not all files could be analyzed."); + TaskHub::addTask(Task::Error, msg, Debugger::Constants::ANALYZERTASK_ID); + TaskHub::requestPopup(); } m_progress.reportFinished(); diff --git a/src/plugins/debugger/analyzer/analyzerutils.cpp b/src/plugins/debugger/analyzer/analyzerutils.cpp index c38e54bb454..21146372ecb 100644 --- a/src/plugins/debugger/analyzer/analyzerutils.cpp +++ b/src/plugins/debugger/analyzer/analyzerutils.cpp @@ -25,10 +25,7 @@ #include "analyzerutils.h" -#include "analyzerconstants.h" - #include <cpptools/cppmodelmanager.h> -#include <projectexplorer/taskhub.h> #include <texteditor/texteditor.h> #include <texteditor/textdocument.h> @@ -39,7 +36,6 @@ #include <QTextCursor> -using namespace Debugger; using namespace Core; using namespace ProjectExplorer; @@ -89,10 +85,3 @@ CPlusPlus::Symbol *AnalyzerUtils::findSymbolUnderCursor() const CPlusPlus::LookupItem &lookupItem = lookupItems.first(); // ### TODO: select best candidate. return lookupItem.declaration(); } - -void AnalyzerUtils::logToIssuesPane(Task::TaskType type, const QString &message) -{ - TaskHub::addTask(type, message, Debugger::Constants::ANALYZERTASK_ID); - if (type == Task::Error) - TaskHub::requestPopup(); -} diff --git a/src/plugins/debugger/analyzer/analyzerutils.h b/src/plugins/debugger/analyzer/analyzerutils.h index 1c5327d4fe9..f38fdf80af1 100644 --- a/src/plugins/debugger/analyzer/analyzerutils.h +++ b/src/plugins/debugger/analyzer/analyzerutils.h @@ -27,13 +27,9 @@ #include <debugger/debugger_global.h> -#include <projectexplorer/task.h> - namespace CPlusPlus { class Symbol; } namespace AnalyzerUtils { DEBUGGER_EXPORT CPlusPlus::Symbol *findSymbolUnderCursor(); - DEBUGGER_EXPORT void logToIssuesPane(ProjectExplorer::Task::TaskType type, - const QString &message); } diff --git a/src/plugins/valgrind/callgrindtool.cpp b/src/plugins/valgrind/callgrindtool.cpp index 28a3dd52e8e..6d708997d6b 100644 --- a/src/plugins/valgrind/callgrindtool.cpp +++ b/src/plugins/valgrind/callgrindtool.cpp @@ -78,6 +78,7 @@ #include <projectexplorer/projectexplorericons.h> #include <projectexplorer/projecttree.h> #include <projectexplorer/session.h> +#include <projectexplorer/taskhub.h> #include <utils/fancymainwindow.h> #include <utils/qtcassert.h> @@ -909,8 +910,9 @@ void CallgrindTool::loadExternalLogFile() QFile logFile(filePath); if (!logFile.open(QIODevice::ReadOnly | QIODevice::Text)) { - AnalyzerUtils::logToIssuesPane(Task::Error, - tr("Callgrind: Failed to open file for reading: %1").arg(filePath)); + QString msg = tr("Callgrind: Failed to open file for reading: %1").arg(filePath); + TaskHub::addTask(Task::Error, msg, Debugger::Constants::ANALYZERTASK_ID); + TaskHub::requestPopup(); return; } diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index ded4867fcec..8e4ea368782 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -53,6 +53,7 @@ #include <projectexplorer/project.h> #include <projectexplorer/runconfiguration.h> #include <projectexplorer/target.h> +#include <projectexplorer/taskhub.h> #include <projectexplorer/session.h> #include <projectexplorer/buildconfiguration.h> @@ -592,8 +593,9 @@ void MemcheckTool::loadExternalXmlLogFile() QFile *logFile = new QFile(filePath); if (!logFile->open(QIODevice::ReadOnly | QIODevice::Text)) { delete logFile; - AnalyzerUtils::logToIssuesPane(Task::Error, - tr("Memcheck: Failed to open file for reading: %1").arg(filePath)); + QString msg = tr("Memcheck: Failed to open file for reading: %1").arg(filePath); + TaskHub::addTask(Task::Error, msg, Debugger::Constants::ANALYZERTASK_ID); + TaskHub::requestPopup(); return; } @@ -623,8 +625,9 @@ void MemcheckTool::parserError(const Error &error) void MemcheckTool::internalParserError(const QString &errorString) { - AnalyzerUtils::logToIssuesPane(Task::Error, - tr("Memcheck: Error occurred parsing Valgrind output: %1").arg(errorString)); + QString msg = tr("Memcheck: Error occurred parsing Valgrind output: %1").arg(errorString); + TaskHub::addTask(Task::Error, msg, Debugger::Constants::ANALYZERTASK_ID); + TaskHub::requestPopup(); } void MemcheckTool::clearErrorView() -- GitLab