diff options
author | hjk <hjk@qt.io> | 2019-02-14 11:02:28 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2019-02-15 15:50:50 +0000 |
commit | 3007105d86be5bfd3016277eedb557cda01eeabf (patch) | |
tree | 42f1696acce015cc9971ceedd3a16a09721ef3ef /src/plugins/qtsupport | |
parent | ec6b38dea0a9c7f5b2b45dff6cbb2b1479f44878 (diff) | |
download | qt-creator-3007105d86be5bfd3016277eedb557cda01eeabf.tar.gz |
QtSupport: Split QtVersionFactory::create()
... into a 'canCreate()' and the actual creation, which can be
done by the already registered m_creator.
Simpler interface, with the (temporary) regression that the
EmbeddedLinuxQtVersion get constructed twice, once only to
determine that it should be alive afterwards. Will be fixed later.
Change-Id: I5da2cafe473b25a0207bbd628632c9a259780361
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/qtsupport')
-rw-r--r-- | src/plugins/qtsupport/desktopqtversionfactory.cpp | 8 | ||||
-rw-r--r-- | src/plugins/qtsupport/desktopqtversionfactory.h | 2 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtversionfactory.cpp | 16 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtversionfactory.h | 4 |
4 files changed, 19 insertions, 11 deletions
diff --git a/src/plugins/qtsupport/desktopqtversionfactory.cpp b/src/plugins/qtsupport/desktopqtversionfactory.cpp index 368fef9026..b7a8bcea90 100644 --- a/src/plugins/qtsupport/desktopqtversionfactory.cpp +++ b/src/plugins/qtsupport/desktopqtversionfactory.cpp @@ -35,11 +35,5 @@ DesktopQtVersionFactory::DesktopQtVersionFactory() setQtVersionCreator([] { return new DesktopQtVersion; }); setSupportedType(Constants::DESKTOPQT); setPriority(0); // Lowest of all, we want to be the fallback -} - -BaseQtVersion *DesktopQtVersionFactory::create(ProFileEvaluator *evaluator) -{ - Q_UNUSED(evaluator); - // we are the fallback :) so we don't care what kind of qt it is - return new DesktopQtVersion; + // No further restrictions. We are the fallback :) so we don't care what kind of qt it is. } diff --git a/src/plugins/qtsupport/desktopqtversionfactory.h b/src/plugins/qtsupport/desktopqtversionfactory.h index d2d12e2f95..00d308456e 100644 --- a/src/plugins/qtsupport/desktopqtversionfactory.h +++ b/src/plugins/qtsupport/desktopqtversionfactory.h @@ -34,8 +34,6 @@ class DesktopQtVersionFactory : public QtVersionFactory { public: DesktopQtVersionFactory(); - - BaseQtVersion *create(ProFileEvaluator *evaluator) override; }; } // Internal diff --git a/src/plugins/qtsupport/qtversionfactory.cpp b/src/plugins/qtsupport/qtversionfactory.cpp index 4a00a199be..99c5e62478 100644 --- a/src/plugins/qtsupport/qtversionfactory.cpp +++ b/src/plugins/qtsupport/qtversionfactory.cpp @@ -71,6 +71,18 @@ BaseQtVersion *QtVersionFactory::restore(const QString &type, const QVariantMap return version; } +BaseQtVersion *QtVersionFactory::create() const +{ + QTC_ASSERT(m_creator, return nullptr); + return m_creator(); +} + +bool QtVersionFactory::canCreate(ProFileEvaluator *evaluator) const +{ + Q_UNUSED(evaluator); + return true; +} + BaseQtVersion *QtVersionFactory::createQtVersionFromQMakePath(const Utils::FileName &qmakePath, bool isAutoDetected, const QString &autoDetectionSource, QString *error) { QHash<ProKey, ProString> versionInfo; @@ -98,7 +110,9 @@ BaseQtVersion *QtVersionFactory::createQtVersionFromQMakePath(const Utils::FileN return nullptr; foreach (QtVersionFactory *factory, factories) { - if (BaseQtVersion *ver = factory->create(&evaluator)) { + if (factory->canCreate(&evaluator)) { + BaseQtVersion *ver = factory->create(); + QTC_ASSERT(ver, continue); ver->setupQmakePathAndId(qmakePath); ver->setAutoDetectionSource(autoDetectionSource); ver->setIsAutodetected(isAutoDetected); diff --git a/src/plugins/qtsupport/qtversionfactory.h b/src/plugins/qtsupport/qtversionfactory.h index c66a87a740..59c8545157 100644 --- a/src/plugins/qtsupport/qtversionfactory.h +++ b/src/plugins/qtsupport/qtversionfactory.h @@ -54,7 +54,9 @@ public: /// a qtversion, the priority of the desktop factory is 0 and /// the desktop factory claims to handle all paths int priority() const { return m_priority; } - virtual BaseQtVersion *create(ProFileEvaluator *evaluator) = 0; + + BaseQtVersion *create() const; + virtual bool canCreate(ProFileEvaluator *evaluator) const; static BaseQtVersion *createQtVersionFromQMakePath( const Utils::FileName &qmakePath, bool isAutoDetected = false, |