From fb8f007bbbe5cb50f6a141c4f29fdf9f231a2781 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 11 Apr 2018 09:06:12 +0200 Subject: [PATCH] Android: Move some unshared code closer to its only place of use Change-Id: Ieaba2c8f76ee9ac020ebd44712aee593c34e4bf0 Reviewed-by: Vikas Pachdha --- .../qmakeandroidrunconfiguration.cpp | 19 ++++++++++++++++-- .../qmakeprojectmanager/qmakeproject.cpp | 20 ------------------- .../qmakeprojectmanager/qmakeproject.h | 3 --- 3 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.cpp b/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.cpp index a352b97b643..0a7fbefc45e 100644 --- a/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.cpp +++ b/src/plugins/qmakeandroidsupport/qmakeandroidrunconfiguration.cpp @@ -111,8 +111,23 @@ QString QmakeAndroidRunConfiguration::disabledReason() const return tr("The .pro file \"%1\" is currently being parsed.") .arg(m_proFilePath.fileName()); - if (!qmakeProject()->hasParsingData()) - return qmakeProject()->disabledReasonForRunConfiguration(m_proFilePath); + if (!qmakeProject()->hasParsingData()) { + if (!m_proFilePath.exists()) + return tr("The .pro file \"%1\" does not exist.") + .arg(m_proFilePath.fileName()); + + QmakeProjectManager::QmakeProFileNode *rootProjectNode = qmakeProject()->rootProjectNode(); + if (!rootProjectNode) // Shutting down + return QString(); + + if (!rootProjectNode->findProFileFor(m_proFilePath)) + return tr("The .pro file \"%1\" is not part of the project.") + .arg(m_proFilePath.fileName()); + + return tr("The .pro file \"%1\" could not be parsed.") + .arg(m_proFilePath.fileName()); + } + return QString(); } diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.cpp b/src/plugins/qmakeprojectmanager/qmakeproject.cpp index a8a442740b1..85c22349ce9 100644 --- a/src/plugins/qmakeprojectmanager/qmakeproject.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeproject.cpp @@ -1019,26 +1019,6 @@ void QmakeProject::configureAsExampleProject(const QSet &platforms) qDeleteAll(infoList); } -// All the Qmake run configurations should share code. -// This is a rather suboptimal way to do that for disabledReason() -// but more pratical then duplicated the code everywhere -QString QmakeProject::disabledReasonForRunConfiguration(const FileName &proFilePath) -{ - if (!proFilePath.exists()) - return tr("The .pro file \"%1\" does not exist.") - .arg(proFilePath.fileName()); - - if (!rootProjectNode()) // Shutting down - return QString(); - - if (!rootProjectNode()->findProFileFor(proFilePath)) - return tr("The .pro file \"%1\" is not part of the project.") - .arg(proFilePath.fileName()); - - return tr("The .pro file \"%1\" could not be parsed.") - .arg(proFilePath.fileName()); -} - void QmakeProject::updateBuildSystemData() { Target *const target = activeTarget(); diff --git a/src/plugins/qmakeprojectmanager/qmakeproject.h b/src/plugins/qmakeprojectmanager/qmakeproject.h index 2b27c3d079f..df22a298bf5 100644 --- a/src/plugins/qmakeprojectmanager/qmakeproject.h +++ b/src/plugins/qmakeprojectmanager/qmakeproject.h @@ -101,9 +101,6 @@ public: void configureAsExampleProject(const QSet &platforms) final; - /// \internal - QString disabledReasonForRunConfiguration(const Utils::FileName &proFilePath); - void emitBuildDirectoryInitialized(); static void proFileParseError(const QString &errorMessage);