From ca660c796cba7af467c75608f30870411f690574 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 13 Jul 2017 16:41:13 +0200 Subject: ClangStaticAnalyzer: Fix rampdown Stop button wasn't doing anything. Change-Id: I84f3d5dccdbdd5a7a800ecc86c3938b01eaa0550 Reviewed-by: Nikolai Kosjar --- .../clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp | 15 ++++++++------- .../clangstaticanalyzer/clangstaticanalyzerruncontrol.h | 1 - 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp index 612a35c52e..94c855efda 100644 --- a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp +++ b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp @@ -79,6 +79,7 @@ ClangStaticAnalyzerToolRunner::ClangStaticAnalyzerToolRunner(RunControl *runCont RunConfiguration *runConfiguration = runControl->runConfiguration(); auto tool = ClangStaticAnalyzerTool::instance(); + tool->stopAction()->disconnect(); connect(tool->stopAction(), &QAction::triggered, runControl, &RunControl::initiateStop); ProjectInfo projectInfoBeforeBuild = tool->projectInfoBeforeBuild(); @@ -495,6 +496,10 @@ void ClangStaticAnalyzerToolRunner::start() m_success = false; ClangStaticAnalyzerTool::instance()->onEngineIsStarting(); + connect(runControl(), &RunControl::finished, this, [this] { + ClangStaticAnalyzerTool::instance()->onEngineFinished(m_success); + }); + QTC_ASSERT(m_projectInfo.isValid(), reportFailure(); return); const Utils::FileName projectFile = m_projectInfo.project()->projectFilePath(); appendMessage(tr("Running Clang Static Analyzer on %1").arg(projectFile.toUserOutput()) @@ -602,12 +607,8 @@ void ClangStaticAnalyzerToolRunner::stop() appendMessage(tr("Clang Static Analyzer stopped by user.") + QLatin1Char('\n'), Utils::NormalMessageFormat); m_progress.reportFinished(); - reportStopped(); -} - -void ClangStaticAnalyzerToolRunner::onFinished() -{ ClangStaticAnalyzerTool::instance()->onEngineFinished(m_success); + reportStopped(); } void ClangStaticAnalyzerToolRunner::analyzeNextFile() @@ -699,7 +700,7 @@ void ClangStaticAnalyzerToolRunner::handleFinished() void ClangStaticAnalyzerToolRunner::onProgressCanceled() { m_progress.reportCanceled(); - stop(); + runControl()->initiateStop(); } void ClangStaticAnalyzerToolRunner::updateProgressValue() @@ -723,7 +724,7 @@ void ClangStaticAnalyzerToolRunner::finalize() } m_progress.reportFinished(); - reportStopped(); + runControl()->initiateStop(); } } // namespace Internal diff --git a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h index 9719c42116..e75660287f 100644 --- a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h +++ b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.h @@ -56,7 +56,6 @@ public: void start() override; void stop() override; - void onFinished() override; bool success() const { return m_success; } // For testing. -- cgit v1.2.3 From 892026a6196b9d69fe0946afedab8b4eaf6c5208 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 14 Jul 2017 17:15:59 +0200 Subject: ClangStaticAnalyzer: Compile fix due to unsubmitted dependency This patch needs to be reverted later. Change-Id: Ia120e225ec1086eca786f668999a48e5ee19ec7e Reviewed-by: Christian Kandeler --- src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp index 94c855efda..ff078f612e 100644 --- a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp +++ b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp @@ -496,7 +496,7 @@ void ClangStaticAnalyzerToolRunner::start() m_success = false; ClangStaticAnalyzerTool::instance()->onEngineIsStarting(); - connect(runControl(), &RunControl::finished, this, [this] { + connect(runControl(), &RunControl::stopped, this, [this] { ClangStaticAnalyzerTool::instance()->onEngineFinished(m_success); }); -- cgit v1.2.3 From 635750aa11db284d5ee3b0e97f6d1e035a8c54e3 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Wed, 12 Jul 2017 09:34:30 +0200 Subject: Clang: delay text mark update Reducing display of unwanted line annotations while typing in small files. Change-Id: I51864bbc3056ad792d5ee4b96f63e954dfba79dd Reviewed-by: Ivan Donchevskii Reviewed-by: Nikolai Kosjar --- src/plugins/clangcodemodel/clangdiagnosticmanager.cpp | 15 ++++++++++++++- src/plugins/clangcodemodel/clangdiagnosticmanager.h | 3 +++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp index c8da6e6c6a..1dd003c7c1 100644 --- a/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp +++ b/src/plugins/clangcodemodel/clangdiagnosticmanager.cpp @@ -278,6 +278,8 @@ namespace Internal { ClangDiagnosticManager::ClangDiagnosticManager(TextEditor::TextDocument *textDocument) : m_textDocument(textDocument) { + m_textMarkDelay.setInterval(1500); + m_textMarkDelay.setSingleShot(true); } ClangDiagnosticManager::~ClangDiagnosticManager() @@ -295,6 +297,7 @@ void ClangDiagnosticManager::cleanMarks() } void ClangDiagnosticManager::generateTextMarks() { + QObject::disconnect(&m_textMarkDelay, &QTimer::timeout, 0, 0); cleanMarks(); m_clangTextMarks.reserve(m_warningDiagnostics.size() + m_errorDiagnostics.size()); addClangTextMarks(m_warningDiagnostics); @@ -350,6 +353,7 @@ ClangDiagnosticManager::diagnosticsAt(uint line, uint column) const void ClangDiagnosticManager::invalidateDiagnostics() { + m_textMarkDelay.start(); if (m_diagnosticsInvalidated) return; @@ -383,9 +387,18 @@ void ClangDiagnosticManager::processNewDiagnostics( m_showTextMarkAnnotations = showTextMarkAnnotations; filterDiagnostics(allDiagnostics); - generateTextMarks(); generateEditorSelections(); generateFixItAvailableMarkers(); + if (m_firstDiagnostics) { + m_firstDiagnostics = false; + generateTextMarks(); + } else if (!m_textMarkDelay.isActive()) { + generateTextMarks(); + } else { + QObject::connect(&m_textMarkDelay, &QTimer::timeout, [this]() { + generateTextMarks(); + }); + } } const QVector & diff --git a/src/plugins/clangcodemodel/clangdiagnosticmanager.h b/src/plugins/clangcodemodel/clangdiagnosticmanager.h index 16b1c16d2d..1321702c99 100644 --- a/src/plugins/clangcodemodel/clangdiagnosticmanager.h +++ b/src/plugins/clangcodemodel/clangdiagnosticmanager.h @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -82,8 +83,10 @@ private: QList m_extraSelections; TextEditor::RefactorMarkers m_fixItAvailableMarkers; std::vector m_clangTextMarks; + bool m_firstDiagnostics = true; bool m_diagnosticsInvalidated = false; bool m_showTextMarkAnnotations = false; + QTimer m_textMarkDelay; }; } // namespace Internal -- cgit v1.2.3 From c9301e80bb960ba5df93fdd22932257542693154 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Fri, 14 Jul 2017 13:11:22 +0200 Subject: Clang: Hide the # button in the editor tool bar ...since this is not yet implemented and confuses users. Change-Id: I16e41f3308607aeaf1fb4a8d38ca276781c88952 Reviewed-by: David Schulz --- src/plugins/cppeditor/cppeditor.cpp | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 677cd1ebc3..65d0c42abf 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -245,13 +245,19 @@ void CppEditorWidget::finalizeInitialization() }); // Toolbar: '#' Button - d->m_preprocessorButton = new QToolButton(this); - d->m_preprocessorButton->setText(QLatin1String("#")); - Command *cmd = ActionManager::command(Constants::OPEN_PREPROCESSOR_DIALOG); - connect(cmd, &Command::keySequenceChanged, this, &CppEditorWidget::updatePreprocessorButtonTooltip); - updatePreprocessorButtonTooltip(); - connect(d->m_preprocessorButton, &QAbstractButton::clicked, this, &CppEditorWidget::showPreProcessorWidget); - insertExtraToolBarWidget(TextEditorWidget::Left, d->m_preprocessorButton); + // TODO: Make "Additional Preprocessor Directives" also useful with Clang Code Model. + if (!d->m_modelManager->isClangCodeModelActive()) { + d->m_preprocessorButton = new QToolButton(this); + d->m_preprocessorButton->setText(QLatin1String("#")); + Command *cmd = ActionManager::command(Constants::OPEN_PREPROCESSOR_DIALOG); + connect(cmd, &Command::keySequenceChanged, + this, &CppEditorWidget::updatePreprocessorButtonTooltip); + updatePreprocessorButtonTooltip(); + connect(d->m_preprocessorButton, &QAbstractButton::clicked, + this, &CppEditorWidget::showPreProcessorWidget); + + insertExtraToolBarWidget(TextEditorWidget::Left, d->m_preprocessorButton); + } // Toolbar: Actions to show minimized info bars d->m_showInfoBarActions = MinimizableInfoBars::createShowInfoBarActions([this](QWidget *w) { @@ -429,13 +435,16 @@ bool CppEditorWidget::selectBlockDown() void CppEditorWidget::updateWidgetHighlighting(QWidget *widget, bool highlight) { + if (!widget) + return; + widget->setProperty("highlightWidget", highlight); widget->update(); } bool CppEditorWidget::isWidgetHighlighted(QWidget *widget) { - return widget->property("highlightWidget").toBool(); + return widget ? widget->property("highlightWidget").toBool() : false; } void CppEditorWidget::renameSymbolUnderCursor() @@ -586,7 +595,9 @@ void CppEditorWidget::renameSymbolUnderCursorClang() void CppEditorWidget::updatePreprocessorButtonTooltip() { - QTC_ASSERT(d->m_preprocessorButton, return); + if (!d->m_preprocessorButton) + return; + Command *cmd = ActionManager::command(Constants::OPEN_PREPROCESSOR_DIALOG); QTC_ASSERT(cmd, return); d->m_preprocessorButton->setToolTip(cmd->action()->toolTip()); -- cgit v1.2.3 From be2b3c91ae4ddb97c35237da11b350c99cc6fd3b Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Fri, 14 Jul 2017 13:44:33 +0200 Subject: Add Q_FALLTHROUGH for Qt < 5.8 ... and make use of it. With gcc 7, the new option -Wimplicit-fallthrough is introduced and added to the -Wextra set, triggering dozens of warnings in our sources. Therefore, we annotate all obviously intended fall-throughs. The ones that are still left are unclear and need to be checked by the respective maintainer. Change-Id: I44ead33cd42a4b41c28ee5fcb5a31db272710bbc Reviewed-by: Nikita Baryshnikov Reviewed-by: hjk Reviewed-by: Eike Ziller --- src/libs/3rdparty/cplusplus/Parser.cpp | 4 +- src/libs/utils/qtcfallthrough.h | 54 ++++++++++++++++++++++ src/libs/utils/utils-lib.pri | 1 + src/libs/utils/utils.qbs | 1 + src/plugins/cppeditor/cppquickfixes.cpp | 3 +- src/plugins/cpptools/compileroptionsbuilder.cpp | 10 ++-- src/plugins/debugger/gdb/attachgdbadapter.cpp | 3 +- .../debugger/gdb/remotegdbserveradapter.cpp | 3 +- src/plugins/debugger/qml/qmlengine.cpp | 3 +- src/plugins/debugger/watchutils.cpp | 4 ++ src/plugins/ios/iostoolhandler.cpp | 7 +-- .../components/formeditor/formeditorscene.cpp | 2 + src/plugins/qmlprofiler/qmlprofilertool.cpp | 3 ++ src/plugins/qmlprofiler/qmlprofilertraceview.cpp | 5 +- src/plugins/scxmleditor/common/structuremodel.cpp | 3 ++ src/plugins/vcsbase/vcsbaseclientsettings.cpp | 2 + 16 files changed, 95 insertions(+), 13 deletions(-) create mode 100644 src/libs/utils/qtcfallthrough.h (limited to 'src') diff --git a/src/libs/3rdparty/cplusplus/Parser.cpp b/src/libs/3rdparty/cplusplus/Parser.cpp index 8754206a0b..16f351077a 100644 --- a/src/libs/3rdparty/cplusplus/Parser.cpp +++ b/src/libs/3rdparty/cplusplus/Parser.cpp @@ -27,6 +27,8 @@ #include "ObjectiveCTypeQualifiers.h" #include "QtContextKeywords.h" +#include + #include #include @@ -442,7 +444,7 @@ bool Parser::skipUntilStatement() case T_AT_THROW: if (_languageFeatures.objCEnabled) return true; - + Q_FALLTHROUGH(); default: consumeToken(); } diff --git a/src/libs/utils/qtcfallthrough.h b/src/libs/utils/qtcfallthrough.h new file mode 100644 index 0000000000..6eba622837 --- /dev/null +++ b/src/libs/utils/qtcfallthrough.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include + +#ifndef Q_FALLTHROUGH +#ifndef QT_HAS_CPP_ATTRIBUTE +#ifdef __has_cpp_attribute +# define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) +#else +# define QT_HAS_CPP_ATTRIBUTE(x) 0 +#endif +#endif +#if defined(__cplusplus) +#if QT_HAS_CPP_ATTRIBUTE(fallthrough) +# define Q_FALLTHROUGH() [[fallthrough]] +#elif QT_HAS_CPP_ATTRIBUTE(clang::fallthrough) +# define Q_FALLTHROUGH() [[clang::fallthrough]] +#elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough) +# define Q_FALLTHROUGH() [[gnu::fallthrough]] +#endif +#endif +#ifndef Q_FALLTHROUGH +# if (defined(Q_CC_GNU) && Q_CC_GNU >= 700) && !defined(Q_CC_INTEL) +# define Q_FALLTHROUGH() __attribute__((fallthrough)) +# else +# define Q_FALLTHROUGH() (void)0 +#endif +#endif +#endif diff --git a/src/libs/utils/utils-lib.pri b/src/libs/utils/utils-lib.pri index bfc9d6084e..3a6aa0a09a 100644 --- a/src/libs/utils/utils-lib.pri +++ b/src/libs/utils/utils-lib.pri @@ -239,6 +239,7 @@ HEADERS += \ $$PWD/asconst.h \ $$PWD/smallstringfwd.h \ $$PWD/optional.h \ + $$PWD/qtcfallthrough.h \ $$PWD/../3rdparty/optional/optional.hpp FORMS += $$PWD/filewizardpage.ui \ diff --git a/src/libs/utils/utils.qbs b/src/libs/utils/utils.qbs index 559129df16..6d68683fdd 100644 --- a/src/libs/utils/utils.qbs +++ b/src/libs/utils/utils.qbs @@ -175,6 +175,7 @@ Project { "proxycredentialsdialog.cpp", "proxycredentialsdialog.h", "proxycredentialsdialog.ui", + "qtcfallthrough.h", "qtcassert.cpp", "qtcassert.h", "qtcolorbutton.cpp", diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index 67d360c3bb..640fa794ef 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -56,6 +56,7 @@ #include #include +#include #include #include @@ -4119,7 +4120,7 @@ public: break; case FromReference: removeReferenceOperator(changes); - // fallthrough intended + Q_FALLTHROUGH(); case FromVariable: convertToPointer(changes); break; diff --git a/src/plugins/cpptools/compileroptionsbuilder.cpp b/src/plugins/cpptools/compileroptionsbuilder.cpp index 8f5fd397fb..170279c9b8 100644 --- a/src/plugins/cpptools/compileroptionsbuilder.cpp +++ b/src/plugins/cpptools/compileroptionsbuilder.cpp @@ -26,6 +26,7 @@ #include "compileroptionsbuilder.h" #include +#include #include #include @@ -201,7 +202,8 @@ static QStringList createLanguageOptionGcc(ProjectFile::Kind fileKind, bool objc if (!objcExt) { opts += QLatin1String("c++-header"); break; - } // else: fall-through! + } + Q_FALLTHROUGH(); case ProjectFile::ObjCHeader: case ProjectFile::ObjCXXHeader: opts += QLatin1String("objective-c++-header"); @@ -211,7 +213,8 @@ static QStringList createLanguageOptionGcc(ProjectFile::Kind fileKind, bool objc if (!objcExt) { opts += QLatin1String("c"); break; - } // else: fall-through! + } + Q_FALLTHROUGH(); case ProjectFile::ObjCSource: opts += QLatin1String("objective-c"); break; @@ -220,7 +223,8 @@ static QStringList createLanguageOptionGcc(ProjectFile::Kind fileKind, bool objc if (!objcExt) { opts += QLatin1String("c++"); break; - } // else: fall-through! + } + Q_FALLTHROUGH(); case ProjectFile::ObjCXXSource: opts += QLatin1String("objective-c++"); break; diff --git a/src/plugins/debugger/gdb/attachgdbadapter.cpp b/src/plugins/debugger/gdb/attachgdbadapter.cpp index 11566a51be..519647d703 100644 --- a/src/plugins/debugger/gdb/attachgdbadapter.cpp +++ b/src/plugins/debugger/gdb/attachgdbadapter.cpp @@ -31,6 +31,7 @@ #include #include +#include namespace Debugger { namespace Internal { @@ -102,7 +103,7 @@ void GdbAttachEngine::handleAttach(const DebuggerResponse &response) notifyEngineIll(); break; } - // if msg != "ptrace: ..." fall through + Q_FALLTHROUGH(); // if msg != "ptrace: ..." default: showStatusMessage(tr("Failed to attach to application: %1") .arg(QString(response.data["msg"].data()))); diff --git a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp index a36aa11bef..cf55a82dc6 100644 --- a/src/plugins/debugger/gdb/remotegdbserveradapter.cpp +++ b/src/plugins/debugger/gdb/remotegdbserveradapter.cpp @@ -34,6 +34,7 @@ #include #include +#include #include #include @@ -367,7 +368,7 @@ void GdbRemoteServerEngine::handleAttach(const DebuggerResponse &response) notifyInferiorSetupFailed(msgPtraceError(runParameters().startMode)); break; } - // if msg != "ptrace: ..." fall through + Q_FALLTHROUGH(); // if msg != "ptrace: ..." default: notifyInferiorSetupFailed(response.data["msg"].data()); } diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index 87b4a039d0..0a0ed1d516 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -60,6 +60,7 @@ #include #include #include +#include #include #include @@ -505,7 +506,7 @@ void QmlEngine::errorMessageBoxFinished(int result) } case QMessageBox::Help: { HelpManager::handleHelpRequest("qthelp://org.qt-project.qtcreator/doc/creator-debugging-qml.html"); - // fall through + Q_FALLTHROUGH(); } default: if (state() == InferiorRunOk) { diff --git a/src/plugins/debugger/watchutils.cpp b/src/plugins/debugger/watchutils.cpp index f6e8dfeb45..2275807d22 100644 --- a/src/plugins/debugger/watchutils.cpp +++ b/src/plugins/debugger/watchutils.cpp @@ -29,6 +29,8 @@ #include "watchutils.h" #include "watchdata.h" +#include + #include #include @@ -231,8 +233,10 @@ QString formatToolTipAddress(quint64 a) switch (rc.size()) { case 16: rc.insert(12, colon); + Q_FALLTHROUGH(); case 12: rc.insert(8, colon); + Q_FALLTHROUGH(); case 8: rc.insert(4, colon); } diff --git a/src/plugins/ios/iostoolhandler.cpp b/src/plugins/ios/iostoolhandler.cpp index f2afa71433..317c1f6f59 100644 --- a/src/plugins/ios/iostoolhandler.cpp +++ b/src/plugins/ios/iostoolhandler.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "utils/runextensions.h" #include "utils/synchronousprocess.h" @@ -606,7 +607,7 @@ void IosDeviceToolHandlerPrivate::subprocessHasData() switch (state) { case NonStarted: qCWarning(toolHandlerLog) << "IosToolHandler unexpected state in subprocessHasData: NonStarted"; - // pass + Q_FALLTHROUGH(); case Starting: case StartedInferior: // read some data @@ -771,7 +772,7 @@ void IosDeviceToolHandlerPrivate::stop(int errorCode) switch (oldState) { case NonStarted: qCWarning(toolHandlerLog) << "IosToolHandler::stop() when state was NonStarted"; - // pass + Q_FALLTHROUGH(); case Starting: switch (op){ case OpNone: @@ -786,7 +787,7 @@ void IosDeviceToolHandlerPrivate::stop(int errorCode) case OpDeviceInfo: break; } - // pass + Q_FALLTHROUGH(); case StartedInferior: case XmlEndProcessed: toolExited(errorCode); diff --git a/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp b/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp index 950028bf3b..3601db1753 100644 --- a/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp +++ b/src/plugins/qmldesigner/components/formeditor/formeditorscene.cpp @@ -44,6 +44,7 @@ #include #include +#include namespace QmlDesigner { @@ -358,6 +359,7 @@ bool FormEditorScene::event(QEvent * event) currentTool()->keyPressEvent(static_cast(event)); return true; } + Q_FALLTHROUGH(); default: return QGraphicsScene::event(event); } diff --git a/src/plugins/qmlprofiler/qmlprofilertool.cpp b/src/plugins/qmlprofiler/qmlprofilertool.cpp index 227b6dff0b..e246bf885c 100644 --- a/src/plugins/qmlprofiler/qmlprofilertool.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertool.cpp @@ -69,6 +69,8 @@ #include +#include + #include #include #include @@ -387,6 +389,7 @@ void QmlProfilerTool::finalizeRunControl(QmlProfilerRunner *runWorker) case QMessageBox::Help: HelpManager::handleHelpRequest( "qthelp://org.qt-project.qtcreator/doc/creator-debugging-qml.html"); + Q_FALLTHROUGH(); case QMessageBox::Cancel: // The actual error message has already been logged. logState(tr("Failed to connect.")); diff --git a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp index 8519d12422..a2a00b4f98 100644 --- a/src/plugins/qmlprofiler/qmlprofilertraceview.cpp +++ b/src/plugins/qmlprofiler/qmlprofilertraceview.cpp @@ -53,6 +53,7 @@ // Needed for the load&save actions in the context menu #include #include +#include #include #include @@ -103,7 +104,7 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerViewManag qint64 end = modelManager->traceTime()->endTime(); d->m_zoomControl->setTrace(start, end); d->m_zoomControl->setRange(start, start + (end - start) / 10); - // Fall through + Q_FALLTHROUGH(); } case QmlProfilerModelManager::Empty: d->m_modelProxy->setModels(d->m_suspendedModels); @@ -116,7 +117,7 @@ QmlProfilerTraceView::QmlProfilerTraceView(QWidget *parent, QmlProfilerViewManag d->m_zoomControl->clear(); if (!d->m_suspendedModels.isEmpty()) break; // Models are suspended already. AcquiringData was aborted. - // Fall through + Q_FALLTHROUGH(); case QmlProfilerModelManager::AcquiringData: // Temporarily remove the models, while we're changing them d->m_suspendedModels = d->m_modelProxy->models(); diff --git a/src/plugins/scxmleditor/common/structuremodel.cpp b/src/plugins/scxmleditor/common/structuremodel.cpp index f7b2e563e9..5f63319c16 100644 --- a/src/plugins/scxmleditor/common/structuremodel.cpp +++ b/src/plugins/scxmleditor/common/structuremodel.cpp @@ -27,6 +27,8 @@ #include "scxmldocument.h" #include "scxmltag.h" +#include + #include #include @@ -245,6 +247,7 @@ Qt::ItemFlags StructureModel::flags(const QModelIndex &index) const case Final: case History: defaultFlags |= Qt::ItemIsDragEnabled; + Q_FALLTHROUGH(); case Scxml: defaultFlags |= Qt::ItemIsDropEnabled; break; diff --git a/src/plugins/vcsbase/vcsbaseclientsettings.cpp b/src/plugins/vcsbase/vcsbaseclientsettings.cpp index 35c2a7c119..ab67910c2f 100644 --- a/src/plugins/vcsbase/vcsbaseclientsettings.cpp +++ b/src/plugins/vcsbase/vcsbaseclientsettings.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -56,6 +57,7 @@ public: switch (v.type()) { case QVariant::UInt: m_type = QVariant::Int; + Q_FALLTHROUGH(); case QVariant::Int: m_comp.intValue = v.toInt(); break; -- cgit v1.2.3 From be3e12c8aff85e133f7a3cddb1c0a9ecf8607467 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Fri, 14 Jul 2017 12:38:06 +0200 Subject: CppEditor: Avoid auto insertion of '}' in empty line ...when typing '{'. Change-Id: Ia1d3bcd7440c96ed3c8c1479148dd74d3d291689 Reviewed-by: David Schulz --- src/libs/cplusplus/MatchingText.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/libs/cplusplus/MatchingText.cpp b/src/libs/cplusplus/MatchingText.cpp index f783d4c508..3fdb573b91 100644 --- a/src/libs/cplusplus/MatchingText.cpp +++ b/src/libs/cplusplus/MatchingText.cpp @@ -143,9 +143,13 @@ bool MatchingText::contextAllowsAutoParentheses(const QTextCursor &cursor, if (!textToInsert.isEmpty()) ch = textToInsert.at(0); + if (ch == QLatin1Char('{') && cursor.block().text().trimmed().isEmpty()) + return false; // User just might want to wrap up some lines. + if (!shouldInsertMatchingText(cursor) && ch != QLatin1Char('\'') && ch != QLatin1Char('"')) return false; - else if (isInCommentHelper(cursor)) + + if (isInCommentHelper(cursor)) return false; return true; -- cgit v1.2.3 From db88225b0ea9531062d184f2e52492b3218980f3 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Thu, 6 Jul 2017 12:04:19 +0200 Subject: CppEditor: Fix invalidating diagnostics on reload Issue was: 1. Open some small file without any includes but with diagnostics 2. Switch to the shell and touch the file open in Qt Creator 3. Switch back to Qt Creator and confirm reload --> Ops, inline diagnostic stays invalidated/gray This is due to a race condition. The problematic sequence is: 1. CppEditorDocument::scheduleProcessDocument() // OK, because contents changed 2. ModelManagerSupportClang::onCppDocumentReloadFinishedOnTranslationUnit(bool) // OK, because we listen on TextDocument::contentsChangedWithPosition. // Because of the fast reparse, new diagnostics are processed with // ClangEditorDocumentProcessor::updateCodeWarnings(). 3. CppEditorDocument::processDocument() // Timeout, invalidates the already up to date diagnostics Avoid to trigger the process timer during a reload. Change-Id: I712d6b2fd5524d5fe6866dbdbb8cbca05e4aef2c Reviewed-by: David Schulz --- src/plugins/cppeditor/cppeditordocument.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/plugins/cppeditor/cppeditordocument.cpp b/src/plugins/cppeditor/cppeditordocument.cpp index c5a9d40e2e..d31a4eb899 100644 --- a/src/plugins/cppeditor/cppeditordocument.cpp +++ b/src/plugins/cppeditor/cppeditordocument.cpp @@ -201,12 +201,17 @@ void CppEditorDocument::onAboutToReload() { QTC_CHECK(!m_fileIsBeingReloaded); m_fileIsBeingReloaded = true; + + processor()->invalidateDiagnostics(); } void CppEditorDocument::onReloadFinished() { QTC_CHECK(m_fileIsBeingReloaded); m_fileIsBeingReloaded = false; + + m_processorRevision = document()->revision(); + processDocument(); } void CppEditorDocument::reparseWithPreferredParseContext(const QString &parseContextId) @@ -250,6 +255,9 @@ void CppEditorDocument::onFilePathChanged(const Utils::FileName &oldPath, void CppEditorDocument::scheduleProcessDocument() { + if (m_fileIsBeingReloaded) + return; + m_processorRevision = document()->revision(); m_processorTimer.start(); processor()->editorDocumentTimerRestarted(); -- cgit v1.2.3 From 8309e0c56a234f7ab1c2d658fcd680b801a5e2f4 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar Date: Fri, 14 Jul 2017 09:42:05 +0200 Subject: Clang: Avoid blocking UI if references are requested and clangbackend crashes The two cases in which the UI might be blocked are: * Invocation of the editor context menu * Rename Symbol Under Cursor Cancel the future if the backend is restarted and on the other side, check whether the future is cancelled. Change-Id: If2315da1f66f15eab1531fcd8da1dff851a9a4e6 Reviewed-by: Ivan Donchevskii Reviewed-by: David Schulz --- .../clangcodemodel/clangbackendipcintegration.cpp | 22 ++++++++++++++-------- .../clangcodemodel/clangbackendipcintegration.h | 4 ++-- src/plugins/cppeditor/cppuseselectionsupdater.cpp | 6 +++++- 3 files changed, 21 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/plugins/clangcodemodel/clangbackendipcintegration.cpp b/src/plugins/clangcodemodel/clangbackendipcintegration.cpp index 5ff5b1aa7e..cfb52f1528 100644 --- a/src/plugins/clangcodemodel/clangbackendipcintegration.cpp +++ b/src/plugins/clangcodemodel/clangbackendipcintegration.cpp @@ -99,7 +99,7 @@ IpcReceiver::IpcReceiver() IpcReceiver::~IpcReceiver() { - deleteAndClearWaitingAssistProcessors(); + reset(); } void IpcReceiver::setAliveHandler(const IpcReceiver::AliveHandler &handler) @@ -116,12 +116,6 @@ void IpcReceiver::addExpectedCodeCompletedMessage( m_assistProcessorsTable.insert(ticket, processor); } -void IpcReceiver::deleteAndClearWaitingAssistProcessors() -{ - qDeleteAll(m_assistProcessorsTable.begin(), m_assistProcessorsTable.end()); - m_assistProcessorsTable.clear(); -} - void IpcReceiver::deleteProcessorsOfEditorWidget(TextEditor::TextEditorWidget *textEditorWidget) { QMutableHashIterator it(m_assistProcessorsTable); @@ -155,6 +149,18 @@ bool IpcReceiver::isExpectingCodeCompletedMessage() const return !m_assistProcessorsTable.isEmpty(); } +void IpcReceiver::reset() +{ + // Clean up waiting assist processors + qDeleteAll(m_assistProcessorsTable.begin(), m_assistProcessorsTable.end()); + m_assistProcessorsTable.clear(); + + // Clean up futures for references + for (ReferencesEntry &entry : m_referencesTable) + entry.futureInterface.cancel(); + m_referencesTable.clear(); +} + void IpcReceiver::alive() { if (printAliveMessage()) @@ -719,7 +725,7 @@ void IpcCommunicator::onConnectedToBackend() if (m_connectedCount > 1) logRestartedDueToUnexpectedFinish(); - m_ipcReceiver.deleteAndClearWaitingAssistProcessors(); + m_ipcReceiver.reset(); m_ipcSender.reset(new IpcSender(m_connection)); initializeBackendWithCurrentData(); diff --git a/src/plugins/clangcodemodel/clangbackendipcintegration.h b/src/plugins/clangcodemodel/clangbackendipcintegration.h index 57a07e8097..e98565f48c 100644 --- a/src/plugins/clangcodemodel/clangbackendipcintegration.h +++ b/src/plugins/clangcodemodel/clangbackendipcintegration.h @@ -73,14 +73,14 @@ public: void setAliveHandler(const AliveHandler &handler); void addExpectedCodeCompletedMessage(quint64 ticket, ClangCompletionAssistProcessor *processor); - void deleteAndClearWaitingAssistProcessors(); void deleteProcessorsOfEditorWidget(TextEditor::TextEditorWidget *textEditorWidget); QFuture addExpectedReferencesMessage(quint64 ticket, QTextDocument *textDocument); - bool isExpectingCodeCompletedMessage() const; + void reset(); + private: void alive() override; void echo(const ClangBackEnd::EchoMessage &message) override; diff --git a/src/plugins/cppeditor/cppuseselectionsupdater.cpp b/src/plugins/cppeditor/cppuseselectionsupdater.cpp index 5e03ebbe2d..81e1436ccd 100644 --- a/src/plugins/cppeditor/cppuseselectionsupdater.cpp +++ b/src/plugins/cppeditor/cppuseselectionsupdater.cpp @@ -98,8 +98,12 @@ void CppUseSelectionsUpdater::update(CallType callType) // QFuture::waitForFinished seems to block completely, not even // allowing to process events from QLocalSocket. - while (!future.isFinished()) + while (!future.isFinished()) { + if (future.isCanceled()) + return; + QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); + } processResults(future.result()); } -- cgit v1.2.3 From 0b1eaacabba0c0b9366766b020597d9280ff19af Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 5 Jul 2017 16:22:10 +0200 Subject: DiffEditor: fix the cancellation of diff requests Change-Id: I36c4af4ec51473fb9da5d9f099f2251f75b2020a Reviewed-by: Orgad Shaneh --- src/plugins/diffeditor/diffeditorplugin.cpp | 6 +- .../vcsbase/vcsbasediffeditorcontroller.cpp | 133 ++++++++++++++++++--- 2 files changed, 119 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/plugins/diffeditor/diffeditorplugin.cpp b/src/plugins/diffeditor/diffeditorplugin.cpp index 232c2addaa..6391c0ae0a 100644 --- a/src/plugins/diffeditor/diffeditorplugin.cpp +++ b/src/plugins/diffeditor/diffeditorplugin.cpp @@ -156,10 +156,12 @@ void DiffFilesController::reload() void DiffFilesController::reloaded() { - const QList fileDataList = m_futureWatcher.future().results(); + const bool success = !m_futureWatcher.future().isCanceled(); + const QList fileDataList = success + ? m_futureWatcher.future().results() : QList(); setDiffFiles(fileDataList); - reloadFinished(true); + reloadFinished(success); } void DiffFilesController::cancelReload() diff --git a/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp b/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp index b92a35f854..6b628cdb13 100644 --- a/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp +++ b/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp @@ -48,6 +48,37 @@ static void readPatch(QFutureInterface> &futureInterface, futureInterface.reportResult(fileDataList); } +///////////////////// + +// We need a way to disconnect from signals posted from different thread +// so that signals that are already posted from the other thread and not delivered +// yet will be ignored. Unfortunately, simple QObject::disconnect() doesn't +// work like that, since signals that are already posted and are awaiting +// to be delivered WILL BE delivered later, even after a call to QObject::disconnect(). +// The delivery will happen when the control returns to the main event loop. + +// This proxy class solves the above problem. Instead of a call to +// QObject::disconnect(), which would still deliver posted signals, +// we delete the proxy object immediately. In this way signals which are +// already posted and are awaiting to be delivered won't be delivered to the +// destroyed object. + +// So the only reason for this proxy object is to be able to disconnect +// effectively from the signals posted from different threads. + +class VcsCommandResultProxy : public QObject { + Q_OBJECT +public: + VcsCommandResultProxy(VcsCommand *command, VcsBaseDiffEditorControllerPrivate *target); +private: + void storeOutput(const QString &output); + void commandFinished(bool success); + + VcsBaseDiffEditorControllerPrivate *m_target; +}; + +///////////////////// + class VcsBaseDiffEditorControllerPrivate { public: @@ -59,6 +90,7 @@ public: void processingFinished(); void processDiff(const QString &patch); void cancelReload(); + void storeOutput(const QString &output); void commandFinished(bool success); VcsBaseDiffEditorController *q; @@ -67,18 +99,43 @@ public: QString m_startupFile; QString m_output; QPointer m_command; - QFutureWatcher> m_processWatcher; + QPointer m_commandResultProxy; + QFutureWatcher> *m_processWatcher = nullptr; }; -VcsBaseDiffEditorControllerPrivate::VcsBaseDiffEditorControllerPrivate(VcsBaseDiffEditorController *controller, +///////////////////// + +VcsCommandResultProxy::VcsCommandResultProxy(VcsCommand *command, + VcsBaseDiffEditorControllerPrivate *target) + : QObject(target->q) + , m_target(target) +{ + connect(command, &VcsCommand::stdOutText, + this, &VcsCommandResultProxy::storeOutput); + connect(command, &VcsCommand::finished, + this, &VcsCommandResultProxy::commandFinished); + connect(command, &VcsCommand::destroyed, + this, &QObject::deleteLater); +} + +void VcsCommandResultProxy::storeOutput(const QString &output) +{ + m_target->storeOutput(output); +} + +void VcsCommandResultProxy::commandFinished(bool success) +{ + m_target->commandFinished(success); +} + +VcsBaseDiffEditorControllerPrivate::VcsBaseDiffEditorControllerPrivate( + VcsBaseDiffEditorController *controller, VcsBaseClientImpl *client, const QString &workingDirectory) : q(controller) , m_client(client) , m_directory(workingDirectory) { - QObject::connect(&m_processWatcher, &QFutureWatcher>::finished, q, - [this] () { processingFinished(); }); } VcsBaseDiffEditorControllerPrivate::~VcsBaseDiffEditorControllerPrivate() @@ -88,9 +145,18 @@ VcsBaseDiffEditorControllerPrivate::~VcsBaseDiffEditorControllerPrivate() void VcsBaseDiffEditorControllerPrivate::processingFinished() { - bool success = !m_processWatcher.future().isCanceled(); + QTC_ASSERT(m_processWatcher, return); + + // success is false when the user clicked the cancel micro button + // inside the progress indicator + const bool success = !m_processWatcher->future().isCanceled(); const QList fileDataList = success - ? m_processWatcher.future().result() : QList(); + ? m_processWatcher->future().result() : QList(); + + // Prevent direct deletion of m_processWatcher since + // processingFinished() is called directly by the m_processWatcher. + m_processWatcher->deleteLater(); + m_processWatcher = nullptr; q->setDiffFiles(fileDataList, q->workingDirectory(), q->startupFile()); q->reloadFinished(success); @@ -98,39 +164,67 @@ void VcsBaseDiffEditorControllerPrivate::processingFinished() void VcsBaseDiffEditorControllerPrivate::processDiff(const QString &patch) { - m_processWatcher.setFuture(Utils::runAsync(&readPatch, patch)); + cancelReload(); + + m_processWatcher = new QFutureWatcher>(); - ProgressManager::addTask(m_processWatcher.future(), - q->tr("Processing diff"), "DiffEditor"); + QObject::connect(m_processWatcher, &QFutureWatcher>::finished, + [this] () { processingFinished(); } ); + + m_processWatcher->setFuture(Utils::runAsync(&readPatch, patch)); + + ProgressManager::addTask(m_processWatcher->future(), + q->tr("Processing diff"), "DiffEditor"); } void VcsBaseDiffEditorControllerPrivate::cancelReload() { if (m_command) { - m_command->disconnect(); m_command->cancel(); m_command.clear(); } - if (m_processWatcher.future().isRunning()) { - m_processWatcher.future().cancel(); - m_processWatcher.setFuture(QFuture>()); + // Disconnect effectively, don't deliver already posted signals + if (m_commandResultProxy) + delete m_commandResultProxy.data(); + + if (m_processWatcher) { + // Cancel the running process without the further processingFinished() + // notification for this process. + m_processWatcher->future().cancel(); + delete m_processWatcher; + m_processWatcher = nullptr; } + m_output = QString(); } +void VcsBaseDiffEditorControllerPrivate::storeOutput(const QString &output) +{ + m_output = output; +} + void VcsBaseDiffEditorControllerPrivate::commandFinished(bool success) { if (m_command) m_command.clear(); + // Prevent direct deletion of m_commandResultProxy inside the possible + // subsequent synchronous calls to cancelReload() [called e.g. by + // processCommandOutput() overload], since + // commandFinished() is called directly by the m_commandResultProxy. + // m_commandResultProxy is removed via deleteLater right after + // a call to this commandFinished() is finished + if (m_commandResultProxy) + m_commandResultProxy.clear(); + if (!success) { cancelReload(); q->reloadFinished(success); return; } - q->processCommandOutput(m_output); + q->processCommandOutput(QString(m_output)); // pass a copy of m_output } ///////////////////// @@ -150,14 +244,15 @@ VcsBaseDiffEditorController::~VcsBaseDiffEditorController() void VcsBaseDiffEditorController::runCommand(const QList &args, unsigned flags, QTextCodec *codec) { + // Cancel the possible ongoing reload without the commandFinished() nor + // processingFinished() notifications, as right after that + // we re-reload it from scratch. So no intermediate "Retrieving data failed." + // and "Waiting for data..." will be shown. d->cancelReload(); d->m_command = new VcsCommand(workingDirectory(), d->m_client->processEnvironment()); d->m_command->setCodec(codec ? codec : EditorManager::defaultTextCodec()); - connect(d->m_command.data(), &VcsCommand::stdOutText, this, - [this] (const QString &output) { d->m_output = output; }); - connect(d->m_command.data(), &VcsCommand::finished, this, - [this] (bool success) { d->commandFinished(success); }); + d->m_commandResultProxy = new VcsCommandResultProxy(d->m_command.data(), d); d->m_command->addFlags(flags); for (const QStringList &arg : args) { @@ -195,3 +290,5 @@ QString VcsBaseDiffEditorController::startupFile() const } } // namespace VcsBase + +#include "vcsbasediffeditorcontroller.moc" -- cgit v1.2.3 From d5342eff77a3857e3d4341bef045e2ab01c73175 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Thu, 13 Jul 2017 16:15:24 +0200 Subject: fix property spelling Change-Id: I00f84ec8d2c83d7f3937d2e21a24e02ba28991b3 Reviewed-by: Christian Stenger --- src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp index a95c455134..f5bb5d1ba6 100644 --- a/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp +++ b/src/plugins/qmldesigner/designercore/metainfo/nodemetainfo.cpp @@ -1029,9 +1029,9 @@ bool NodeMetaInfoPrivate::cleverCheckType(const TypeName &otherType) const return typeName == convertedName.toUtf8(); } -QVariant::Type NodeMetaInfoPrivate::variantTypeId(const PropertyName &properyName) const +QVariant::Type NodeMetaInfoPrivate::variantTypeId(const PropertyName &propertyName) const { - TypeName typeName = propertyType(properyName); + TypeName typeName = propertyType(propertyName); if (typeName == "string") return QVariant::String; -- cgit v1.2.3 From a7e895166f9ca6aad1389a46913b6c83bb3d76d0 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 17 Jul 2017 10:36:24 +0200 Subject: Locator: Fix pressing return when no results are available yet In that case the first item will be activated as soon as it gets available. That behavior got lost during the recent refactoring. Task-number: QTCREATORBUG-18560 Change-Id: Ifda117f92f2adf23b499f50bdb4809c5e7830517 Reviewed-by: Orgad Shaneh --- src/plugins/coreplugin/locator/locatorwidget.cpp | 18 ++++++++++++++---- src/plugins/coreplugin/locator/locatorwidget.h | 4 +++- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/plugins/coreplugin/locator/locatorwidget.cpp b/src/plugins/coreplugin/locator/locatorwidget.cpp index 76f0ac1f5b..5073bcd33c 100644 --- a/src/plugins/coreplugin/locator/locatorwidget.cpp +++ b/src/plugins/coreplugin/locator/locatorwidget.cpp @@ -483,6 +483,16 @@ void CompletionList::keyPressEvent(QKeyEvent *event) return; } break; + case Qt::Key_Return: + case Qt::Key_Enter: + // emit activated even if current index is not valid + // if there are no results yet, this allows activating the first entry when it is available + // (see LocatorWidget::addSearchResults) + if (event->modifiers() == 0) { + emit activated(currentIndex()); + return; + } + break; } Utils::TreeView::keyPressEvent(event); } @@ -795,9 +805,9 @@ void LocatorWidget::handleSearchFinished() m_showProgressTimer.stop(); setProgressIndicatorVisible(false); m_updateRequested = false; - if (m_rowRequestedForAccept >= 0) { - acceptEntry(m_rowRequestedForAccept); - m_rowRequestedForAccept = -1; + if (m_rowRequestedForAccept) { + acceptEntry(m_rowRequestedForAccept.value()); + m_rowRequestedForAccept.reset(); return; } if (m_entriesWatcher->future().isCanceled()) { @@ -892,7 +902,7 @@ void LocatorWidget::addSearchResults(int firstIndex, int endIndex) m_locatorModel->addEntries(entries); if (selectFirst) { emit selectRow(0); - if (m_rowRequestedForAccept >= 0) + if (m_rowRequestedForAccept) m_rowRequestedForAccept = 0; } } diff --git a/src/plugins/coreplugin/locator/locatorwidget.h b/src/plugins/coreplugin/locator/locatorwidget.h index 4484faefdd..c4ce3c4a14 100644 --- a/src/plugins/coreplugin/locator/locatorwidget.h +++ b/src/plugins/coreplugin/locator/locatorwidget.h @@ -27,6 +27,8 @@ #include "locator.h" +#include + #include #include @@ -99,9 +101,9 @@ private: bool m_needsClearResult = true; bool m_updateRequested = false; bool m_possibleToolTipRequest = false; - int m_rowRequestedForAccept = -1; QWidget *m_progressIndicator; QTimer m_showProgressTimer; + Utils::optional m_rowRequestedForAccept; }; class LocatorPopup : public QWidget -- cgit v1.2.3 From c8054d9547ffffd9300340d48033e9f75f3f3e7b Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 14 Jul 2017 11:22:35 +0200 Subject: ProjectExplorer: Heed RunControlFactory priorities again This fixes the regression introduced in 5a848aa18872f and uses the feature to resolve the conflict between ClangStaticAnalyzer and Boot2Qt. Change-Id: I6cdec8261a457c399c11a4b2078a78088d4c56d1 Reviewed-by: Christian Kandeler --- .../clangstaticanalyzerplugin.cpp | 2 +- src/plugins/projectexplorer/runconfiguration.cpp | 24 +++++++++++++++------- src/plugins/projectexplorer/runconfiguration.h | 9 ++++---- 3 files changed, 23 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/plugins/clangstaticanalyzer/clangstaticanalyzerplugin.cpp b/src/plugins/clangstaticanalyzer/clangstaticanalyzerplugin.cpp index f10b2784bb..e18b9747b8 100644 --- a/src/plugins/clangstaticanalyzer/clangstaticanalyzerplugin.cpp +++ b/src/plugins/clangstaticanalyzer/clangstaticanalyzerplugin.cpp @@ -143,7 +143,7 @@ bool ClangStaticAnalyzerPlugin::initialize(const QStringList &arguments, QString }; RunControl::registerWorker - (Constants::CLANGSTATICANALYZER_RUN_MODE, constraint); + (Constants::CLANGSTATICANALYZER_RUN_MODE, constraint, /*priority*/ -1); return true; } diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index d098411706..093c261ad2 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -522,14 +522,24 @@ bool IRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id run RunControl *IRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id runMode, QString *) { + WorkerFactories candidates; for (const RunControl::WorkerFactory &factory : theWorkerFactories()) { - if (factory.canRun(runConfiguration, runMode)) { - auto runControl = new RunControl(runConfiguration, runMode); - factory.producer(runControl); - return runControl; - } - }; - return nullptr; + if (factory.canRun(runConfiguration, runMode)) + candidates.push_back(factory); + } + + if (candidates.empty()) + return nullptr; + + RunControl::WorkerFactory bestFactory = *candidates.begin(); + for (const RunControl::WorkerFactory &factory : candidates) { + if (factory.priority > bestFactory.priority) + bestFactory = factory; + } + + auto runControl = new RunControl(runConfiguration, runMode); + bestFactory.producer(runControl); + return runControl; } /*! diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index eb408c204a..264ec4fd50 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -450,23 +450,24 @@ public: addWorkerFactory({runMode, constraint, producer}); } template - static void registerWorker(Core::Id runMode, const Constraint &constraint) + static void registerWorker(Core::Id runMode, const Constraint &constraint, int priority = 0) { auto producer = [](RunControl *rc) { return new Worker(rc); }; - addWorkerFactory({runMode, constraint, producer}); + addWorkerFactory({runMode, constraint, producer, priority}); } template - static void registerWorker(Core::Id runMode) + static void registerWorker(Core::Id runMode, int priority = 0) { auto constraint = [](RunConfiguration *runConfig) { return qobject_cast(runConfig); }; auto producer = [](RunControl *rc) { return new Worker(rc); }; - addWorkerFactory({runMode, constraint, producer}); + addWorkerFactory({runMode, constraint, producer, priority}); } struct WorkerFactory { Core::Id runMode; Constraint constraint; WorkerCreator producer; + int priority = 0; bool canRun(RunConfiguration *runConfiguration, Core::Id runMode) const; }; -- cgit v1.2.3 From cd5ba755056a70f86fa6b9d7789090f9c84927de Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 13 Jul 2017 15:24:04 +0200 Subject: ProjectExplorer: Use a real 'finishing' phase for RunControls Instead of a blunt delete() RunControl::initiateFinish() is triggered by the closing of the application output instead. The rampdown process is basically the same as stop() now, except for the other success signal (new finished()) and the final self-destruction of the runcontrol. stop() itself triggers initiateStop() on all running workers in parallel (before it was in the order of start). This gives downstream complex worker combinations the flexibility to use any order it wants by ignoring stop() on 'uninteresting' workers, and centralizing rampdown e.g. in the main worker. That setup should be rare in practice, but seems needed in some profiler cases. Change-Id: I986a152a663754206709ed4df0d4568847afad17 Reviewed-by: Christian Kandeler --- src/plugins/projectexplorer/appoutputpane.cpp | 8 +- src/plugins/projectexplorer/appoutputpane.h | 3 +- src/plugins/projectexplorer/runconfiguration.cpp | 176 +++++++++++++++++++---- src/plugins/projectexplorer/runconfiguration.h | 2 + src/plugins/valgrind/memchecktool.cpp | 1 + src/plugins/valgrind/valgrindengine.cpp | 1 - 6 files changed, 160 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/plugins/projectexplorer/appoutputpane.cpp b/src/plugins/projectexplorer/appoutputpane.cpp index 9e0617454b..1e6ef0efd6 100644 --- a/src/plugins/projectexplorer/appoutputpane.cpp +++ b/src/plugins/projectexplorer/appoutputpane.cpp @@ -420,7 +420,8 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc) if (tabIndex != -1) { RunControlTab &tab = m_runControlTabs[tabIndex]; // Reuse this tab - delete tab.runControl; + if (tab.runControl) + tab.runControl->initiateFinish(); tab.runControl = rc; tab.window->setFormatter(rc ? rc->outputFormatter() : nullptr); @@ -559,7 +560,7 @@ bool AppOutputPane::closeTabs(CloseTabMode mode) QList AppOutputPane::allRunControls() const { return Utils::transform(m_runControlTabs,[](const RunControlTab &tab) { - return tab.runControl; + return tab.runControl.data(); }); } @@ -596,7 +597,8 @@ bool AppOutputPane::closeTab(int tabIndex, CloseTabMode closeTabMode) m_tabWidget->removeTab(tabIndex); delete m_runControlTabs[index].window; - delete m_runControlTabs[index].runControl; + m_runControlTabs[index].runControl->initiateFinish(); // Will self-destruct. + m_runControlTabs[index].runControl = 0; m_runControlTabs.removeAt(index); updateCloseActions(); diff --git a/src/plugins/projectexplorer/appoutputpane.h b/src/plugins/projectexplorer/appoutputpane.h index ba3839ca6a..b260447ba5 100644 --- a/src/plugins/projectexplorer/appoutputpane.h +++ b/src/plugins/projectexplorer/appoutputpane.h @@ -25,6 +25,7 @@ #pragma once +#include #include #include @@ -124,7 +125,7 @@ private: public: explicit RunControlTab(RunControl *runControl = nullptr, Core::OutputWindow *window = nullptr); - RunControl *runControl; + QPointer runControl; Core::OutputWindow *window; BehaviorOnOutput behaviorOnOutput = Flash; }; diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 093c261ad2..8cbfaf7fd2 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -602,7 +602,7 @@ static QString stateName(RunWorkerState s) SN(RunWorkerState::Done) SN(RunWorkerState::Failed) } - return QLatin1String(""); + return QString("").arg(int(s)); # undef SN } @@ -616,7 +616,7 @@ public: RunWorker *q; RunWorkerState state = RunWorkerState::Initialized; - RunControl *runControl; + QPointer runControl; QList dependencies; QString id; @@ -635,6 +635,8 @@ enum class RunControlState Running, // All good and running. Stopping, // initiateStop() was called, stop application/tool Stopped, // all good, but stopped. Can possibly be re-started + Finishing, // Application tab manually closed + Finished // Final state, will self-destruct with deleteLater() }; static QString stateName(RunControlState s) @@ -646,8 +648,10 @@ static QString stateName(RunControlState s) SN(RunControlState::Running) SN(RunControlState::Stopping) SN(RunControlState::Stopped) + SN(RunControlState::Finishing) + SN(RunControlState::Finished) } - return QLatin1String(""); + return QString("").arg(int(s)); # undef SN } @@ -669,8 +673,11 @@ public: ~RunControlPrivate() { - QTC_CHECK(state == RunControlState::Stopped || state == RunControlState::Initialized); + QTC_CHECK(state == RunControlState::Finished || state == RunControlState::Initialized); + disconnect(); + q = nullptr; qDeleteAll(m_workers); + m_workers.clear(); delete outputFormatter; } @@ -685,7 +692,7 @@ public: void initiateReStart(); void continueStart(); void initiateStop(); - void continueStop(); + void initiateFinish(); void onWorkerStarted(RunWorker *worker); void onWorkerStopped(RunWorker *worker); @@ -704,7 +711,7 @@ public: Utils::Icon icon; const QPointer runConfiguration; // Not owned. QPointer project; // Not owned. - Utils::OutputFormatter *outputFormatter = nullptr; + QPointer outputFormatter = nullptr; std::function promptToStop; std::vector m_factories; @@ -769,6 +776,11 @@ void RunControl::initiateStop() d->initiateStop(); } +void RunControl::initiateFinish() +{ + d->initiateFinish(); +} + using WorkerCreators = QHash; static WorkerCreators &theWorkerCreators() @@ -890,15 +902,58 @@ void RunControlPrivate::initiateStop() { checkState(RunControlState::Running); setState(RunControlState::Stopping); - debugMessage("Queue: Stopping"); + debugMessage("Queue: Stopping for all workers"); - continueStop(); + bool allDone = true; + for (RunWorker *worker : m_workers) { + if (worker) { + const QString &workerId = worker->d->id; + debugMessage(" Examining worker " + workerId); + switch (worker->d->state) { + case RunWorkerState::Initialized: + debugMessage(" " + workerId + " was Initialized, setting to Done"); + worker->d->state = RunWorkerState::Done; + break; + case RunWorkerState::Stopping: + debugMessage(" " + workerId + " was already Stopping. Keeping it that way"); + allDone = false; + break; + case RunWorkerState::Starting: + debugMessage(" " + workerId + " was Starting, queuing stop"); + worker->d->state = RunWorkerState::Stopping; + QTimer::singleShot(0, worker, &RunWorker::initiateStop); + allDone = false; + break; + case RunWorkerState::Running: + debugMessage(" " + workerId + " was Running, queuing stop"); + worker->d->state = RunWorkerState::Stopping; + allDone = false; + QTimer::singleShot(0, worker, &RunWorker::initiateStop); + break; + case RunWorkerState::Done: + debugMessage(" " + workerId + " was Done. Good."); + break; + case RunWorkerState::Failed: + debugMessage(" " + workerId + " was Failed. Good"); + break; + } + } else { + debugMessage("Found unknown deleted worker"); + } + } + if (allDone) { + debugMessage("All stopped."); + setState(RunControlState::Stopped); + } else { + debugMessage("Not all workers stopped. Waiting..."); + } } -void RunControlPrivate::continueStop() +void RunControlPrivate::initiateFinish() { - debugMessage("Continue Stopping"); - checkState(RunControlState::Stopping); + setState(RunControlState::Finishing); + debugMessage("Ramping down"); + bool allDone = true; for (RunWorker *worker : m_workers) { if (worker) { @@ -914,17 +969,17 @@ void RunControlPrivate::continueStop() allDone = false; break; case RunWorkerState::Starting: - worker->d->state = RunWorkerState::Stopping; debugMessage(" " + workerId + " was Starting, queuing stop"); - allDone = false; + worker->d->state = RunWorkerState::Stopping; QTimer::singleShot(0, worker, &RunWorker::initiateStop); - return; // Sic. + allDone = false; + break; case RunWorkerState::Running: debugMessage(" " + workerId + " was Running, queuing stop"); worker->d->state = RunWorkerState::Stopping; allDone = false; QTimer::singleShot(0, worker, &RunWorker::initiateStop); - return; // Sic. + break; case RunWorkerState::Done: debugMessage(" " + workerId + " was Done. Good."); break; @@ -937,8 +992,9 @@ void RunControlPrivate::continueStop() } } if (allDone) { - debugMessage("All workers stopped. Set runControl to Stopped"); - setState(RunControlState::Stopped); + setState(RunControlState::Finished); + } else { + debugMessage("Not all workers finished. Waiting..."); } } @@ -954,7 +1010,6 @@ void RunControlPrivate::onWorkerStarted(RunWorker *worker) showError(tr("Unexpected run control state %1 when worker %2 started") .arg(stateName(state)) .arg(worker->d->id)); - //setState(RunControlState::Stopped); } void RunControlPrivate::onWorkerFailed(RunWorker *worker, const QString &msg) @@ -978,13 +1033,72 @@ void RunControlPrivate::onWorkerStopped(RunWorker *worker) worker->d->state = RunWorkerState::Done; debugMessage(workerId + " stopped expectedly."); break; + case RunWorkerState::Done: + worker->d->state = RunWorkerState::Done; + debugMessage(workerId + " stopped twice. Huh? But harmless."); + return; // Sic! default: debugMessage(workerId + " stopped unexpectedly in state" + stateName(worker->d->state)); worker->d->state = RunWorkerState::Failed; break; } - continueStop(); + + debugMessage("Checking whether all stopped"); + bool allDone = true; + for (RunWorker *worker : m_workers) { + if (worker) { + const QString &workerId = worker->d->id; + debugMessage(" Examining worker " + workerId); + switch (worker->d->state) { + case RunWorkerState::Initialized: + debugMessage(" " + workerId + " was Initialized, setting to Done"); + worker->d->state = RunWorkerState::Done; + break; + case RunWorkerState::Starting: + worker->d->state = RunWorkerState::Stopping; + debugMessage(" " + workerId + " was Starting, queuing stop"); + allDone = false; + break; + case RunWorkerState::Running: + debugMessage(" " + workerId + " was Running, queuing stop"); + worker->d->state = RunWorkerState::Stopping; + allDone = false; + break; + case RunWorkerState::Stopping: + debugMessage(" " + workerId + " was already Stopping. Keeping it that way"); + allDone = false; + break; + case RunWorkerState::Done: + debugMessage(" " + workerId + " was Done. Good."); + break; + case RunWorkerState::Failed: + debugMessage(" " + workerId + " was Failed. Good"); + break; + } + } else { + debugMessage("Found unknown deleted worker"); + } + } + if (state == RunControlState::Finishing) { + if (allDone) { + debugMessage("All finished. Deleting myself"); + setState(RunControlState::Finished); + } else { + debugMessage("Not all workers finished. Waiting..."); + } + } else { + if (allDone) { + if (state == RunControlState::Stopped) { + debugMessage("All workers stopped, but runControl was already stopped."); + } else { + debugMessage("All workers stopped. Set runControl to Stopped"); + setState(RunControlState::Stopped); + } + } else { + debugMessage("Not all workers stopped. Waiting..."); + } + } } void RunControlPrivate::showError(const QString &msg) @@ -1185,15 +1299,23 @@ bool RunControlPrivate::isAllowedTransition(RunControlState from, RunControlStat { switch (from) { case RunControlState::Initialized: - return to == RunControlState::Starting; + return to == RunControlState::Starting + || to == RunControlState::Finishing; case RunControlState::Starting: - return to == RunControlState::Running; + return to == RunControlState::Running + || to == RunControlState::Finishing; case RunControlState::Running: return to == RunControlState::Stopping - || to == RunControlState::Stopped; + || to == RunControlState::Stopped + || to == RunControlState::Finishing; case RunControlState::Stopping: - return to == RunControlState::Stopped; + return to == RunControlState::Stopped + || to == RunControlState::Finishing; case RunControlState::Stopped: + return to == RunControlState::Finishing; + case RunControlState::Finishing: + return to == RunControlState::Finished; + case RunControlState::Finished: return false; } return false; @@ -1223,11 +1345,13 @@ void RunControlPrivate::setState(RunControlState newState) break; case RunControlState::Stopped: q->setApplicationProcessHandle(Utils::ProcessHandle()); - foreach (auto worker, m_workers) - if (worker) - worker->onFinished(); emit q->stopped(); break; + case RunControlState::Finished: + emit q->finished(); + debugMessage("All finished. Deleting myself"); + deleteLater(); + break; default: break; } diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 264ec4fd50..5a8fe5dbdc 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -397,6 +397,7 @@ public: void initiateStart(); void initiateReStart(); void initiateStop(); + void initiateFinish(); bool promptToStop(bool *optionalPrompt = nullptr) const; void setPromptToStop(const std::function &promptToStop); @@ -480,6 +481,7 @@ signals: void aboutToStart(); void started(); void stopped(); + void finished(); void applicationProcessHandleChanged(QPrivateSignal); // Use setApplicationProcessHandle private: diff --git a/src/plugins/valgrind/memchecktool.cpp b/src/plugins/valgrind/memchecktool.cpp index a69e2eac60..cab6dea44c 100644 --- a/src/plugins/valgrind/memchecktool.cpp +++ b/src/plugins/valgrind/memchecktool.cpp @@ -562,6 +562,7 @@ RunWorker *MemcheckTool::createRunWorker(RunControl *runControl) connect(runTool, &MemcheckToolRunner::internalParserError, this, &MemcheckTool::internalParserError); connect(runTool, &MemcheckToolRunner::stopped, this, &MemcheckTool::engineFinished); + m_stopAction->disconnect(); connect(m_stopAction, &QAction::triggered, runControl, &RunControl::initiateStop); m_toolBusy = true; diff --git a/src/plugins/valgrind/valgrindengine.cpp b/src/plugins/valgrind/valgrindengine.cpp index 3cb1a4245b..13beca1fa0 100644 --- a/src/plugins/valgrind/valgrindengine.cpp +++ b/src/plugins/valgrind/valgrindengine.cpp @@ -106,7 +106,6 @@ void ValgrindToolRunner::stop() { m_isStopping = true; m_runner.stop(); - reportStopped(); // FIXME: Restrict to non-running scenarios? } QString ValgrindToolRunner::executable() const -- cgit v1.2.3 From cb0a09b74bb7279a9845955d6a85a0cfe95048c2 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Mon, 17 Jul 2017 14:43:59 +0200 Subject: ProjectExplorer: Fix compile for older gcc/Qt5.6 Change-Id: I145f2fddb143b1e3149b4b850a7586115ac20df6 Reviewed-by: hjk --- src/plugins/projectexplorer/runconfiguration.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 5a8fe5dbdc..57a39fe374 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -470,6 +470,9 @@ public: WorkerCreator producer; int priority = 0; + WorkerFactory(const Core::Id &mode, Constraint constr, const WorkerCreator &prod, + int prio = 0) + : runMode(mode), constraint(constr), producer(prod), priority(prio) {} bool canRun(RunConfiguration *runConfiguration, Core::Id runMode) const; }; -- cgit v1.2.3 From 6c040996018bbcd32d17e45b82945fecb37352e1 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 14 Jul 2017 10:12:37 +0200 Subject: iOS: Dissolve IosRunControlFactory Follows suite. Change-Id: I2ef11d19d9a2d3d0f3f282a94f98a40478273fbc Reviewed-by: Vikas Pachdha --- src/plugins/ios/iosplugin.cpp | 19 ++++++++++++-- src/plugins/ios/iosrunfactories.cpp | 49 ------------------------------------- src/plugins/ios/iosrunfactories.h | 17 ------------- src/plugins/ios/iosrunner.cpp | 20 +++++++++++++++ 4 files changed, 37 insertions(+), 68 deletions(-) (limited to 'src') diff --git a/src/plugins/ios/iosplugin.cpp b/src/plugins/ios/iosplugin.cpp index 28e590167e..b2b33d8ae3 100644 --- a/src/plugins/ios/iosplugin.cpp +++ b/src/plugins/ios/iosplugin.cpp @@ -36,17 +36,22 @@ #include "iosdsymbuildstep.h" #include "iosqtversionfactory.h" #include "iosrunfactories.h" +#include "iosrunner.h" #include "iossettingspage.h" #include "iossimulator.h" #include "iossimulatorfactory.h" #include "iostoolhandler.h" +#include "iosrunconfiguration.h" +#include #include +#include + #include #include -#include +using namespace ProjectExplorer; namespace Ios { namespace Internal { @@ -67,7 +72,6 @@ bool IosPlugin::initialize(const QStringList &arguments, QString *errorMessage) addAutoReleasedObject(new Internal::IosBuildConfigurationFactory); addAutoReleasedObject(new Internal::IosToolChainFactory); - addAutoReleasedObject(new Internal::IosRunControlFactory); addAutoReleasedObject(new Internal::IosRunConfigurationFactory); addAutoReleasedObject(new Internal::IosSettingsPage); addAutoReleasedObject(new Internal::IosQtVersionFactory); @@ -78,6 +82,17 @@ bool IosPlugin::initialize(const QStringList &arguments, QString *errorMessage) addAutoReleasedObject(new Internal::IosDsymBuildStepFactory); addAutoReleasedObject(new Internal::IosDeployConfigurationFactory); + auto constraint = [](RunConfiguration *runConfig) { + return qobject_cast(runConfig) != nullptr; + }; + + RunControl::registerWorker + (ProjectExplorer::Constants::NORMAL_RUN_MODE, constraint); + RunControl::registerWorker + (ProjectExplorer::Constants::DEBUG_RUN_MODE, constraint); + RunControl::registerWorker + (ProjectExplorer::Constants::QML_PROFILER_RUN_MODE, constraint); + return true; } diff --git a/src/plugins/ios/iosrunfactories.cpp b/src/plugins/ios/iosrunfactories.cpp index b2d42b671b..c41dcb8263 100644 --- a/src/plugins/ios/iosrunfactories.cpp +++ b/src/plugins/ios/iosrunfactories.cpp @@ -27,7 +27,6 @@ #include "iosconstants.h" #include "iosrunconfiguration.h" -#include "iosrunner.h" #include "iosmanager.h" #include @@ -143,53 +142,5 @@ RunConfiguration *IosRunConfigurationFactory::doRestore(Target *parent, const QV return new IosRunConfiguration(parent, id, pathFromId(id)); } -IosRunControlFactory::IosRunControlFactory(QObject *parent) - : IRunControlFactory(parent) -{ -} - -bool IosRunControlFactory::canRun(RunConfiguration *runConfiguration, - Core::Id mode) const -{ - if (mode != ProjectExplorer::Constants::NORMAL_RUN_MODE - && mode != ProjectExplorer::Constants::DEBUG_RUN_MODE - && mode != ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) { - return false; - } - - return qobject_cast(runConfiguration); -} - -RunControl *IosRunControlFactory::create(RunConfiguration *runConfig, - Core::Id mode, QString *errorMessage) -{ - Q_UNUSED(errorMessage); - Q_ASSERT(canRun(runConfig, mode)); - IosRunConfiguration *rc = qobject_cast(runConfig); - Q_ASSERT(rc); - Target *target = runConfig->target(); - QTC_ASSERT(target, return 0); - - Core::Id devId = DeviceKitInformation::deviceId(rc->target()->kit()); - // The device can only run an application at a time, if an app is running stop it. - if (m_activeRunControls.contains(devId)) { - if (QPointer activeRunControl = m_activeRunControls[devId]) - activeRunControl->initiateStop(); - m_activeRunControls.remove(devId); - } - auto runControl = new RunControl(runConfig, mode); - if (mode == ProjectExplorer::Constants::NORMAL_RUN_MODE) { - (void) new Ios::Internal::IosRunSupport(runControl); - } else if (mode == ProjectExplorer::Constants::QML_PROFILER_RUN_MODE) { - (void) new IosQmlProfilerSupport(runControl); - } else { - (void) new IosDebugSupport(runControl); - } - - if (devId.isValid()) - m_activeRunControls[devId] = runControl; - return runControl; -} - } // namespace Internal } // namespace Ios diff --git a/src/plugins/ios/iosrunfactories.h b/src/plugins/ios/iosrunfactories.h index 8e9b072639..318e57e04e 100644 --- a/src/plugins/ios/iosrunfactories.h +++ b/src/plugins/ios/iosrunfactories.h @@ -29,8 +29,6 @@ #include namespace ProjectExplorer { -class RunControl; -class RunConfigWidget; class Target; class Node; } // namespace ProjectExplorer @@ -68,20 +66,5 @@ private: const QVariantMap &map) override; }; -class IosRunControlFactory : public ProjectExplorer::IRunControlFactory -{ - Q_OBJECT - -public: - explicit IosRunControlFactory(QObject *parent = 0); - - bool canRun(ProjectExplorer::RunConfiguration *runConfiguration, - Core::Id mode) const override; - ProjectExplorer::RunControl *create(ProjectExplorer::RunConfiguration *runConfiguration, - Core::Id mode, QString *) override; -private: - mutable QMap > m_activeRunControls; -}; - } // namespace Internal } // namespace Ios diff --git a/src/plugins/ios/iosrunner.cpp b/src/plugins/ios/iosrunner.cpp index 23400d34c7..0a09efe933 100644 --- a/src/plugins/ios/iosrunner.cpp +++ b/src/plugins/ios/iosrunner.cpp @@ -74,9 +74,29 @@ using namespace Utils; namespace Ios { namespace Internal { +static void stopRunningRunControl(RunControl *runControl) +{ + static QMap> activeRunControls; + + RunConfiguration *runConfig = runControl->runConfiguration(); + Target *target = runConfig->target(); + Core::Id devId = DeviceKitInformation::deviceId(target->kit()); + + // The device can only run an application at a time, if an app is running stop it. + if (activeRunControls.contains(devId)) { + if (QPointer activeRunControl = activeRunControls[devId]) + activeRunControl->initiateStop(); + activeRunControls.remove(devId); + } + + if (devId.isValid()) + activeRunControls[devId] = runControl; +} + IosRunner::IosRunner(RunControl *runControl) : RunWorker(runControl) { + stopRunningRunControl(runControl); auto runConfig = qobject_cast(runControl->runConfiguration()); m_bundleDir = runConfig->bundleDirectory().toString(); m_arguments = QStringList(runConfig->commandLineArguments()); -- cgit v1.2.3 From b7babda68d1bfc162a4e5497e9645df9da221474 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 13 Jul 2017 17:00:29 +0200 Subject: iOS: Remove unneeded abortDebugger call Change-Id: Ib4a4897e61b74cfed54a77b367fcad8932a47b9f Reviewed-by: Vikas Pachdha --- src/plugins/ios/iosrunner.cpp | 5 ----- src/plugins/ios/iosrunner.h | 1 - 2 files changed, 6 deletions(-) (limited to 'src') diff --git a/src/plugins/ios/iosrunner.cpp b/src/plugins/ios/iosrunner.cpp index 0a09efe933..7ecd50b836 100644 --- a/src/plugins/ios/iosrunner.cpp +++ b/src/plugins/ios/iosrunner.cpp @@ -533,10 +533,5 @@ void IosDebugSupport::start() DebuggerRunTool::start(); } -void IosDebugSupport::onFinished() -{ - abortDebugger(); -} - } // namespace Internal } // namespace Ios diff --git a/src/plugins/ios/iosrunner.h b/src/plugins/ios/iosrunner.h index 203ae87909..2db7cf8c0d 100644 --- a/src/plugins/ios/iosrunner.h +++ b/src/plugins/ios/iosrunner.h @@ -135,7 +135,6 @@ public: private: void start() override; - void onFinished() override; const QString m_dumperLib; IosRunner *m_runner; -- cgit v1.2.3 From d93da5f5f1f5cbc15c093e05a5a22829322e5685 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 14 Jul 2017 09:36:09 +0200 Subject: ProjectExplorer: Add and use a RunConfiguration::registerAspect<> ... to register RunConfigurationAspect creating functions. Change-Id: I9e7a2cef0bc134ac6a7becbd0b5ecb40c26ef118 Reviewed-by: hjk --- src/plugins/debugger/debuggerplugin.cpp | 14 +------------ src/plugins/projectexplorer/runconfiguration.cpp | 26 ++++++------------------ src/plugins/projectexplorer/runconfiguration.h | 10 ++++++--- src/plugins/qmlprofiler/qmlprofilerplugin.cpp | 13 ++---------- src/plugins/valgrind/valgrindplugin.cpp | 12 ++--------- 5 files changed, 18 insertions(+), 57 deletions(-) (limited to 'src') diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 832a343540..38d867c878 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -421,18 +421,6 @@ namespace Internal { void addCdbOptionPages(QList *opts); void addGdbOptionPages(QList *opts); -/// DebuggerRunControlFactory - -class DebuggerRunControlFactory : public IRunControlFactory -{ -public: - IRunConfigurationAspect *createRunConfigurationAspect(RunConfiguration *rc) override - { - return new DebuggerRunConfigurationAspect(rc); - } -}; - - static QIcon visibleStartIcon(Id id, bool toolBarStyle) { if (id == Id(Constants::DEBUG)) { @@ -1495,7 +1483,7 @@ bool DebuggerPluginPrivate::initialize(const QStringList &arguments, m_localsAndExpressionsWindow->setObjectName(QLatin1String(DOCKWIDGET_WATCHERS)); m_localsAndExpressionsWindow->setWindowTitle(m_localsWindow->windowTitle()); - m_plugin->addAutoReleasedObject(new DebuggerRunControlFactory); + RunConfiguration::registerAspect(); // The main "Start Debugging" action. act = m_startAction = new QAction(this); diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 8cbfaf7fd2..345cbcd5cc 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -183,13 +183,16 @@ void IRunConfigurationAspect::resetProjectToGlobalSettings() for a target, but still be runnable via the output tab. */ +static std::vector theAspectFactories; + RunConfiguration::RunConfiguration(Target *target, Core::Id id) : ProjectConfiguration(target, id) { Q_ASSERT(target); ctor(); - addExtraAspects(); + for (const AspectFactory &factory : theAspectFactories) + addExtraAspect(factory(this)); } RunConfiguration::RunConfiguration(Target *target, RunConfiguration *source) : @@ -209,10 +212,9 @@ RunConfiguration::~RunConfiguration() qDeleteAll(m_aspects); } -void RunConfiguration::addExtraAspects() +void RunConfiguration::addAspectFactory(const AspectFactory &aspectFactory) { - foreach (IRunControlFactory *factory, ExtensionSystem::PluginManager::getObjects()) - addExtraAspect(factory->createRunConfigurationAspect(this)); + theAspectFactories.push_back(aspectFactory); } void RunConfiguration::addExtraAspect(IRunConfigurationAspect *aspect) @@ -542,22 +544,6 @@ RunControl *IRunControlFactory::create(RunConfiguration *runConfiguration, Core: return runControl; } -/*! - Returns an IRunConfigurationAspect to carry options for RunControls this - factory can create. - - If no extra options are required, it is allowed to return null like the - default implementation does. This function is intended to be called from the - RunConfiguration constructor, so passing a RunConfiguration pointer makes - no sense because that object is under construction at the time. -*/ - -IRunConfigurationAspect *IRunControlFactory::createRunConfigurationAspect(RunConfiguration *rc) -{ - Q_UNUSED(rc); - return nullptr; -} - /*! \class ProjectExplorer::RunControl \brief The RunControl class instances represent one item that is run. diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 57a39fe374..0b9b3618de 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -245,6 +245,12 @@ public: static RunConfiguration *startupRunConfiguration(); + using AspectFactory = std::function; + template static void registerAspect() + { + addAspectFactory([](RunConfiguration *rc) { return new T(rc); }); + } + signals: void enabledChanged(); void requestRunActionsUpdate(); @@ -260,7 +266,7 @@ protected: private: void ctor(); - void addExtraAspects(); + static void addAspectFactory(const AspectFactory &aspectFactory); QList m_aspects; }; @@ -304,8 +310,6 @@ public: virtual bool canRun(RunConfiguration *runConfiguration, Core::Id runMode) const; virtual RunControl *create(RunConfiguration *runConfiguration, Core::Id runMode, QString *errorMessage); - virtual IRunConfigurationAspect *createRunConfigurationAspect(RunConfiguration *rc); - int priority() const; protected: void setPriority(int priority); // Higher values will be preferred. diff --git a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp index 777a042fc1..ea89b6b6dc 100644 --- a/src/plugins/qmlprofiler/qmlprofilerplugin.cpp +++ b/src/plugins/qmlprofiler/qmlprofilerplugin.cpp @@ -76,16 +76,6 @@ namespace Internal { Q_GLOBAL_STATIC(QmlProfilerSettings, qmlProfilerGlobalSettings) - -class QmlProfilerRunControlFactory : public IRunControlFactory -{ -public: - IRunConfigurationAspect *createRunConfigurationAspect(RunConfiguration *rc) override - { - return new QmlProfilerRunConfigurationAspect(rc); - } -}; - bool QmlProfilerPlugin::initialize(const QStringList &arguments, QString *errorString) { Q_UNUSED(arguments) @@ -101,7 +91,8 @@ void QmlProfilerPlugin::extensionsInitialized() (void) new QmlProfilerTool(this); addAutoReleasedObject(new QmlProfilerOptionsPage); - addAutoReleasedObject(new QmlProfilerRunControlFactory); + + RunConfiguration::registerAspect(); auto constraint = [](RunConfiguration *runConfiguration) { Target *target = runConfiguration ? runConfiguration->target() : nullptr; diff --git a/src/plugins/valgrind/valgrindplugin.cpp b/src/plugins/valgrind/valgrindplugin.cpp index 4cb71eab68..4e250b8b19 100644 --- a/src/plugins/valgrind/valgrindplugin.cpp +++ b/src/plugins/valgrind/valgrindplugin.cpp @@ -110,15 +110,6 @@ public: } }; -class ValgrindRunControlFactory : public IRunControlFactory -{ -public: - IRunConfigurationAspect *createRunConfigurationAspect(RunConfiguration *rc) override - { - return new ValgrindRunConfigurationAspect(rc); - } -}; - ValgrindPlugin::~ValgrindPlugin() { delete theGlobalSettings; @@ -131,7 +122,8 @@ bool ValgrindPlugin::initialize(const QStringList &, QString *) theGlobalSettings->readSettings(); addAutoReleasedObject(new ValgrindOptionsPage); - addAutoReleasedObject(new ValgrindRunControlFactory); + + RunConfiguration::registerAspect(); return true; } -- cgit v1.2.3 From 528b0918bf943256ed41bfec8ca18bcace408ce5 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 13 Jul 2017 17:39:42 +0200 Subject: ProjectExplorer: Remove RunControl::bringApplicationToForeground ... and replace it by direct uses of ProcessHandle::activate(). Change-Id: I7beffba7bfbeff72a81b8699ff54a311a74ce1a3 Reviewed-by: Christian Stenger --- src/plugins/debugger/debuggerengine.cpp | 8 +------- src/plugins/debugger/qml/qmlengine.cpp | 2 +- src/plugins/projectexplorer/runconfiguration.cpp | 17 +++-------------- src/plugins/projectexplorer/runconfiguration.h | 1 - 4 files changed, 5 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/plugins/debugger/debuggerengine.cpp b/src/plugins/debugger/debuggerengine.cpp index e60af1faa8..efc1680458 100644 --- a/src/plugins/debugger/debuggerengine.cpp +++ b/src/plugins/debugger/debuggerengine.cpp @@ -292,12 +292,6 @@ public: } } - void raiseApplication() - { - QTC_ASSERT(runControl(), return); - runControl()->bringApplicationToForeground(); - } - void scheduleResetLocation() { m_stackHandler.scheduleResetLocation(); @@ -1323,7 +1317,7 @@ void DebuggerEngine::notifyInferiorPid(const ProcessHandle &pid) showMessage(tr("Taking notice of pid %1").arg(pid.pid())); DebuggerStartMode sm = runParameters().startMode; if (sm == StartInternal || sm == StartExternal || sm == AttachExternal) - QTimer::singleShot(0, d, &DebuggerEnginePrivate::raiseApplication); + d->m_inferiorPid.activate(); } } diff --git a/src/plugins/debugger/qml/qmlengine.cpp b/src/plugins/debugger/qml/qmlengine.cpp index 0a0ed1d516..10e6d4f3b2 100644 --- a/src/plugins/debugger/qml/qmlengine.cpp +++ b/src/plugins/debugger/qml/qmlengine.cpp @@ -377,7 +377,7 @@ void QmlEngine::handleLauncherStarted() { // FIXME: The QmlEngine never calls notifyInferiorPid() triggering the // raising, so do it here manually for now. - runControl()->bringApplicationToForeground(); + runControl()->applicationProcessHandle().activate(); d->noDebugOutputTimer.start(); } diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 345cbcd5cc..566ecc6912 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -1348,18 +1348,6 @@ void RunControlPrivate::debugMessage(const QString &msg) qCDebug(statesLog()) << msg; } -/*! - Brings the application determined by this RunControl's \c applicationProcessHandle - to the foreground. - - The default implementation raises the application on Mac, and does - nothing elsewhere. -*/ -void RunControl::bringApplicationToForeground() -{ - d->applicationProcessHandle.activate(); -} - void RunControl::appendMessage(const QString &msg, Utils::OutputFormat format) { emit appendMessageRequested(this, msg, format); @@ -1478,8 +1466,9 @@ void SimpleTargetRunner::stop() void SimpleTargetRunner::onProcessStarted() { // Console processes only know their pid after being started - runControl()->setApplicationProcessHandle(m_launcher.applicationPID()); - runControl()->bringApplicationToForeground(); + ProcessHandle pid = m_launcher.applicationPID(); + runControl()->setApplicationProcessHandle(pid); + pid.activate(); reportStarted(); } diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 0b9b3618de..4d49d434ea 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -435,7 +435,6 @@ public: void setRunnable(const Runnable &runnable); virtual void appendMessage(const QString &msg, Utils::OutputFormat format); - virtual void bringApplicationToForeground(); static bool showPromptToStopDialog(const QString &title, const QString &text, const QString &stopButtonText = QString(), -- cgit v1.2.3 From eebac87be558c9a269a748c09da75a97de643183 Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Mon, 17 Jul 2017 13:36:39 +0300 Subject: ProjectTree: Enable Synchronize with Editor by default Changed by 4943510b60acc320dff8f2c31af69cfbfa331203. Change-Id: I359c4abd77009b22bc1a7143002563f66a3b5fd0 Reviewed-by: Tobias Hunger --- src/plugins/projectexplorer/projecttreewidget.cpp | 2 +- src/plugins/projectexplorer/projecttreewidget.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/plugins/projectexplorer/projecttreewidget.cpp b/src/plugins/projectexplorer/projecttreewidget.cpp index 372dbdb757..2a98fbe86e 100644 --- a/src/plugins/projectexplorer/projecttreewidget.cpp +++ b/src/plugins/projectexplorer/projecttreewidget.cpp @@ -489,5 +489,5 @@ void ProjectTreeWidgetFactory::restoreSettings(QSettings *settings, int position const QString baseKey = QLatin1String("ProjectTreeWidget.") + QString::number(position); ptw->setProjectFilter(settings->value(baseKey + QLatin1String(".ProjectFilter"), false).toBool()); ptw->setGeneratedFilesFilter(settings->value(baseKey + QLatin1String(".GeneratedFilter"), true).toBool()); - ptw->setAutoSynchronization(settings->value(baseKey + QLatin1String(".SyncWithEditor")).toBool()); + ptw->setAutoSynchronization(settings->value(baseKey + QLatin1String(".SyncWithEditor"), true).toBool()); } diff --git a/src/plugins/projectexplorer/projecttreewidget.h b/src/plugins/projectexplorer/projecttreewidget.h index 072cc1f1ab..69102fedb0 100644 --- a/src/plugins/projectexplorer/projecttreewidget.h +++ b/src/plugins/projectexplorer/projecttreewidget.h @@ -87,7 +87,7 @@ private: QToolButton *m_toggleSync; QString m_modelId; - bool m_autoSync = false; + bool m_autoSync = true; Utils::FileName m_delayedRename; static QList m_projectTreeWidgets; -- cgit v1.2.3 From a196170df9e1decf9fb5e755b9ae411ae4ef7b9e Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 18 Jul 2017 08:51:26 +0200 Subject: Debugger: Fix removing items from modules model Change-Id: Icce09b890e9a4a5cca142ee5307fd6f42bd5c839 Reviewed-by: hjk --- src/plugins/debugger/moduleshandler.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/debugger/moduleshandler.cpp b/src/plugins/debugger/moduleshandler.cpp index 94d558851a..e37c44ccbb 100644 --- a/src/plugins/debugger/moduleshandler.cpp +++ b/src/plugins/debugger/moduleshandler.cpp @@ -327,7 +327,8 @@ void ModulesHandler::endUpdateAll() if (!item->updated) toDestroy.append(item); }); - qDeleteAll(toDestroy); + for (TreeItem *item : toDestroy) + m_model->destroyItem(item); } } // namespace Internal -- cgit v1.2.3 From 862dd4c6bffc7b9b4b0465f5edb7e673331b54a5 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Wed, 5 Jul 2017 11:09:07 +0200 Subject: TextEditor: Simplify annotation rectangle computation Change-Id: Ie04f545d24696d66645c367b2c25d643c3691908 Reviewed-by: Nikolai Kosjar --- src/plugins/texteditor/texteditor.cpp | 2 +- src/plugins/texteditor/textmark.cpp | 50 +++++++++++++++++++++-------------- src/plugins/texteditor/textmark.h | 10 ++++++- 3 files changed, 40 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 4c9711a67c..7e8c1c2345 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -3821,7 +3821,7 @@ void TextEditorWidgetPrivate::drawLineAnnotation(QPainter &painter, const QTextB QRectF annotationRect(x, lineRect.top(), q->viewport()->width() - x, lineRect.height()); if (annotationRect.width() <= 0) break; - mark->paintAnnotation(&painter, &annotationRect, q->fontMetrics()); + mark->paintAnnotation(&painter, &annotationRect); x += annotationRect.width() + itemOffset; m_annotationRects[block.blockNumber()].append({annotationRect, mark}); } diff --git a/src/plugins/texteditor/textmark.cpp b/src/plugins/texteditor/textmark.cpp index 15939a3f44..254999f1b3 100644 --- a/src/plugins/texteditor/textmark.cpp +++ b/src/plugins/texteditor/textmark.cpp @@ -123,42 +123,52 @@ void TextMark::paintIcon(QPainter *painter, const QRect &rect) const m_icon.paint(painter, rect, Qt::AlignCenter); } -void TextMark::paintAnnotation(QPainter *painter, - QRectF *annotationRect, - const QFontMetrics &fm) const +void TextMark::paintAnnotation(QPainter *painter, QRectF *annotationRect) const { QString text = lineAnnotation(); if (text.isEmpty()) return; - const bool drawIcon = !m_icon.isNull(); - int textWidth = fm.width(text); - constexpr qreal margin = 1; - const qreal iconHeight = annotationRect->height() - 2 * margin; - const qreal iconWidth = iconHeight * m_widthFactor + 2 * margin; - qreal annotationWidth = (drawIcon ? textWidth + iconWidth : textWidth) + margin; - if (annotationRect->left() + annotationWidth > annotationRect->right()) { - textWidth = int(annotationRect->width() - (drawIcon ? iconWidth + margin : margin)); - text = fm.elidedText(text, Qt::ElideRight, textWidth); - annotationWidth = annotationRect->width(); - } + const AnnotationRects &rects = annotationRects(*annotationRect, painter->fontMetrics()); + const QColor markColor = m_hasColor ? Utils::creatorTheme()->color(m_color).toHsl() : painter->pen().color(); const AnnotationColors &colors = AnnotationColors::getAnnotationColors(markColor, painter->background().color()); painter->save(); - annotationRect->setWidth(annotationWidth); painter->setPen(colors.rectColor); painter->setBrush(colors.rectColor); - painter->drawRect(*annotationRect); + painter->drawRect(rects.annotationRect); painter->setPen(colors.textColor); + paintIcon(painter, rects.iconRect.toAlignedRect()); + painter->drawText(rects.textRect, Qt::AlignLeft, rects.text); + painter->restore(); + *annotationRect = rects.annotationRect; +} + +TextMark::AnnotationRects TextMark::annotationRects(const QRectF &boundingRect, + const QFontMetrics &fm) const +{ + AnnotationRects rects; + rects.annotationRect = boundingRect; + rects.text = lineAnnotation(); + const bool drawIcon = !m_icon.isNull(); + constexpr qreal margin = 1; + rects.iconRect = QRectF(boundingRect.left() + margin, boundingRect.top() + margin, 0, 0); if (drawIcon) { - paintIcon(painter, annotationRect->adjusted( - margin, margin, -(textWidth + 2 * margin), -margin).toAlignedRect()); + rects.iconRect.setHeight(boundingRect.height() - 2 * margin); + rects.iconRect.setWidth(rects.iconRect.height() * m_widthFactor); } - painter->drawText(annotationRect->adjusted(iconWidth, 0, 0, 0), Qt::AlignLeft, text); - painter->restore(); + rects.textRect = QRectF(rects.iconRect.right() + margin, boundingRect.top(), + qreal(fm.width(rects.text)), boundingRect.height()); + rects.annotationRect.setRight(rects.textRect.right() + margin); + if (rects.annotationRect.right() > boundingRect.right()) { + rects.textRect.setRight(boundingRect.right() - margin); + rects.text = fm.elidedText(rects.text, Qt::ElideRight, int(rects.textRect.width())); + rects.annotationRect.setRight(boundingRect.right()); + } + return rects; } void TextMark::updateLineNumber(int lineNumber) diff --git a/src/plugins/texteditor/textmark.h b/src/plugins/texteditor/textmark.h index 89d3d96e02..ca484a8538 100644 --- a/src/plugins/texteditor/textmark.h +++ b/src/plugins/texteditor/textmark.h @@ -64,7 +64,15 @@ public: int lineNumber() const; virtual void paintIcon(QPainter *painter, const QRect &rect) const; - virtual void paintAnnotation(QPainter *painter, QRectF *annotationRect, const QFontMetrics &fm) const; + virtual void paintAnnotation(QPainter *painter, QRectF *annotationRect) const; + struct AnnotationRects + { + QRectF annotationRect; + QRectF iconRect; + QRectF textRect; + QString text; + }; + virtual AnnotationRects annotationRects(const QRectF &boundingRect, const QFontMetrics &fm) const; /// called if the filename of the document changed virtual void updateFileName(const QString &fileName); virtual void updateLineNumber(int lineNumber); -- cgit v1.2.3 From 3b22cd3e203c3dac2975984bf7ae2a0fa6656bc8 Mon Sep 17 00:00:00 2001 From: hjk Date: Mon, 17 Jul 2017 09:37:34 +0200 Subject: Debugger: Describe the "Override server address/channel" field better Change-Id: I2bd112d1d2f46904513fa668a17f0a07ebe26e12 Reviewed-by: Leena Miettinen Reviewed-by: Rainer Keller --- src/plugins/debugger/debuggerdialogs.cpp | 36 +++++++++++++++++++++++--------- src/plugins/debugger/debuggerdialogs.h | 1 + 2 files changed, 27 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp index c247c22a43..f9017a7f41 100644 --- a/src/plugins/debugger/debuggerdialogs.cpp +++ b/src/plugins/debugger/debuggerdialogs.cpp @@ -71,8 +71,8 @@ class StartApplicationDialogPrivate public: KitChooser *kitChooser; QLabel *serverPortLabel; - QLabel *serverAddressLabel; - QLineEdit *serverAddressEdit; + QLabel *channelOverrideLabel; + QLineEdit *channelOverrideEdit; QSpinBox *serverPortSpinBox; PathChooser *localExecutablePathChooser; FancyLineEdit *arguments; @@ -235,8 +235,11 @@ StartApplicationDialog::StartApplicationDialog(QWidget *parent) d->serverPortSpinBox = new QSpinBox(this); d->serverPortSpinBox->setRange(1, 65535); - d->serverAddressLabel = new QLabel(tr("Override server address"), this); - d->serverAddressEdit = new QLineEdit(this); + d->channelOverrideLabel = new QLabel(tr("Override server channel:"), this); + d->channelOverrideEdit = new QLineEdit(this); + //: "For example, /dev/ttyS0, COM1, 127.0.0.1:1234" + d->channelOverrideEdit->setPlaceholderText( + tr("For example, %1").arg("/dev/ttyS0, COM1, 127.0.0.1:1234")); d->localExecutablePathChooser = new PathChooser(this); d->localExecutablePathChooser->setExpectedKind(PathChooser::File); @@ -292,7 +295,6 @@ StartApplicationDialog::StartApplicationDialog(QWidget *parent) formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); formLayout->addRow(tr("&Kit:"), d->kitChooser); formLayout->addRow(d->serverPortLabel, d->serverPortSpinBox); - formLayout->addRow(d->serverAddressLabel, d->serverAddressEdit); formLayout->addRow(tr("Local &executable:"), d->localExecutablePathChooser); formLayout->addRow(tr("Command line &arguments:"), d->arguments); formLayout->addRow(tr("&Working directory:"), d->workingDirectory); @@ -300,6 +302,11 @@ StartApplicationDialog::StartApplicationDialog(QWidget *parent) formLayout->addRow(tr("Break at \"&main\":"), d->breakAtMainCheckBox); formLayout->addRow(d->serverStartScriptLabel, d->serverStartScriptPathChooser); formLayout->addRow(tr("Debug &information:"), d->debuginfoPathChooser); + formLayout->addRow(new QLabel(tr("Normally, the running server is identified by the IP of the " + "device in the kit and the server port selected above.\n" + "You can choose another communication channel here, such as " + "a serial line or custom ip:port."))); + formLayout->addRow(d->channelOverrideLabel, d->channelOverrideEdit); formLayout->addRow(line2); formLayout->addRow(tr("&Recent:"), d->historyComboBox); @@ -316,6 +323,9 @@ StartApplicationDialog::StartApplicationDialog(QWidget *parent) connect(d->historyComboBox, static_cast(&QComboBox::currentIndexChanged), this, &StartApplicationDialog::historyIndexChanged); + connect(d->channelOverrideEdit, &QLineEdit::textChanged, + this, &StartApplicationDialog::onChannelOverrideChanged); + updateState(); } @@ -334,6 +344,12 @@ void StartApplicationDialog::setHistory(const QList } } +void StartApplicationDialog::onChannelOverrideChanged(const QString &channel) +{ + d->serverPortSpinBox->setEnabled(channel.isEmpty()); + d->serverPortLabel->setEnabled(channel.isEmpty()); +} + void StartApplicationDialog::historyIndexChanged(int index) { if (index < 0) @@ -379,8 +395,8 @@ bool StartApplicationDialog::run(QWidget *parent, DebuggerRunParameters *rp, Kit dialog.d->serverStartScriptLabel->setVisible(false); dialog.d->serverPortSpinBox->setVisible(false); dialog.d->serverPortLabel->setVisible(false); - dialog.d->serverAddressLabel->setVisible(false); - dialog.d->serverAddressEdit->setVisible(false); + dialog.d->channelOverrideLabel->setVisible(false); + dialog.d->channelOverrideEdit->setVisible(false); } if (dialog.exec() != QDialog::Accepted) return false; @@ -404,7 +420,7 @@ bool StartApplicationDialog::run(QWidget *parent, DebuggerRunParameters *rp, Kit } rp->inferior.executable = newParameters.runnable.executable; - const QString inputAddress = dialog.d->serverAddressEdit->text(); + const QString inputAddress = dialog.d->channelOverrideEdit->text(); if (!inputAddress.isEmpty()) rp->remoteChannel = inputAddress; else @@ -430,7 +446,7 @@ StartApplicationParameters StartApplicationDialog::parameters() const { StartApplicationParameters result; result.serverPort = d->serverPortSpinBox->value(); - result.serverAddress = d->serverAddressEdit->text(); + result.serverAddress = d->channelOverrideEdit->text(); result.runnable.executable = d->localExecutablePathChooser->path(); result.serverStartScript = d->serverStartScriptPathChooser->path(); result.kitId = d->kitChooser->currentKitId(); @@ -447,7 +463,7 @@ void StartApplicationDialog::setParameters(const StartApplicationParameters &p) { d->kitChooser->setCurrentKitId(p.kitId); d->serverPortSpinBox->setValue(p.serverPort); - d->serverAddressEdit->setText(p.serverAddress); + d->channelOverrideEdit->setText(p.serverAddress); d->localExecutablePathChooser->setPath(p.runnable.executable); d->serverStartScriptPathChooser->setPath(p.serverStartScript); d->debuginfoPathChooser->setPath(p.debugInfoLocation); diff --git a/src/plugins/debugger/debuggerdialogs.h b/src/plugins/debugger/debuggerdialogs.h index 60cdedefeb..b291dbbe26 100644 --- a/src/plugins/debugger/debuggerdialogs.h +++ b/src/plugins/debugger/debuggerdialogs.h @@ -80,6 +80,7 @@ private: StartApplicationParameters parameters() const; void setParameters(const StartApplicationParameters &p); void setHistory(const QList &l); + void onChannelOverrideChanged(const QString &channel); StartApplicationDialogPrivate *d; }; -- cgit v1.2.3 From ba7f7bcf0f8a89d0f1ca9cf8a619b9cb5f2c7918 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 13 Jul 2017 16:57:04 +0200 Subject: ClangStaticAnalyzer: Remove a few + QLatinChar('\n') It's implicit in appendMessage nowadays. Change-Id: I4f1bdde4d4127579d4b26cd275def59c65f18f2f Reviewed-by: Nikolai Kosjar --- .../clangstaticanalyzerruncontrol.cpp | 30 ++++++++++------------ 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp index ff078f612e..33b7f4f807 100644 --- a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp +++ b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp @@ -502,8 +502,8 @@ void ClangStaticAnalyzerToolRunner::start() QTC_ASSERT(m_projectInfo.isValid(), reportFailure(); return); const Utils::FileName projectFile = m_projectInfo.project()->projectFilePath(); - appendMessage(tr("Running Clang Static Analyzer on %1").arg(projectFile.toUserOutput()) - + QLatin1Char('\n'), Utils::NormalMessageFormat); + appendMessage(tr("Running Clang Static Analyzer on %1").arg(projectFile.toUserOutput()), + Utils::NormalMessageFormat); // Check clang executable bool isValidClangExecutable; @@ -512,7 +512,7 @@ void ClangStaticAnalyzerToolRunner::start() if (!isValidClangExecutable) { const QString errorMessage = tr("Clang Static Analyzer: Invalid executable \"%1\", stop.") .arg(executable); - appendMessage(errorMessage + QLatin1Char('\n'), Utils::ErrorMessageFormat); + appendMessage(errorMessage, Utils::ErrorMessageFormat); TaskHub::addTask(Task::Error, errorMessage, Debugger::Constants::ANALYZERTASK_ID); TaskHub::requestPopup(); reportFailure(); @@ -527,7 +527,7 @@ void ClangStaticAnalyzerToolRunner::start() = tr("Clang Static Analyzer: Running with possibly unsupported version, " "could not determine version from executable \"%1\".") .arg(versionCheckExecutable); - appendMessage(warningMessage + QLatin1Char('\n'), Utils::StdErrFormat); + appendMessage(warningMessage, Utils::StdErrFormat); TaskHub::addTask(Task::Warning, warningMessage, Debugger::Constants::ANALYZERTASK_ID); TaskHub::requestPopup(); } else if (!version.isSupportedVersion()) { @@ -536,7 +536,7 @@ void ClangStaticAnalyzerToolRunner::start() "supported version is %2.") .arg(version.toString()) .arg(ClangExecutableVersion::supportedVersionAsString()); - appendMessage(warningMessage + QLatin1Char('\n'), Utils::StdErrFormat); + appendMessage(warningMessage, Utils::StdErrFormat); TaskHub::addTask(Task::Warning, warningMessage, Debugger::Constants::ANALYZERTASK_ID); TaskHub::requestPopup(); } @@ -549,7 +549,7 @@ void ClangStaticAnalyzerToolRunner::start() if (!temporaryDir.isValid()) { const QString errorMessage = tr("Clang Static Analyzer: Failed to create temporary dir, stop."); - appendMessage(errorMessage + QLatin1Char('\n'), Utils::ErrorMessageFormat); + appendMessage(errorMessage, Utils::ErrorMessageFormat); TaskHub::addTask(Task::Error, errorMessage, Debugger::Constants::ANALYZERTASK_ID); TaskHub::requestPopup(); reportFailure(errorMessage); @@ -604,7 +604,7 @@ void ClangStaticAnalyzerToolRunner::stop() } m_runners.clear(); m_unitsToProcess.clear(); - appendMessage(tr("Clang Static Analyzer stopped by user.") + QLatin1Char('\n'), + appendMessage(tr("Clang Static Analyzer stopped by user."), Utils::NormalMessageFormat); m_progress.reportFinished(); ClangStaticAnalyzerTool::instance()->onEngineFinished(m_success); @@ -630,7 +630,7 @@ void ClangStaticAnalyzerToolRunner::analyzeNextFile() QTC_ASSERT(runner->run(unit.file, unit.arguments), return); appendMessage(tr("Analyzing \"%1\".").arg( - Utils::FileName::fromString(unit.file).toUserOutput()) + QLatin1Char('\n'), + Utils::FileName::fromString(unit.file).toUserOutput()), Utils::StdOutFormat); } @@ -659,9 +659,8 @@ void ClangStaticAnalyzerToolRunner::onRunnerFinishedWithSuccess(const QString &l if (!errorMessage.isEmpty()) { qCDebug(LOG) << "onRunnerFinishedWithSuccess: Error reading log file:" << errorMessage; const QString filePath = qobject_cast(sender())->filePath(); - appendMessage(tr("Failed to analyze \"%1\": %2").arg(filePath, errorMessage) - + QLatin1Char('\n') - , Utils::StdErrFormat); + appendMessage(tr("Failed to analyze \"%1\": %2").arg(filePath, errorMessage), + Utils::StdErrFormat); } else { ++m_filesAnalyzed; if (!diagnostics.isEmpty()) @@ -680,9 +679,8 @@ void ClangStaticAnalyzerToolRunner::onRunnerFinishedWithFailure(const QString &e ++m_filesNotAnalyzed; m_success = false; const QString filePath = qobject_cast(sender())->filePath(); - appendMessage(tr("Failed to analyze \"%1\": %2").arg(filePath, errorMessage) - + QLatin1Char('\n') - , Utils::StdErrFormat); + appendMessage(tr("Failed to analyze \"%1\": %2").arg(filePath, errorMessage), + Utils::StdErrFormat); appendMessage(errorDetails, Utils::StdErrFormat); TaskHub::addTask(Task::Warning, errorMessage, Debugger::Constants::ANALYZERTASK_ID); TaskHub::addTask(Task::Warning, errorDetails, Debugger::Constants::ANALYZERTASK_ID); @@ -712,9 +710,7 @@ void ClangStaticAnalyzerToolRunner::finalize() { appendMessage(tr("Clang Static Analyzer finished: " "Processed %1 files successfully, %2 failed.") - .arg(m_filesAnalyzed) - .arg(m_filesNotAnalyzed) - + QLatin1Char('\n'), + .arg(m_filesAnalyzed).arg(m_filesNotAnalyzed), Utils::NormalMessageFormat); if (m_filesNotAnalyzed != 0) { -- cgit v1.2.3 From c5cc3e25947a1e215627142b9947f83bad948869 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 4 Jul 2017 13:24:38 +0200 Subject: ClangStaticAnalyzer: Don't get stuck if project is not buildable Task-number: QTCREATORBUG-18495 Change-Id: I6621ceebd05be2fabcdcd3061e41e4674e5fbb26 Reviewed-by: Nikolai Kosjar --- .../clangstaticanalyzerruncontrol.cpp | 1 + .../clangstaticanalyzer/clangstaticanalyzertool.cpp | 19 ++++++++++++------- .../clangstaticanalyzer/clangstaticanalyzertool.h | 3 ++- 3 files changed, 15 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp index 33b7f4f807..98a0788ebc 100644 --- a/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp +++ b/src/plugins/clangstaticanalyzer/clangstaticanalyzerruncontrol.cpp @@ -81,6 +81,7 @@ ClangStaticAnalyzerToolRunner::ClangStaticAnalyzerToolRunner(RunControl *runCont auto tool = ClangStaticAnalyzerTool::instance(); tool->stopAction()->disconnect(); connect(tool->stopAction(), &QAction::triggered, runControl, &RunControl::initiateStop); + tool->handleWorkerStart(this); ProjectInfo projectInfoBeforeBuild = tool->projectInfoBeforeBuild(); QTC_ASSERT(projectInfoBeforeBuild.isValid(), return); diff --git a/src/plugins/clangstaticanalyzer/clangstaticanalyzertool.cpp b/src/plugins/clangstaticanalyzer/clangstaticanalyzertool.cpp index c8f1f6c8ba..461f31049b 100644 --- a/src/plugins/clangstaticanalyzer/clangstaticanalyzertool.cpp +++ b/src/plugins/clangstaticanalyzer/clangstaticanalyzertool.cpp @@ -145,7 +145,6 @@ ClangStaticAnalyzerTool::ClangStaticAnalyzerTool() {{ClangStaticAnalyzerDockId, m_diagnosticView, {}, Perspective::SplitVertical}} )); - //Debugger::registerAction(Constants::CLANGSTATICANALYZER_RUN_MODE, {}); action = new QAction(tr("Clang Static Analyzer"), this); action->setToolTip(toolTip); menu->addAction(ActionManager::registerAction(action, "ClangStaticAnalyzer.Action"), @@ -211,14 +210,12 @@ static bool dontStartAfterHintForDebugMode(Project *project) return false; } -void ClangStaticAnalyzerTool::startTool() +void ClangStaticAnalyzerTool::handleWorkerStart(RunWorker *runWorker) { - Project *project = SessionManager::startupProject(); + RunControl *runControl = runWorker->runControl(); + Project *project = runControl->project(); QTC_ASSERT(project, emit finished(false); return); - if (dontStartAfterHintForDebugMode(project)) - return; - Debugger::selectPerspective(ClangStaticAnalyzerPerspectiveId); m_diagnosticModel->clear(); setBusyCursor(true); @@ -230,8 +227,13 @@ void ClangStaticAnalyzerTool::startTool() m_toolBusy = true; updateRunActions(); +} - Target * const target = project->activeTarget(); +void ClangStaticAnalyzerTool::startTool() +{ + Project *project = SessionManager::startupProject(); + QTC_ASSERT(project, return); + Target *target = project->activeTarget(); QTC_ASSERT(target, return); DummyRunConfiguration *& rc = m_runConfigs[target]; if (!rc) { @@ -245,6 +247,9 @@ void ClangStaticAnalyzerTool::startTool() connect(SessionManager::instance(), &SessionManager::aboutToRemoveProject, this, onProjectRemoved, Qt::UniqueConnection); } + if (dontStartAfterHintForDebugMode(project)) + return; + ProjectExplorerPlugin::runRunConfiguration(rc, Constants::CLANGSTATICANALYZER_RUN_MODE); } diff --git a/src/plugins/clangstaticanalyzer/clangstaticanalyzertool.h b/src/plugins/clangstaticanalyzer/clangstaticanalyzertool.h index b3f05843d6..06550bce31 100644 --- a/src/plugins/clangstaticanalyzer/clangstaticanalyzertool.h +++ b/src/plugins/clangstaticanalyzer/clangstaticanalyzertool.h @@ -58,9 +58,10 @@ public: // For testing. QList diagnostics() const; - void startTool(); + void handleWorkerStart(ProjectExplorer::RunWorker *runWorker); + void onEngineIsStarting(); void onNewDiagnosticsAvailable(const QList &diagnostics); void onEngineFinished(bool success); -- cgit v1.2.3 From dbb67fd5c3219e6d2c92df67d57d3d376bc5f7c1 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Mon, 17 Jul 2017 12:29:38 +0200 Subject: Wizards: remove empty line and replace tabs with spaces Change-Id: I5decd680f92ee78a036be894aee42226b73dd053 Reviewed-by: Christian Stenger --- src/plugins/coreplugin/dialogs/newdialog.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/plugins/coreplugin/dialogs/newdialog.cpp b/src/plugins/coreplugin/dialogs/newdialog.cpp index f38a43e73b..45fe813a97 100644 --- a/src/plugins/coreplugin/dialogs/newdialog.cpp +++ b/src/plugins/coreplugin/dialogs/newdialog.cpp @@ -125,14 +125,14 @@ public: return sourceModel()->columnCount(mapToSource(index)); } - QModelIndex mapFromSource (const QModelIndex &index) const + QModelIndex mapFromSource (const QModelIndex &index) const { if (!index.isValid()) return QModelIndex(); return createIndex(index.row(), index.column(), index.internalPointer()); } - QModelIndex mapToSource (const QModelIndex &index) const + QModelIndex mapToSource (const QModelIndex &index) const { if (!index.isValid()) return QModelIndex(); @@ -172,7 +172,6 @@ public: { QSize size = QItemDelegate::sizeHint(option, index); - size = size.expandedTo(QSize(0, ROW_HEIGHT)); return size; -- cgit v1.2.3 From ca49ff1f876911a3aa44590e6eccbcdbc71a6c83 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Mon, 17 Jul 2017 12:34:41 +0200 Subject: Wizards: sprinkle some overrides Change-Id: I52bd759f9c91f36192b147a1e6579be2b4b54a82 Reviewed-by: Christian Stenger --- src/plugins/coreplugin/dialogs/newdialog.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/plugins/coreplugin/dialogs/newdialog.cpp b/src/plugins/coreplugin/dialogs/newdialog.cpp index 45fe813a97..cdfff0d989 100644 --- a/src/plugins/coreplugin/dialogs/newdialog.cpp +++ b/src/plugins/coreplugin/dialogs/newdialog.cpp @@ -79,7 +79,7 @@ public: invalidateFilter(); } - bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const + bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override { if (!sourceParent.isValid()) return true; @@ -101,18 +101,18 @@ class TwoLevelProxyModel : public QAbstractProxyModel public: TwoLevelProxyModel(QObject *parent = 0): QAbstractProxyModel(parent) {} - QModelIndex index(int row, int column, const QModelIndex &parent) const + QModelIndex index(int row, int column, const QModelIndex &parent) const override { QModelIndex ourModelIndex = sourceModel()->index(row, column, mapToSource(parent)); return createIndex(row, column, ourModelIndex.internalPointer()); } - QModelIndex parent(const QModelIndex &index) const + QModelIndex parent(const QModelIndex &index) const override { return mapFromSource(mapToSource(index).parent()); } - int rowCount(const QModelIndex &index) const + int rowCount(const QModelIndex &index) const override { if (index.isValid() && index.parent().isValid() && !index.parent().parent().isValid()) return 0; @@ -120,19 +120,19 @@ public: return sourceModel()->rowCount(mapToSource(index)); } - int columnCount(const QModelIndex &index) const + int columnCount(const QModelIndex &index) const override { return sourceModel()->columnCount(mapToSource(index)); } - QModelIndex mapFromSource (const QModelIndex &index) const + QModelIndex mapFromSource (const QModelIndex &index) const override { if (!index.isValid()) return QModelIndex(); return createIndex(index.row(), index.column(), index.internalPointer()); } - QModelIndex mapToSource (const QModelIndex &index) const + QModelIndex mapToSource (const QModelIndex &index) const override { if (!index.isValid()) return QModelIndex(); @@ -148,7 +148,7 @@ public: FancyTopLevelDelegate(QObject *parent = 0) : QItemDelegate(parent) {} - void drawDisplay(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const + void drawDisplay(QPainter *painter, const QStyleOptionViewItem &option, const QRect &rect, const QString &text) const override { QStyleOptionViewItem newoption = option; if (!(option.state & QStyle::State_Enabled)) { @@ -168,7 +168,7 @@ public: QItemDelegate::drawDisplay(painter, newoption, rect, text); } - QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const + QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override { QSize size = QItemDelegate::sizeHint(option, index); -- cgit v1.2.3 From c77e76dd6d288b0341ad00da8245b53b46408362 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 17 Jul 2017 18:52:02 +0200 Subject: Nim: Update the Nim wizard icon The icon should have the same size and look as the other icons. Task-number: QTCREATORBUG-18550 Change-Id: I16ee48196a14878858f02cabe0678342b4abb44f Reviewed-by: Filippo Cucchetto Reviewed-by: Christian Stenger --- src/tools/icons/qtcreatoricons.svg | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src') diff --git a/src/tools/icons/qtcreatoricons.svg b/src/tools/icons/qtcreatoricons.svg index e24903e09e..0534a08b94 100644 --- a/src/tools/icons/qtcreatoricons.svg +++ b/src/tools/icons/qtcreatoricons.svg @@ -1670,6 +1670,28 @@ inkscape:connector-curvature="0" sodipodi:nodetypes="cccccccccccccccc" /> + + + + + -- cgit v1.2.3 From 1646510ffadd8d8990fa67d1b377a881e0e58ab7 Mon Sep 17 00:00:00 2001 From: Tim Jenssen Date: Mon, 17 Jul 2017 12:30:15 +0200 Subject: Wizards: scale smaller icons if necessary Change-Id: I26b51668b1f2d1be1b96e43bbc42f49d39249e83 Reviewed-by: hjk --- src/plugins/coreplugin/dialogs/newdialog.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/plugins/coreplugin/dialogs/newdialog.cpp b/src/plugins/coreplugin/dialogs/newdialog.cpp index cdfff0d989..80f8eb8d4d 100644 --- a/src/plugins/coreplugin/dialogs/newdialog.cpp +++ b/src/plugins/coreplugin/dialogs/newdialog.cpp @@ -91,6 +91,21 @@ public: return true; } + QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override + { + if (role == Qt::DecorationRole) { + // scale too small icons to have one size for all + QIcon icon = qvariant_cast(QSortFilterProxyModel::data(index, role)); + if (!icon.isNull()) { + QPixmap pixmap(icon.pixmap(ICON_SIZE, ICON_SIZE)); + if (pixmap.size() != QSize(ICON_SIZE, ICON_SIZE)) + return pixmap.scaled(ICON_SIZE, ICON_SIZE, Qt::KeepAspectRatio, Qt::SmoothTransformation); + } + } + + return QSortFilterProxyModel::data(index, role); + } + private: Core::Id m_platform; }; -- cgit v1.2.3 From b3f13f9620af33bdd4c57f4201e109f923170d2c Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 18 Jul 2017 10:39:03 +0200 Subject: ProjectExplorer: Move RunWorker priority handling to worker selection This fixes the temporary regression introduced by 5a848aa1. After having RunWorker registration in RunControl and RunConfigurationAspect registration in RunConfiguration, this was effectively the only remaining code in IRunControlFactory, so this can go now. Change-Id: I38b51bb00058b90d30f0260660b040f788920008 Reviewed-by: Christian Stenger --- src/plugins/projectexplorer/projectexplorer.cpp | 11 --- src/plugins/projectexplorer/projectexplorer.h | 1 - src/plugins/projectexplorer/runconfiguration.cpp | 88 +++++------------------- src/plugins/projectexplorer/runconfiguration.h | 14 ---- 4 files changed, 16 insertions(+), 98 deletions(-) (limited to 'src') diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 12c3e5f678..5380acb478 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1995,17 +1995,6 @@ static RunControlFactory findRunControlFactory(RunConfiguration *config, Core::I }; } - IRunControlFactory *runControlFactory = ExtensionSystem::PluginManager::getObject( - [&config, &mode](IRunControlFactory *factory) { - return factory->canRun(config, mode); - }); - - if (runControlFactory) { - return [runControlFactory](RunConfiguration *rc, Id runMode, QString *errorMessage) { - return runControlFactory->create(rc, runMode, errorMessage); - }; - } - return {}; } diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index 58958c08f2..2ffb0d200d 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -48,7 +48,6 @@ namespace Utils { class ProcessHandle; } namespace ProjectExplorer { class RunControl; class RunConfiguration; -class IRunControlFactory; class Project; class Node; class FolderNode; diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 566ecc6912..5e59a9e3d2 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -367,7 +367,7 @@ IRunConfigurationAspect *RunConfiguration::extraAspect(Core::Id id) const A target specific \l RunConfiguration implementation can specify what information it considers necessary to execute a process - on the target. Target specific) \n IRunControlFactory implementation + on the target. Target specific) \n RunWorker implementation can use that information either unmodified or tweak it or ignore it when setting up a RunControl. @@ -473,29 +473,6 @@ QList IRunConfigurationFactory::find(Target *parent) }); } -/*! - \class ProjectExplorer::IRunControlFactory - - \brief The IRunControlFactory class creates RunControl objects matching a - run configuration. -*/ - -/*! - \fn RunConfigWidget *ProjectExplorer::IRunConfigurationAspect::createConfigurationWidget() - - Returns a widget used to configure this runner. Ownership is transferred to - the caller. - - Returns null if @p \a runConfiguration is not suitable for RunControls from this - factory, or no user-accessible - configuration is required. -*/ - -IRunControlFactory::IRunControlFactory(QObject *parent) - : QObject(parent) -{ -} - using WorkerFactories = std::vector; static WorkerFactories &theWorkerFactories() @@ -513,37 +490,6 @@ bool RunControl::WorkerFactory::canRun(RunConfiguration *runConfiguration, Core: return constraint(runConfiguration); } -bool IRunControlFactory::canRun(RunConfiguration *runConfiguration, Core::Id runMode) const -{ - for (const RunControl::WorkerFactory &factory : theWorkerFactories()) { - if (factory.canRun(runConfiguration, runMode)) - return true; - }; - return false; -} - -RunControl *IRunControlFactory::create(RunConfiguration *runConfiguration, Core::Id runMode, QString *) -{ - WorkerFactories candidates; - for (const RunControl::WorkerFactory &factory : theWorkerFactories()) { - if (factory.canRun(runConfiguration, runMode)) - candidates.push_back(factory); - } - - if (candidates.empty()) - return nullptr; - - RunControl::WorkerFactory bestFactory = *candidates.begin(); - for (const RunControl::WorkerFactory &factory : candidates) { - if (factory.priority > bestFactory.priority) - bestFactory = factory; - } - - auto runControl = new RunControl(runConfiguration, runMode); - bestFactory.producer(runControl); - return runControl; -} - /*! \class ProjectExplorer::RunControl \brief The RunControl class instances represent one item that is run. @@ -558,18 +504,6 @@ RunControl *IRunControlFactory::create(RunConfiguration *runConfiguration, Core: */ -const char PRIORITY_KEY[] = "RunControlFactoryPriority"; - -int ProjectExplorer::IRunControlFactory::priority() const -{ - return property(PRIORITY_KEY).toInt(); // 0 by default. -} - -void IRunControlFactory::setPriority(int priority) -{ - setProperty(PRIORITY_KEY, priority); -} - namespace Internal { enum class RunWorkerState @@ -797,12 +731,22 @@ RunWorker *RunControl::createWorker(Core::Id id) RunControl::WorkerCreator RunControl::producer(RunConfiguration *runConfiguration, Core::Id runMode) { - for (const auto &factory : theWorkerFactories()) { - if (factory.runMode == runMode - && (!factory.constraint || factory.constraint(runConfiguration))) - return factory.producer; + WorkerFactories candidates; + for (const RunControl::WorkerFactory &factory : theWorkerFactories()) { + if (factory.canRun(runConfiguration, runMode)) + candidates.push_back(factory); + } + + if (candidates.empty()) + return {}; + + RunControl::WorkerFactory bestFactory = *candidates.begin(); + for (const RunControl::WorkerFactory &factory : candidates) { + if (factory.priority > bestFactory.priority) + bestFactory = factory; } - return {}; + + return bestFactory.producer; } void RunControl::addWorkerFactory(const RunControl::WorkerFactory &workerFactory) diff --git a/src/plugins/projectexplorer/runconfiguration.h b/src/plugins/projectexplorer/runconfiguration.h index 4d49d434ea..8fabadb654 100644 --- a/src/plugins/projectexplorer/runconfiguration.h +++ b/src/plugins/projectexplorer/runconfiguration.h @@ -301,20 +301,6 @@ private: virtual RunConfiguration *doRestore(Target *parent, const QVariantMap &map) = 0; }; -class PROJECTEXPLORER_EXPORT IRunControlFactory : public QObject -{ - Q_OBJECT -public: - explicit IRunControlFactory(QObject *parent = nullptr); - - virtual bool canRun(RunConfiguration *runConfiguration, Core::Id runMode) const; - virtual RunControl *create(RunConfiguration *runConfiguration, Core::Id runMode, QString *errorMessage); - - int priority() const; -protected: - void setPriority(int priority); // Higher values will be preferred. -}; - class PROJECTEXPLORER_EXPORT RunConfigWidget : public QWidget { Q_OBJECT -- cgit v1.2.3 From 41ae823bda7cc1bad4b85861d9b0e3087c130e4a Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 18 Jul 2017 14:56:59 +0200 Subject: ProjectExplorer: Take run mode *really* into account Change-Id: Iab69e43a1c6e06dadb5a193d827b7673f09e87c9 Reviewed-by: Christian Kandeler --- src/plugins/projectexplorer/runconfiguration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index 5e59a9e3d2..bc3eaac911 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -483,7 +483,7 @@ static WorkerFactories &theWorkerFactories() bool RunControl::WorkerFactory::canRun(RunConfiguration *runConfiguration, Core::Id runMode) const { - if (runMode != runMode) + if (runMode != this->runMode) return false; if (!constraint) return true; -- cgit v1.2.3