diff options
author | Jake Petroules <jake.petroules@qt.io> | 2017-05-10 01:25:19 -0700 |
---|---|---|
committer | Jake Petroules <jake.petroules@qt.io> | 2017-05-23 16:50:08 +0000 |
commit | 20149803a44856ea25063077964c1159b6d7a078 (patch) | |
tree | 4cd0b818e1fbe5861095d7acd516451322570bc6 /src/lib | |
parent | 41595d0cf8ac00416a3a8a437eedde2715f75500 (diff) | |
download | qbs-20149803a44856ea25063077964c1159b6d7a078.tar.gz |
Replace QSharedPointer/QWeakPointer with std::shared_ptr/std::weak_ptr
Change-Id: I2915c578968bed425a8d8b617b56df88ed3f2882
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/lib')
42 files changed, 410 insertions, 372 deletions
diff --git a/src/lib/corelib/api/internaljobs.cpp b/src/lib/corelib/api/internaljobs.cpp index 349d93834..54ce7bfe1 100644 --- a/src/lib/corelib/api/internaljobs.cpp +++ b/src/lib/corelib/api/internaljobs.cpp @@ -248,7 +248,7 @@ void InternalSetupProjectJob::start() const QString buildDir = TopLevelProject::deriveBuildDirectory(m_parameters.buildRoot(), projectId); if (m_existingProject && m_existingProject->buildDirectory != buildDir) - m_existingProject.clear(); + m_existingProject.reset(); if (!m_existingProject) { bgLocker = new BuildGraphLocker(ProjectBuildData::deriveBuildGraphFilePath(buildDir, projectId), @@ -261,7 +261,7 @@ void InternalSetupProjectJob::start() m_newProject->bgLocker = bgLocker; deleteLocker = false; } catch (const ErrorInfo &error) { - m_newProject.clear(); + m_newProject.reset(); setError(error); // Delete the build graph locker if and only if we allocated it here. @@ -303,7 +303,7 @@ void InternalSetupProjectJob::execute() storeBuildGraph(m_newProject); // The evalutation context cannot be re-used for building, which runs in a different thread. - m_newProject->buildData->evaluationContext.clear(); + m_newProject->buildData->evaluationContext.reset(); } void InternalSetupProjectJob::resolveProjectFromScratch(ScriptEngine *engine) @@ -386,7 +386,7 @@ void InternalBuildJob::build(const TopLevelProjectPtr &project, void InternalBuildJob::handleFinished() { setError(m_executor->error()); - project()->buildData->evaluationContext.clear(); + project()->buildData->evaluationContext.reset(); storeBuildGraph(); m_executor->deleteLater(); } diff --git a/src/lib/corelib/api/jobs.cpp b/src/lib/corelib/api/jobs.cpp index b1b5b7e5f..76c1484cf 100644 --- a/src/lib/corelib/api/jobs.cpp +++ b/src/lib/corelib/api/jobs.cpp @@ -268,7 +268,7 @@ void SetupProjectJob::finish() // already transferred. if (m_existingProject.isValid() && (!error().hasError() || !m_existingProject.d->internalProject->buildData)) { - m_existingProject.d->internalProject.clear(); + m_existingProject.d->internalProject.reset(); } } diff --git a/src/lib/corelib/api/project.cpp b/src/lib/corelib/api/project.cpp index 7d8a3c12d..017db6f42 100644 --- a/src/lib/corelib/api/project.cpp +++ b/src/lib/corelib/api/project.cpp @@ -733,14 +733,14 @@ RuleCommandList ProjectPrivate::ruleCommands(const ProductData &product, case AbstractCommand::JavaScriptCommandType: { externalCommand.d->type = RuleCommand::JavaScriptCommandType; const JavaScriptCommandPtr &jsCmd - = internalCommand.staticCast<JavaScriptCommand>(); + = std::static_pointer_cast<JavaScriptCommand>(internalCommand); externalCommand.d->sourceCode = jsCmd->sourceCode(); break; } case AbstractCommand::ProcessCommandType: { externalCommand.d->type = RuleCommand::ProcessCommandType; const ProcessCommandPtr &procCmd - = internalCommand.staticCast<ProcessCommand>(); + = std::static_pointer_cast<ProcessCommand>(internalCommand); externalCommand.d->executable = procCmd->program(); externalCommand.d->arguments = procCmd->arguments(); externalCommand.d->workingDir = procCmd->workingDir(); diff --git a/src/lib/corelib/buildgraph/artifact.cpp b/src/lib/corelib/buildgraph/artifact.cpp index e7c45e6c6..4562c4e9c 100644 --- a/src/lib/corelib/buildgraph/artifact.cpp +++ b/src/lib/corelib/buildgraph/artifact.cpp @@ -71,26 +71,26 @@ void Artifact::accept(BuildGraphVisitor *visitor) QString Artifact::toString() const { return QLatin1String("ARTIFACT ") + filePath() + QLatin1String(" [") - + (!product.isNull() ? product->name : QLatin1String("<null>")) + QLatin1Char(']'); + + (!product.expired() ? product->name : QLatin1String("<null>")) + QLatin1Char(']'); } void Artifact::addFileTag(const FileTag &t) { m_fileTags += t; - if (!product.isNull() && product->buildData) + if (!product.expired() && product->buildData) product->buildData->artifactsByFileTag[t] += this; } void Artifact::removeFileTag(const FileTag &t) { m_fileTags -= t; - if (!product.isNull() && product->buildData) + if (!product.expired() && product->buildData) removeArtifactFromSetByFileTag(this, t, product->buildData->artifactsByFileTag); } void Artifact::setFileTags(const FileTags &newFileTags) { - if (product.isNull() || !product->buildData) { + if (product.expired() || !product->buildData) { m_fileTags = newFileTags; return; } diff --git a/src/lib/corelib/buildgraph/buildgraph.cpp b/src/lib/corelib/buildgraph/buildgraph.cpp index cb12996d9..0a3f83d38 100644 --- a/src/lib/corelib/buildgraph/buildgraph.cpp +++ b/src/lib/corelib/buildgraph/buildgraph.cpp @@ -96,7 +96,7 @@ public: void init(QScriptValue &productScriptValue, const ResolvedProductConstPtr &product, PrepareScriptObserver *observer) { - QScriptValue depfunc = m_engine->newFunction(&js_productDependencies, product.data()); + QScriptValue depfunc = m_engine->newFunction(&js_productDependencies, product.get()); setObserver(depfunc, observer); productScriptValue.setProperty(QLatin1String("dependencies"), depfunc, QScriptValue::ReadOnly | QScriptValue::Undeletable @@ -266,7 +266,7 @@ static void setupProductScriptValue(ScriptEngine *engine, QScriptValue &productS { ModuleProperties::init(productScriptValue, product); - QScriptValue artifactsFunc = engine->newFunction(&js_productArtifacts, product.data()); + QScriptValue artifactsFunc = engine->newFunction(&js_productArtifacts, product.get()); productScriptValue.setProperty(QStringLiteral("artifacts"), artifactsFunc, QScriptValue::ReadOnly | QScriptValue::Undeletable | QScriptValue::PropertyGetter); @@ -292,7 +292,8 @@ void setupScriptEngineForProduct(ScriptEngine *engine, const ResolvedProductCons const ResolvedModuleConstPtr &module, QScriptValue targetObject, PrepareScriptObserver *observer) { - QScriptValue projectScriptValue = setupProjectScriptValue(engine, product->project, observer); + QScriptValue projectScriptValue = setupProjectScriptValue(engine, product->project.lock(), + observer); targetObject.setProperty(QLatin1String("project"), projectScriptValue); if (observer) observer->setProjectObjectId(projectScriptValue.objectId()); @@ -553,10 +554,10 @@ static void doSanityChecksForProduct(const ResolvedProductConstPtr &product, QBS_CHECK(parent->children.contains(node)); for (BuildGraphNode * const child : qAsConst(node->children)) { QBS_CHECK(child->parents.contains(node)); - QBS_CHECK(!child->product.isNull()); + QBS_CHECK(!child->product.expired()); QBS_CHECK(!child->product->buildData.isNull()); QBS_CHECK(child->product->buildData->nodes.contains(child)); - QBS_CHECK(allProducts.contains(child->product)); + QBS_CHECK(allProducts.contains(child->product.lock())); } Artifact * const artifact = dynamic_cast<Artifact *>(node); diff --git a/src/lib/corelib/buildgraph/buildgraphloader.cpp b/src/lib/corelib/buildgraph/buildgraphloader.cpp index 695d21530..cea4aaec4 100644 --- a/src/lib/corelib/buildgraph/buildgraphloader.cpp +++ b/src/lib/corelib/buildgraph/buildgraphloader.cpp @@ -284,11 +284,10 @@ void BuildGraphLoader::trackProjectChanges() checkAllProductsForChanges(allRestoredProducts, freshProductsByName, changedProducts); - QSharedPointer<ProjectBuildData> oldBuildData; + std::shared_ptr<ProjectBuildData> oldBuildData; ChildListHash childLists; if (!changedProducts.isEmpty()) { - oldBuildData = QSharedPointer<ProjectBuildData>( - new ProjectBuildData(restoredProject->buildData.data())); + oldBuildData = std::make_shared<ProjectBuildData>(restoredProject->buildData.data()); for (const ResolvedProductConstPtr &product : qAsConst(allRestoredProducts)) { if (!product->buildData) continue; @@ -365,13 +364,13 @@ void BuildGraphLoader::trackProjectChanges() childLists, rescuableArtifactData.value(changedProduct->uniqueName())); } - EmptyDirectoriesRemover(m_result.newlyResolvedProject.data(), m_logger) + EmptyDirectoriesRemover(m_result.newlyResolvedProject.get(), m_logger) .removeEmptyParentDirectories(m_artifactsRemovedFromDisk); for (FileResourceBase * const f : qAsConst(m_objectsToDelete)) { Artifact * const a = dynamic_cast<Artifact *>(f); if (a) - a->product.clear(); // To help with the sanity checks. + a->product.reset(); // To help with the sanity checks. } doSanityChecks(m_result.newlyResolvedProject, m_logger); } diff --git a/src/lib/corelib/buildgraph/depscanner.cpp b/src/lib/corelib/buildgraph/depscanner.cpp index fddacfc5d..2ca4c3e5f 100644 --- a/src/lib/corelib/buildgraph/depscanner.cpp +++ b/src/lib/corelib/buildgraph/depscanner.cpp @@ -189,7 +189,7 @@ bool UserDependencyScanner::recursive() const const void *UserDependencyScanner::key() const { - return m_scanner.data(); + return m_scanner.get(); } QString UserDependencyScanner::createId() const @@ -226,9 +226,9 @@ QStringList UserDependencyScanner::evaluate(Artifact *artifact, const ScriptFunc { ScriptEngineActiveFlagGuard guard(m_engine); - if (artifact->product.data() != m_product) { - m_product = artifact->product.data(); - setupScriptEngineForProduct(m_engine, artifact->product, + if (artifact->product.get() != m_product) { + m_product = artifact->product.get(); + setupScriptEngineForProduct(m_engine, artifact->product.lock(), m_scanner->module, m_global, &m_observer); } diff --git a/src/lib/corelib/buildgraph/depscanner.h b/src/lib/corelib/buildgraph/depscanner.h index 08b779536..6ab577839 100644 --- a/src/lib/corelib/buildgraph/depscanner.h +++ b/src/lib/corelib/buildgraph/depscanner.h @@ -117,7 +117,7 @@ private: ScriptEngine *m_engine; PrepareScriptObserver m_observer; QScriptValue m_global; - void *m_product; + ResolvedProduct *m_product; }; } // namespace Internal diff --git a/src/lib/corelib/buildgraph/executor.cpp b/src/lib/corelib/buildgraph/executor.cpp index b95f9ea5a..4cab204bd 100644 --- a/src/lib/corelib/buildgraph/executor.cpp +++ b/src/lib/corelib/buildgraph/executor.cpp @@ -231,9 +231,9 @@ void Executor::doBuild() = m_project->buildData->lookupFiles(fileToConsider); for (const FileResourceBase * const file : files) { const Artifact * const artifact = dynamic_cast<const Artifact *>(file); - if (artifact && m_productsToBuild.contains(artifact->product)) { + if (artifact && m_productsToBuild.contains(artifact->product.lock())) { m_tagsOfFilesToConsider.unite(artifact->fileTags()); - m_productsOfFilesToConsider << artifact->product; + m_productsOfFilesToConsider << artifact->product.lock(); } } } @@ -717,7 +717,7 @@ void Executor::doSanityChecks() QBS_CHECK(!m_productsToBuild.isEmpty()); for (const ResolvedProductConstPtr &product : qAsConst(m_productsToBuild)) { QBS_CHECK(product->buildData); - QBS_CHECK(product->topLevelProject() == m_project); + QBS_CHECK(product->topLevelProject() == m_project.get()); } } @@ -759,7 +759,7 @@ void Executor::rescueOldBuildData(Artifact *artifact, bool *childrenAdded = 0) if (artifact->artifactType != Artifact::Generated) return; - ResolvedProduct * const product = artifact->product.data(); + ResolvedProduct * const product = artifact->product.get(); AllRescuableArtifactData::Iterator it = product->buildData->rescuableArtifactData.find(artifact->filePath()); if (it == product->buildData->rescuableArtifactData.end()) @@ -950,7 +950,7 @@ void Executor::runTransformer(const TransformerPtr &transformer) for (Artifact * const artifact : qAsConst(transformer->outputs)) artifact->buildState = BuildGraphNode::Building; m_processingJobs.insert(job, transformer); - job->run(transformer.data()); + job->run(transformer.get()); } void Executor::finishTransformer(const TransformerPtr &transformer) @@ -1043,7 +1043,7 @@ void Executor::checkForUnbuiltProducts() bool Executor::checkNodeProduct(BuildGraphNode *node) { - if (!m_partialBuild || m_productsToBuild.contains(node->product)) + if (!m_partialBuild || m_productsToBuild.contains(node->product.lock())) return true; // TODO: Turn this into a warning once we have a reliable C++ scanner. @@ -1072,7 +1072,7 @@ void Executor::finish() m_cancelationTimer->stop(); } - EmptyDirectoriesRemover(m_project.data(), m_logger) + EmptyDirectoriesRemover(m_project.get(), m_logger) .removeEmptyParentDirectories(m_artifactsRemovedFromDisk); if (m_buildOptions.logElapsedTime()) { @@ -1159,10 +1159,10 @@ void Executor::setupForBuildingSelectedFiles(const BuildGraphNode *node) return; if (m_buildOptions.filesToConsider().isEmpty()) return; - if (!m_productsOfFilesToConsider.contains(node->product)) + if (!m_productsOfFilesToConsider.contains(node->product.lock())) return; const RuleNode * const ruleNode = static_cast<const RuleNode *>(node); - const Rule * const rule = ruleNode->rule().data(); + const Rule * const rule = ruleNode->rule().get(); if (rule->inputs.intersects(m_tagsOfFilesToConsider)) { FileTags otherInputs = rule->auxiliaryInputs; otherInputs.unite(rule->explicitlyDependsOn).subtract(rule->excludedAuxiliaryInputs); @@ -1199,7 +1199,7 @@ void Executor::prepareReachableNodes_impl(BuildGraphNode *node) void Executor::prepareProducts() { - ProductPrioritySetter prioritySetter(m_project.data()); + ProductPrioritySetter prioritySetter(m_project.get()); prioritySetter.apply(); for (const ResolvedProductPtr &product : qAsConst(m_productsToBuild)) product->setupBuildEnvironment(m_evalContext->engine(), m_project->environment); diff --git a/src/lib/corelib/buildgraph/executorjob.cpp b/src/lib/corelib/buildgraph/executorjob.cpp index 56c9a8ac3..628426adf 100644 --- a/src/lib/corelib/buildgraph/executorjob.cpp +++ b/src/lib/corelib/buildgraph/executorjob.cpp @@ -139,7 +139,7 @@ void ExecutorJob::runNextCommand() qFatal("Missing implementation for command type %d", command->type()); } - m_currentCommandExecutor->start(m_transformer, command.data()); + m_currentCommandExecutor->start(m_transformer, command.get()); } void ExecutorJob::onCommandFinished(const ErrorInfo &err) diff --git a/src/lib/corelib/buildgraph/forward_decls.h b/src/lib/corelib/buildgraph/forward_decls.h index c24944fe3..fe35cd89a 100644 --- a/src/lib/corelib/buildgraph/forward_decls.h +++ b/src/lib/corelib/buildgraph/forward_decls.h @@ -39,7 +39,7 @@ #ifndef QBS_BG_FORWARD_DECLS_H #define QBS_BG_FORWARD_DECLS_H -#include <QtCore/qsharedpointer.h> +#include <memory> namespace qbs { namespace Internal { @@ -51,20 +51,20 @@ class ProductBuildData; class Node; class Transformer; -typedef QSharedPointer<Transformer> TransformerPtr; -typedef QSharedPointer<const Transformer> TransformerConstPtr; +typedef std::shared_ptr<Transformer> TransformerPtr; +typedef std::shared_ptr<const Transformer> TransformerConstPtr; class RulesEvaluationContext; -typedef QSharedPointer<RulesEvaluationContext> RulesEvaluationContextPtr; +typedef std::shared_ptr<RulesEvaluationContext> RulesEvaluationContextPtr; class AbstractCommand; -typedef QSharedPointer<AbstractCommand> AbstractCommandPtr; +typedef std::shared_ptr<AbstractCommand> AbstractCommandPtr; class ProcessCommand; -typedef QSharedPointer<ProcessCommand> ProcessCommandPtr; +typedef std::shared_ptr<ProcessCommand> ProcessCommandPtr; class JavaScriptCommand; -typedef QSharedPointer<JavaScriptCommand> JavaScriptCommandPtr; +typedef std::shared_ptr<JavaScriptCommand> JavaScriptCommandPtr; template<typename T> class Set; using ArtifactSet = Set<Artifact *>; diff --git a/src/lib/corelib/buildgraph/inputartifactscanner.cpp b/src/lib/corelib/buildgraph/inputartifactscanner.cpp index 203edb0da..6b545dd24 100644 --- a/src/lib/corelib/buildgraph/inputartifactscanner.cpp +++ b/src/lib/corelib/buildgraph/inputartifactscanner.cpp @@ -72,7 +72,7 @@ static void resolveDepencency(const RawScannedDependency &dependency, if (!dependency.isClean()) absDirPath = QDir::cleanPath(absDirPath); - ResolvedProject *project = product->project.data(); + ResolvedProject *project = product->project.get(); FileDependency *fileDependencyArtifact = 0; Artifact *dependencyInProduct = 0; Artifact *dependencyInOtherProduct = 0; @@ -179,7 +179,7 @@ void InputArtifactScanner::scanForFileDependencies(Artifact *inputArtifact) Set<DependencyScanner *> InputArtifactScanner::scannersForArtifact(const Artifact *artifact) const { Set<DependencyScanner *> scanners; - ResolvedProduct *product = artifact->product.data(); + ResolvedProduct *product = artifact->product.get(); ScriptEngine *engine = product->topLevelProject()->buildData->evaluationContext->engine(); QHash<FileTag, InputArtifactScannerContext::DependencyScannerCacheItem> &scannerCache = m_context->scannersCache[product]; @@ -200,7 +200,7 @@ Set<DependencyScanner *> InputArtifactScanner::scannersForArtifact(const Artifac } } for (const DependencyScannerPtr &scanner : qAsConst(cache.scanners)) - scanners += scanner.data(); + scanners += scanner.get(); } return scanners; } @@ -262,13 +262,13 @@ void InputArtifactScanner::resolveScanResultDependencies(const Artifact *inputAr cachedResolvedDependencyItem.valid = true; if (FileInfo::isAbsolute(dependencyFilePath)) { - resolveDepencency(dependency, inputArtifact->product.data(), &resolvedDependency); + resolveDepencency(dependency, inputArtifact->product.get(), &resolvedDependency); goto resolved; } // try include paths for (const QString &includePath : cache.searchPaths) { - resolveDepencency(dependency, inputArtifact->product.data(), + resolveDepencency(dependency, inputArtifact->product.get(), &resolvedDependency, includePath); if (resolvedDependency.isValid()) goto resolved; @@ -298,7 +298,7 @@ resolved: void InputArtifactScanner::handleDependency(ResolvedDependency &dependency) { - const ResolvedProductPtr product = m_artifact->product; + const ResolvedProductPtr product = m_artifact->product.lock(); QBS_CHECK(m_artifact->artifactType == Artifact::Generated); QBS_CHECK(product); diff --git a/src/lib/corelib/buildgraph/inputartifactscanner.h b/src/lib/corelib/buildgraph/inputartifactscanner.h index 6d82f97ec..54e2db0ad 100644 --- a/src/lib/corelib/buildgraph/inputartifactscanner.h +++ b/src/lib/corelib/buildgraph/inputartifactscanner.h @@ -60,7 +60,7 @@ class RawScanResults; class PropertyMapInternal; class DependencyScanner; -typedef QSharedPointer<DependencyScanner> DependencyScannerPtr; +typedef std::shared_ptr<DependencyScanner> DependencyScannerPtr; class ResolvedDependency { diff --git a/src/lib/corelib/buildgraph/productinstaller.cpp b/src/lib/corelib/buildgraph/productinstaller.cpp index 935bdd0b1..2b67c0682 100644 --- a/src/lib/corelib/buildgraph/productinstaller.cpp +++ b/src/lib/corelib/buildgraph/productinstaller.cpp @@ -84,7 +84,7 @@ ProductInstaller::ProductInstaller(const TopLevelProjectPtr &project, if (m_options.removeExistingInstallation()) throw ErrorInfo(Tr::tr("Refusing to remove sysroot.")); } - initInstallRoot(project.data(), m_options); + initInstallRoot(project.get(), m_options); } void ProductInstaller::install() @@ -190,7 +190,7 @@ void ProductInstaller::copyFile(const Artifact *artifact) .arg(m_products.first()->project->topLevelProject()->id())); } - const QString targetFilePath = this->targetFilePath(m_project.data(), + const QString targetFilePath = this->targetFilePath(m_project.get(), artifact->product->sourceDirectory, artifact->filePath(), artifact->properties, m_options); const QString targetDir = FileInfo::path(targetFilePath); diff --git a/src/lib/corelib/buildgraph/projectbuilddata.cpp b/src/lib/corelib/buildgraph/projectbuilddata.cpp index 0f2768307..1b5b86887 100644 --- a/src/lib/corelib/buildgraph/projectbuilddata.cpp +++ b/src/lib/corelib/buildgraph/projectbuilddata.cpp @@ -113,10 +113,10 @@ void ProjectBuildData::insertIntoLookupTable(FileResourceBase *fileres) error.append(Tr::tr("Conflicting artifacts for file path '%1'.") .arg(artifact->filePath())); error.append(Tr::tr("The first artifact comes from product '%1'.") - .arg(productNameForErrorMessage(otherArtifact->product.data())), + .arg(productNameForErrorMessage(otherArtifact->product.get())), otherArtifact->product->location); error.append(Tr::tr("The second artifact comes from product '%1'.") - .arg(productNameForErrorMessage(artifact->product.data())), + .arg(productNameForErrorMessage(artifact->product.get())), artifact->product->location); throw error; } @@ -358,7 +358,7 @@ private: void visit(const RuleConstPtr &parentRule, const RuleConstPtr &rule) { - if (!m_rulesOnPath.insert(rule.data()).second) { + if (!m_rulesOnPath.insert(rule.get()).second) { QString pathstr; for (const Rule *r : qAsConst(m_rulePath)) { pathstr += QLatin1Char('\n') + r->toString() + QLatin1Char('\t') @@ -366,7 +366,7 @@ private: } throw ErrorInfo(Tr::tr("Cycle detected in rule dependencies: %1").arg(pathstr)); } - m_rulePath.append(rule.data()); + m_rulePath.append(rule.get()); RuleNode *node = m_nodePerRule.value(rule); if (!node) { node = new RuleNode; @@ -392,7 +392,7 @@ private: void endVisit(const RuleConstPtr &rule) { - m_rulesOnPath.remove(rule.data()); + m_rulesOnPath.remove(rule.get()); m_rulePath.removeLast(); } }; diff --git a/src/lib/corelib/buildgraph/rulecommands.cpp b/src/lib/corelib/buildgraph/rulecommands.cpp index 73f5fcfc3..c7c88efef 100644 --- a/src/lib/corelib/buildgraph/rulecommands.cpp +++ b/src/lib/corelib/buildgraph/rulecommands.cpp @@ -442,7 +442,7 @@ bool commandListsAreEqual(const QList<AbstractCommandPtr> &l1, const QList<Abstr if (l1.count() != l2.count()) return false; for (int i = 0; i < l1.count(); ++i) - if (!l1.at(i)->equals(l2.at(i).data())) + if (!l1.at(i)->equals(l2.at(i).get())) return false; return true; } diff --git a/src/lib/corelib/buildgraph/rulegraph.cpp b/src/lib/corelib/buildgraph/rulegraph.cpp index 50b520e19..8bd42c9f9 100644 --- a/src/lib/corelib/buildgraph/rulegraph.cpp +++ b/src/lib/corelib/buildgraph/rulegraph.cpp @@ -56,7 +56,7 @@ void RuleGraph::build(const Set<RulePtr> &rules, const FileTags &productFileTags m_rules.reserve(rules.size()); for (const RulePtr &rule : rules) { for (const FileTag &fileTag : rule->collectedOutputFileTags()) - m_outputFileTagToRule[fileTag].append(rule.data()); + m_outputFileTagToRule[fileTag].append(rule.get()); insert(rule); } @@ -68,11 +68,11 @@ void RuleGraph::build(const Set<RulePtr> &rules, const FileTags &productFileTags inFileTags += rule->auxiliaryInputs; inFileTags += rule->explicitlyDependsOn; for (const FileTag &fileTag : qAsConst(inFileTags)) { - inputFileTagToRule[fileTag].append(rule.data()); + inputFileTagToRule[fileTag].append(rule.get()); for (const Rule * const producingRule : m_outputFileTagToRule.value(fileTag)) { if (!producingRule->collectedOutputFileTags().intersects( rule->excludedAuxiliaryInputs)) { - connect(rule.data(), producingRule); + connect(rule.get(), producingRule); } } } diff --git a/src/lib/corelib/buildgraph/rulenode.cpp b/src/lib/corelib/buildgraph/rulenode.cpp index a9c547490..7b7ac7899 100644 --- a/src/lib/corelib/buildgraph/rulenode.cpp +++ b/src/lib/corelib/buildgraph/rulenode.cpp @@ -73,7 +73,7 @@ void RuleNode::accept(BuildGraphVisitor *visitor) QString RuleNode::toString() const { return QLatin1String("RULE ") + m_rule->toString() + QLatin1String(" [") - + (!product.isNull() ? product->name : QLatin1String("<null>")) + QLatin1Char(']'); + + (!product.expired() ? product->name : QLatin1String("<null>")) + QLatin1Char(']'); } void RuleNode::apply(const Logger &logger, const ArtifactSet &changedInputs, @@ -134,7 +134,7 @@ void RuleNode::apply(const Logger &logger, const ArtifactSet &changedInputs, RulesApplicator::handleRemovedRuleOutputs(inputs, outputArtifactsToRemove, logger); } if (!inputs.isEmpty() || !m_rule->requiresInputs()) { - RulesApplicator applicator(product, logger); + RulesApplicator applicator(product.lock(), logger); applicator.applyRule(m_rule, inputs); result->createdNodes = applicator.createdArtifacts(); result->invalidatedNodes = applicator.invalidatedArtifacts(); diff --git a/src/lib/corelib/buildgraph/rulesapplicator.cpp b/src/lib/corelib/buildgraph/rulesapplicator.cpp index 271c9c325..08a778850 100644 --- a/src/lib/corelib/buildgraph/rulesapplicator.cpp +++ b/src/lib/corelib/buildgraph/rulesapplicator.cpp @@ -89,7 +89,7 @@ void RulesApplicator::applyRule(const RuleConstPtr &rule, const ArtifactSet &inp m_createdArtifacts.clear(); m_invalidatedArtifacts.clear(); - RulesEvaluationContext::Scope s(evalContext().data()); + RulesEvaluationContext::Scope s(evalContext().get()); m_rule = rule; m_completeInputSet = inputArtifacts; @@ -197,7 +197,7 @@ void RulesApplicator::doApply(const ArtifactSet &inputArtifacts, QScriptValue &p if (!outputArtifact) continue; outputArtifacts << outputArtifact; - ruleArtifactArtifactMap << std::make_pair(ruleArtifact.data(), outputArtifact); + ruleArtifactArtifactMap << std::make_pair(ruleArtifact.get(), outputArtifact); } } @@ -302,7 +302,7 @@ Artifact *RulesApplicator::createOutputArtifact(const QString &filePath, const F Artifact *outputArtifact = lookupArtifact(m_product, outputPath); if (outputArtifact) { - const Transformer * const transformer = outputArtifact->transformer.data(); + const Transformer * const transformer = outputArtifact->transformer.get(); if (transformer && transformer->rule != m_rule) { QString e = Tr::tr("Conflicting rules for producing %1 %2 \n") .arg(outputArtifact->filePath(), diff --git a/src/lib/corelib/buildgraph/transformer.cpp b/src/lib/corelib/buildgraph/transformer.cpp index a9b51f151..147c61aff 100644 --- a/src/lib/corelib/buildgraph/transformer.cpp +++ b/src/lib/corelib/buildgraph/transformer.cpp @@ -159,7 +159,7 @@ ResolvedProductPtr Transformer::product() const { if (outputs.isEmpty()) return ResolvedProductPtr(); - return (*outputs.cbegin())->product; + return (*outputs.cbegin())->product.lock(); } void Transformer::setupInputs(QScriptValue targetScriptValue, const ArtifactSet &inputs, diff --git a/src/lib/corelib/generators/visualstudio/visualstudiogenerator.cpp b/src/lib/corelib/generators/visualstudio/visualstudiogenerator.cpp index ea621b271..7eaaaf2f0 100644 --- a/src/lib/corelib/generators/visualstudio/visualstudiogenerator.cpp +++ b/src/lib/corelib/generators/visualstudio/visualstudiogenerator.cpp @@ -74,10 +74,10 @@ public: Internal::VisualStudioVersionInfo versionInfo; - QSharedPointer<VisualStudioGuidPool> guidPool; - QSharedPointer<VisualStudioSolution> solution; + std::shared_ptr<VisualStudioGuidPool> guidPool; + std::shared_ptr<VisualStudioSolution> solution; QString solutionFilePath; - QMap<QString, QSharedPointer<MSBuildProject>> msbuildProjects; + QMap<QString, std::shared_ptr<MSBuildProject>> msbuildProjects; QMap<QString, VisualStudioSolutionFileProject *> solutionProjects; QMap<QString, VisualStudioSolutionFolderProject *> solutionFolders; QList<std::pair<QString, bool>> propertySheetNames; @@ -106,7 +106,7 @@ public: void visitProject(const GeneratableProject &project) override { Q_UNUSED(project); nestedProjects = new VisualStudioSolutionGlobalSection( - QStringLiteral("NestedProjects"), generator->d->solution.data()); + QStringLiteral("NestedProjects"), generator->d->solution.get()); generator->d->solution->appendGlobalSection(nestedProjects); } @@ -171,7 +171,7 @@ void VisualStudioGenerator::addPropertySheets(const GeneratableProject &project) const auto fileName = QStringLiteral("qbs.props"); d->propertySheetNames.append({ fileName, true }); d->msbuildProjects.insert(project.baseBuildDirectory().absoluteFilePath(fileName), - QSharedPointer<MSBuildSolutionPropertiesProject>::create( + std::make_shared<MSBuildSolutionPropertiesProject>( d->versionInfo, project, qbsExecutableFilePath(), qbsSettingsDir())); } @@ -180,14 +180,14 @@ void VisualStudioGenerator::addPropertySheets(const GeneratableProject &project) const auto fileName = QStringLiteral("qbs-shared.props"); d->propertySheetNames.append({ fileName, false }); d->msbuildProjects.insert(project.baseBuildDirectory().absoluteFilePath(fileName), - QSharedPointer<MSBuildSharedSolutionPropertiesProject>::create( + std::make_shared<MSBuildSharedSolutionPropertiesProject>( d->versionInfo, project, qbsExecutableFilePath(), qbsSettingsDir())); } } void VisualStudioGenerator::addPropertySheets( - const QSharedPointer<MSBuildTargetProject> &targetProject) + const std::shared_ptr<MSBuildTargetProject> &targetProject) { for (const auto &pair : d->propertySheetNames) { targetProject->appendPropertySheet( @@ -242,10 +242,10 @@ static void addDefaultGlobalSections(const GeneratableProject &topLevelProject, QStringLiteral("FALSE")); } -static void writeProjectFiles(const QMap<QString, QSharedPointer<MSBuildProject>> &projects) +static void writeProjectFiles(const QMap<QString, std::shared_ptr<MSBuildProject>> &projects) { // Write out all the MSBuild project files to disk - QMapIterator<QString, QSharedPointer<MSBuildProject>> it(projects); + QMapIterator<QString, std::shared_ptr<MSBuildProject>> it(projects); while (it.hasNext()) { it.next(); const auto projectFilePath = it.key(); @@ -253,14 +253,14 @@ static void writeProjectFiles(const QMap<QString, QSharedPointer<MSBuildProject> if (!file.open()) throw ErrorInfo(Tr::tr("Cannot open %s for writing").arg(projectFilePath)); - QSharedPointer<MSBuildProject> project = it.value(); + std::shared_ptr<MSBuildProject> project = it.value(); MSBuildProjectWriter writer(file.device()); - if (!(writer.write(project.data()) && file.commit())) + if (!(writer.write(project.get()) && file.commit())) throw ErrorInfo(Tr::tr("Failed to generate %1").arg(projectFilePath)); } } -static void writeSolution(const QSharedPointer<VisualStudioSolution> &solution, +static void writeSolution(const std::shared_ptr<VisualStudioSolution> &solution, const QString &solutionFilePath) { Internal::FileSaver file(solutionFilePath); @@ -269,7 +269,7 @@ static void writeSolution(const QSharedPointer<VisualStudioSolution> &solution, VisualStudioSolutionWriter writer(file.device()); writer.setProjectBaseDirectory(QFileInfo(solutionFilePath).path()); - if (!(writer.write(solution.data()) && file.commit())) + if (!(writer.write(solution.get()) && file.commit())) throw ErrorInfo(Tr::tr("Failed to generate %1").arg(solutionFilePath)); qDebug() << "Generated" << qPrintable(QFileInfo(solutionFilePath).fileName()); @@ -280,7 +280,7 @@ void VisualStudioGenerator::generate() GeneratableProjectIterator it(project()); it.accept(this); - addDefaultGlobalSections(project(), d->solution.data()); + addDefaultGlobalSections(project(), d->solution.get()); // Second pass: connection solution project interdependencies and project nesting hierarchy SolutionDependenciesVisitor solutionDependenciesVisitor(this); @@ -292,12 +292,12 @@ void VisualStudioGenerator::generate() d->reset(); } -std::vector<QSharedPointer<ProjectGenerator> > VisualStudioGenerator::createGeneratorList() +std::vector<std::shared_ptr<ProjectGenerator> > VisualStudioGenerator::createGeneratorList() { - std::vector<QSharedPointer<ProjectGenerator> > result; + std::vector<std::shared_ptr<ProjectGenerator> > result; for (const auto &info : VisualStudioVersionInfo::knownVersions()) { if (info.usesMsBuild()) - result.push_back(QSharedPointer<ProjectGenerator>(new VisualStudioGenerator(info))); + result.push_back(std::make_shared<VisualStudioGenerator>(info)); } return result; } @@ -308,18 +308,18 @@ void VisualStudioGenerator::visitProject(const GeneratableProject &project) const auto buildDir = project.baseBuildDirectory(); - d->guidPool = QSharedPointer<VisualStudioGuidPool>::create( + d->guidPool = std::make_shared<VisualStudioGuidPool>( buildDir.absoluteFilePath(project.name() + QStringLiteral(".guid.txt"))); d->solutionFilePath = buildDir.absoluteFilePath(project.name() + QStringLiteral(".sln")); - d->solution = QSharedPointer<VisualStudioSolution>::create(d->versionInfo); + d->solution = std::make_shared<VisualStudioSolution>(d->versionInfo); // Create a helper project to re-run qbs generate const auto qbsGenerate = QStringLiteral("qbs-generate"); const auto projectFilePath = targetFilePath(qbsGenerate, buildDir.absolutePath()); const auto relativeProjectFilePath = QFileInfo(d->solutionFilePath).dir() .relativeFilePath(projectFilePath); - auto targetProject = QSharedPointer<MSBuildQbsGenerateProject>::create(project, d->versionInfo); + auto targetProject = std::make_shared<MSBuildQbsGenerateProject>(project, d->versionInfo); targetProject->setGuid(d->guidPool->drawProductGuid(relativeProjectFilePath)); d->msbuildProjects.insert(projectFilePath, targetProject); @@ -327,7 +327,7 @@ void VisualStudioGenerator::visitProject(const GeneratableProject &project) auto solutionProject = new VisualStudioSolutionFileProject( targetFilePath(qbsGenerate, project.baseBuildDirectory().absolutePath()), - d->solution.data()); + d->solution.get()); solutionProject->setGuid(targetProject->guid()); d->solution->appendProject(solutionProject); d->solutionProjects.insert(qbsGenerate, solutionProject); @@ -337,7 +337,7 @@ void VisualStudioGenerator::visitProjectData(const GeneratableProject &project, const GeneratableProjectData &projectData) { Q_UNUSED(project); - auto solutionFolder = new VisualStudioSolutionFolderProject(d->solution.data()); + auto solutionFolder = new VisualStudioSolutionFolderProject(d->solution.get()); solutionFolder->setName(projectData.name()); d->solution->appendProject(solutionFolder); d->solutionFolders.insert(projectData.name(), solutionFolder); @@ -352,7 +352,7 @@ void VisualStudioGenerator::visitProduct(const GeneratableProject &project, project.baseBuildDirectory().absolutePath()); const auto relativeProjectFilePath = QFileInfo(d->solutionFilePath) .dir().relativeFilePath(projectFilePath); - auto targetProject = QSharedPointer<MSBuildQbsProductProject>::create(project, productData, + auto targetProject = std::make_shared<MSBuildQbsProductProject>(project, productData, d->versionInfo); targetProject->setGuid(d->guidPool->drawProductGuid(relativeProjectFilePath)); @@ -360,11 +360,11 @@ void VisualStudioGenerator::visitProduct(const GeneratableProject &project, d->msbuildProjects.insert(projectFilePath, targetProject); d->msbuildProjects.insert(projectFilePath + QStringLiteral(".filters"), - QSharedPointer<MSBuildFiltersProject>::create(productData)); + std::make_shared<MSBuildFiltersProject>(productData)); auto solutionProject = new VisualStudioSolutionFileProject( targetFilePath(productData, project.baseBuildDirectory().absolutePath()), - d->solution.data()); + d->solution.get()); solutionProject->setGuid(targetProject->guid()); d->solution->appendProject(solutionProject); d->solutionProjects.insert(productData.name(), solutionProject); diff --git a/src/lib/corelib/generators/visualstudio/visualstudiogenerator.h b/src/lib/corelib/generators/visualstudio/visualstudiogenerator.h index b8e9ad2ae..5c1d37695 100644 --- a/src/lib/corelib/generators/visualstudio/visualstudiogenerator.h +++ b/src/lib/corelib/generators/visualstudio/visualstudiogenerator.h @@ -61,7 +61,7 @@ public: QString generatorName() const override; void generate() override; - static std::vector<QSharedPointer<ProjectGenerator> > createGeneratorList(); + static std::vector<std::shared_ptr<ProjectGenerator> > createGeneratorList(); private: virtual void visitProject(const GeneratableProject &project) override; @@ -72,7 +72,7 @@ private: const GeneratableProductData &productData) override; void addPropertySheets(const GeneratableProject &project); - void addPropertySheets(const QSharedPointer<MSBuildTargetProject> &targetProject); + void addPropertySheets(const std::shared_ptr<MSBuildTargetProject> &targetProject); QScopedPointer<VisualStudioGeneratorPrivate> d; }; diff --git a/src/lib/corelib/jsextensions/moduleproperties.cpp b/src/lib/corelib/jsextensions/moduleproperties.cpp index df93c52af..c9b17c855 100644 --- a/src/lib/corelib/jsextensions/moduleproperties.cpp +++ b/src/lib/corelib/jsextensions/moduleproperties.cpp @@ -134,7 +134,7 @@ static QString artifactType() { return QLatin1String("artifact"); } void ModuleProperties::init(QScriptValue productObject, const ResolvedProductConstPtr &product) { - init(productObject, product.data(), productType()); + init(productObject, product.get(), productType()); setupModules(productObject, product, nullptr); } @@ -152,7 +152,7 @@ void ModuleProperties::init(QScriptValue artifactObject, const Artifact *artifac }; QScriptEngine * const engine = artifactObject.engine(); artifactObject.setProperty(QStringLiteral("product"), engine->toScriptValue(productProperties)); - setupModules(artifactObject, artifact->product, artifact); + setupModules(artifactObject, artifact->product.lock(), artifact); } void ModuleProperties::init(QScriptValue objectWithProperties, const void *ptr, @@ -178,7 +178,7 @@ void ModuleProperties::setupModules(QScriptValue &object, const ResolvedProductC QScriptValue data = engine->newObject(); data.setProperty(ModuleNameKey, module->name); QVariant v; - v.setValue<quintptr>(reinterpret_cast<quintptr>(product.data())); + v.setValue<quintptr>(reinterpret_cast<quintptr>(product.get())); data.setProperty(ProductPtrKey, engine->newVariant(v)); v.setValue<quintptr>(reinterpret_cast<quintptr>(artifact)); data.setProperty(ArtifactPtrKey, engine->newVariant(v)); diff --git a/src/lib/corelib/language/astpropertiesitemhandler.cpp b/src/lib/corelib/language/astpropertiesitemhandler.cpp index 51d9eb43c..4b0d36f3e 100644 --- a/src/lib/corelib/language/astpropertiesitemhandler.cpp +++ b/src/lib/corelib/language/astpropertiesitemhandler.cpp @@ -105,7 +105,7 @@ private: continue; } if (it.value()->type() == Value::ItemValueType) { - Item * const innerVal = it.value().staticCast<ItemValue>()->item(); + Item * const innerVal = std::static_pointer_cast<ItemValue>(it.value())->item(); ItemValuePtr outerVal = outer->itemProperty(it.key()); if (!outerVal) { outerVal = ItemValue::create(Item::create(outer->pool(), innerVal->type()), @@ -119,8 +119,8 @@ private: throw ErrorInfo(Tr::tr("Incompatible value type in unconditional value at %1.") .arg(outerVal->location().toString())); } - doApply(it.key(), outer, outerVal.staticCast<JSSourceValue>(), - it.value().staticCast<JSSourceValue>()); + doApply(it.key(), outer, std::static_pointer_cast<JSSourceValue>(outerVal), + std::static_pointer_cast<JSSourceValue>(it.value())); } else { QBS_CHECK(!"Unexpected value type in conditional value."); } @@ -171,7 +171,7 @@ static QString getPropertyString(const Item *propertiesItem, const QString &name } } - const JSSourceValuePtr srcval = value.staticCast<JSSourceValue>(); + const JSSourceValuePtr srcval = std::static_pointer_cast<JSSourceValue>(value); return srcval->sourceCodeForEvaluation(); } diff --git a/src/lib/corelib/language/evaluatorscriptclass.cpp b/src/lib/corelib/language/evaluatorscriptclass.cpp index 3050e4261..efc574e37 100755 --- a/src/lib/corelib/language/evaluatorscriptclass.cpp +++ b/src/lib/corelib/language/evaluatorscriptclass.cpp @@ -228,7 +228,7 @@ private: } if (overrides.toBool()) value->setIsExclusiveListValue(); - value = alternative->value.data(); + value = alternative->value.get(); break; } } @@ -355,7 +355,7 @@ QScriptClass::QueryFlags EvaluatorScriptClass::queryItemProperty(const Evaluatio { for (const Item *item = data->item; item; item = item->prototype()) { m_queryResult.value = item->ownProperty(name); - if (!m_queryResult.value.isNull()) { + if (m_queryResult.value) { m_queryResult.data = data; m_queryResult.itemOfProperty = item; return HandlesReadAccess; @@ -393,7 +393,7 @@ void EvaluatorScriptClass::collectValuesFromNextChain(const EvaluationData *data QScriptValueList lst; Set<Value *> oldNextChain = m_currentNextChain; for (ValuePtr next = value; next; next = next->next()) - m_currentNextChain.insert(next.data()); + m_currentNextChain.insert(next.get()); for (ValuePtr next = value; next; next = next->next()) { QScriptValue v = data->evaluator->property(next->definingItem(), propertyName); @@ -406,7 +406,7 @@ void EvaluatorScriptClass::collectValuesFromNextChain(const EvaluationData *data continue; lst << v; if (next->type() == Value::JSSourceValueType - && next.staticCast<JSSourceValue>()->isExclusiveListValue()) { + && std::static_pointer_cast<JSSourceValue>(next)->isExclusiveListValue()) { lst = lst.mid(lst.length() - 2); break; } @@ -589,7 +589,7 @@ QScriptValue EvaluatorScriptClass::property(const QScriptValue &object, const QS if (debugProperties) qDebug() << "[SC] property " << name; - PropertyStackManager propStackmanager(itemOfProperty, name, value.data(), + PropertyStackManager propStackmanager(itemOfProperty, name, value.get(), m_requestedProperties, m_propertyDependencies); QScriptValue result; @@ -602,14 +602,14 @@ QScriptValue EvaluatorScriptClass::property(const QScriptValue &object, const QS } } - if (value->next() && !m_currentNextChain.contains(value.data())) { + if (value->next() && !m_currentNextChain.contains(value.get())) { collectValuesFromNextChain(data, &result, name.toString(), value); } else { SVConverter converter(this, &object, value, itemOfProperty, &name, data, &result); converter.start(); const PropertyDeclaration decl = data->item->propertyDeclaration(name.toString()); - convertToPropertyType(data->item, decl, value.data(), result); + convertToPropertyType(data->item, decl, value.get(), result); } if (debugProperties) diff --git a/src/lib/corelib/language/forward_decls.h b/src/lib/corelib/language/forward_decls.h index 6b09449c2..4ce9d57eb 100644 --- a/src/lib/corelib/language/forward_decls.h +++ b/src/lib/corelib/language/forward_decls.h @@ -39,94 +39,101 @@ #ifndef QBS_LANG_FORWARD_DECLS_H #define QBS_LANG_FORWARD_DECLS_H -#include <QtCore/qsharedpointer.h> +#include <memory> + +#include <QtCore/qhash.h> namespace qbs { namespace Internal { class Value; -typedef QSharedPointer<Value> ValuePtr; -typedef QSharedPointer<const Value> ValueConstPtr; +typedef std::shared_ptr<Value> ValuePtr; +typedef std::shared_ptr<const Value> ValueConstPtr; class ItemValue; -typedef QSharedPointer<ItemValue> ItemValuePtr; -typedef QSharedPointer<const ItemValue> ItemValueConstPtr; +typedef std::shared_ptr<ItemValue> ItemValuePtr; +typedef std::shared_ptr<const ItemValue> ItemValueConstPtr; class JSSourceValue; -typedef QSharedPointer<JSSourceValue> JSSourceValuePtr; -typedef QSharedPointer<const JSSourceValue> JSSourceValueConstPtr; +typedef std::shared_ptr<JSSourceValue> JSSourceValuePtr; +typedef std::shared_ptr<const JSSourceValue> JSSourceValueConstPtr; class VariantValue; -typedef QSharedPointer<VariantValue> VariantValuePtr; -typedef QSharedPointer<const VariantValue> VariantValueConstPtr; +typedef std::shared_ptr<VariantValue> VariantValuePtr; +typedef std::shared_ptr<const VariantValue> VariantValueConstPtr; class FileContext; -typedef QSharedPointer<FileContext> FileContextPtr; -typedef QSharedPointer<const FileContext> FileContextConstPtr; +typedef std::shared_ptr<FileContext> FileContextPtr; +typedef std::shared_ptr<const FileContext> FileContextConstPtr; class FileContextBase; -typedef QSharedPointer<FileContextBase> FileContextBasePtr; -typedef QSharedPointer<const FileContextBase> FileContextBaseConstPtr; +typedef std::shared_ptr<FileContextBase> FileContextBasePtr; +typedef std::shared_ptr<const FileContextBase> FileContextBaseConstPtr; class Probe; -typedef QSharedPointer<Probe> ProbePtr; -typedef QSharedPointer<const Probe> ProbeConstPtr; +typedef std::shared_ptr<Probe> ProbePtr; +typedef std::shared_ptr<const Probe> ProbeConstPtr; class PropertyMapInternal; -typedef QSharedPointer<PropertyMapInternal> PropertyMapPtr; -typedef QSharedPointer<const PropertyMapInternal> PropertyMapConstPtr; +typedef std::shared_ptr<PropertyMapInternal> PropertyMapPtr; +typedef std::shared_ptr<const PropertyMapInternal> PropertyMapConstPtr; class FileTagger; -typedef QSharedPointer<FileTagger> FileTaggerPtr; -typedef QSharedPointer<const FileTagger> FileTaggerConstPtr; +typedef std::shared_ptr<FileTagger> FileTaggerPtr; +typedef std::shared_ptr<const FileTagger> FileTaggerConstPtr; class ResolvedProduct; -typedef QSharedPointer<ResolvedProduct> ResolvedProductPtr; -typedef QSharedPointer<const ResolvedProduct> ResolvedProductConstPtr; +typedef std::shared_ptr<ResolvedProduct> ResolvedProductPtr; +typedef std::shared_ptr<const ResolvedProduct> ResolvedProductConstPtr; class ResolvedProject; -typedef QSharedPointer<ResolvedProject> ResolvedProjectPtr; -typedef QSharedPointer<const ResolvedProject> ResolvedProjectConstPtr; +typedef std::shared_ptr<ResolvedProject> ResolvedProjectPtr; +typedef std::shared_ptr<const ResolvedProject> ResolvedProjectConstPtr; class TopLevelProject; -typedef QSharedPointer<TopLevelProject> TopLevelProjectPtr; -typedef QSharedPointer<const TopLevelProject> TopLevelProjectConstPtr; +typedef std::shared_ptr<TopLevelProject> TopLevelProjectPtr; +typedef std::shared_ptr<const TopLevelProject> TopLevelProjectConstPtr; class ResolvedFileContext; -typedef QSharedPointer<ResolvedFileContext> ResolvedFileContextPtr; -typedef QSharedPointer<const ResolvedFileContext> ResolvedFileContextConstPtr; +typedef std::shared_ptr<ResolvedFileContext> ResolvedFileContextPtr; +typedef std::shared_ptr<const ResolvedFileContext> ResolvedFileContextConstPtr; class Rule; -typedef QSharedPointer<Rule> RulePtr; -typedef QSharedPointer<const Rule> RuleConstPtr; +typedef std::shared_ptr<Rule> RulePtr; +typedef std::shared_ptr<const Rule> RuleConstPtr; class ResolvedScanner; -typedef QSharedPointer<ResolvedScanner> ResolvedScannerPtr; -typedef QSharedPointer<const ResolvedScanner> ResolvedScannerConstPtr; +typedef std::shared_ptr<ResolvedScanner> ResolvedScannerPtr; +typedef std::shared_ptr<const ResolvedScanner> ResolvedScannerConstPtr; class SourceArtifactInternal; -typedef QSharedPointer<SourceArtifactInternal> SourceArtifactPtr; -typedef QSharedPointer<const SourceArtifactInternal> SourceArtifactConstPtr; +typedef std::shared_ptr<SourceArtifactInternal> SourceArtifactPtr; +typedef std::shared_ptr<const SourceArtifactInternal> SourceArtifactConstPtr; class ScriptFunction; -typedef QSharedPointer<ScriptFunction> ScriptFunctionPtr; -typedef QSharedPointer<const ScriptFunction> ScriptFunctionConstPtr; +typedef std::shared_ptr<ScriptFunction> ScriptFunctionPtr; +typedef std::shared_ptr<const ScriptFunction> ScriptFunctionConstPtr; class RuleArtifact; -typedef QSharedPointer<RuleArtifact> RuleArtifactPtr; -typedef QSharedPointer<const RuleArtifact> RuleArtifactConstPtr; +typedef std::shared_ptr<RuleArtifact> RuleArtifactPtr; +typedef std::shared_ptr<const RuleArtifact> RuleArtifactConstPtr; class ResolvedModule; -typedef QSharedPointer<ResolvedModule> ResolvedModulePtr; -typedef QSharedPointer<const ResolvedModule> ResolvedModuleConstPtr; +typedef std::shared_ptr<ResolvedModule> ResolvedModulePtr; +typedef std::shared_ptr<const ResolvedModule> ResolvedModuleConstPtr; class ResolvedGroup; -typedef QSharedPointer<ResolvedGroup> GroupPtr; -typedef QSharedPointer<const ResolvedGroup> GroupConstPtr; +typedef std::shared_ptr<ResolvedGroup> GroupPtr; +typedef std::shared_ptr<const ResolvedGroup> GroupConstPtr; class ArtifactProperties; -typedef QSharedPointer<ArtifactProperties> ArtifactPropertiesPtr; -typedef QSharedPointer<const ArtifactProperties> ArtifactPropertiesConstPtr; +typedef std::shared_ptr<ArtifactProperties> ArtifactPropertiesPtr; +typedef std::shared_ptr<const ArtifactProperties> ArtifactPropertiesConstPtr; + +template <typename T> inline static uint qHash(const std::shared_ptr<T> &p, uint seed = 0) +{ + return ::qHash(p.get(), seed); +} } // namespace Internal } // namespace qbs diff --git a/src/lib/corelib/language/item.cpp b/src/lib/corelib/language/item.cpp index 1d23f96d1..73273495f 100644 --- a/src/lib/corelib/language/item.cpp +++ b/src/lib/corelib/language/item.cpp @@ -150,7 +150,7 @@ ItemValuePtr Item::itemProperty(const QString &name, const Item *itemTemplate) ItemValuePtr result; ValuePtr v = property(name); if (v && v->type() == Value::ItemValueType) { - result = v.staticCast<ItemValue>(); + result = std::static_pointer_cast<ItemValue>(v); } else if (itemTemplate) { result = ItemValue::create(Item::create(m_pool, itemTemplate->type())); setProperty(name, result); @@ -163,7 +163,7 @@ JSSourceValuePtr Item::sourceProperty(const QString &name) const ValuePtr v = property(name); if (!v || v->type() != Value::JSSourceValueType) return JSSourceValuePtr(); - return v.staticCast<JSSourceValue>(); + return std::static_pointer_cast<JSSourceValue>(v); } VariantValuePtr Item::variantProperty(const QString &name) const @@ -171,7 +171,7 @@ VariantValuePtr Item::variantProperty(const QString &name) const ValuePtr v = property(name); if (!v || v->type() != Value::VariantValueType) return VariantValuePtr(); - return v.staticCast<VariantValue>(); + return std::static_pointer_cast<VariantValue>(v); } PropertyDeclaration Item::propertyDeclaration(const QString &name) const @@ -273,19 +273,19 @@ void Item::dump(int indentation) const for (auto it = m_properties.constBegin(); it != m_properties.constEnd(); ++it) { const QByteArray nextIndent(indentation + 4, ' '); qDebug("%skey: %s, value type: %s", nextIndent.constData(), qPrintable(it.key()), - valueType(it.value().data())); + valueType(it.value().get())); switch (it.value()->type()) { case Value::JSSourceValueType: qDebug("%svalue: %s", nextIndent.constData(), - qPrintable(it.value().staticCast<JSSourceValue>()->sourceCodeForEvaluation())); + qPrintable(std::static_pointer_cast<JSSourceValue>(it.value())->sourceCodeForEvaluation())); break; case Value::ItemValueType: qDebug("%svalue:", nextIndent.constData()); - it.value().staticCast<ItemValue>()->item()->dump(indentation + 8); + std::static_pointer_cast<ItemValue>(it.value())->item()->dump(indentation + 8); break; case Value::VariantValueType: qDebug("%svalue: %s", nextIndent.constData(), - qPrintable(it.value().staticCast<VariantValue>()->value().toString())); + qPrintable(std::static_pointer_cast<VariantValue>(it.value())->value().toString())); break; } } diff --git a/src/lib/corelib/language/itemreaderastvisitor.cpp b/src/lib/corelib/language/itemreaderastvisitor.cpp index f748119d2..91d33a81d 100644 --- a/src/lib/corelib/language/itemreaderastvisitor.cpp +++ b/src/lib/corelib/language/itemreaderastvisitor.cpp @@ -275,7 +275,7 @@ Item *ItemReaderASTVisitor::targetItemForBinding(const QStringList &bindingName, QString msg = Tr::tr("Binding to non-item property."); throw ErrorInfo(msg, value->location()); } - targetItem = v.staticCast<ItemValue>()->item(); + targetItem = std::static_pointer_cast<ItemValue>(v)->item(); } return targetItem; } @@ -310,17 +310,17 @@ void ItemReaderASTVisitor::inheritItem(Item *dst, const Item *src) continue; switch (v->type()) { case Value::JSSourceValueType: { - JSSourceValuePtr sv = v.staticCast<JSSourceValue>(); + JSSourceValuePtr sv = std::static_pointer_cast<JSSourceValue>(v); QBS_CHECK(!sv->baseValue()); - const JSSourceValuePtr baseValue = it.value().staticCast<JSSourceValue>(); + const JSSourceValuePtr baseValue = std::static_pointer_cast<JSSourceValue>(it.value()); sv->setBaseValue(baseValue); for (const JSSourceValue::Alternative &alt : qAsConst(sv->m_alternatives)) alt.value->setBaseValue(baseValue); break; } case Value::ItemValueType: - inheritItem(v.staticCast<ItemValue>()->item(), - it.value().staticCast<const ItemValue>()->item()); + inheritItem(std::static_pointer_cast<ItemValue>(v)->item(), + std::static_pointer_cast<const ItemValue>(it.value())->item()); break; default: QBS_CHECK(!"unexpected value type"); diff --git a/src/lib/corelib/language/language.cpp b/src/lib/corelib/language/language.cpp index 31ab5f120..b1647a7e2 100644 --- a/src/lib/corelib/language/language.cpp +++ b/src/lib/corelib/language/language.cpp @@ -337,7 +337,7 @@ bool operator==(const ScriptFunction &a, const ScriptFunction &b) return a.sourceCode == b.sourceCode && a.location == b.location && a.argumentNames == b.argumentNames - && equals(a.fileContext.data(), b.fileContext.data()); + && equals(a.fileContext.get(), b.fileContext.get()); } void ResolvedModule::load(PersistentPool &pool) @@ -360,8 +360,8 @@ bool operator==(const ResolvedModule &m1, const ResolvedModule &m2) { return m1.name == m2.name && m1.moduleDependencies.toSet() == m2.moduleDependencies.toSet() - && equals(m1.setupBuildEnvironmentScript.data(), m2.setupBuildEnvironmentScript.data()) - && equals(m1.setupRunEnvironmentScript.data(), m2.setupRunEnvironmentScript.data()); + && equals(m1.setupBuildEnvironmentScript.get(), m2.setupBuildEnvironmentScript.get()) + && equals(m1.setupRunEnvironmentScript.get(), m2.setupRunEnvironmentScript.get()); } QString Rule::toString() const @@ -600,7 +600,7 @@ static QProcessEnvironment getProcessEnvironment(ScriptEngine *engine, EnvType e { QMap<QString, const ResolvedModule *> moduleMap; for (const ResolvedModuleConstPtr &module : modules) - moduleMap.insert(module->name, module.data()); + moduleMap.insert(module->name, module.get()); QHash<const ResolvedModule*, QList<const ResolvedModule*> > moduleParents; QHash<const ResolvedModule*, QList<const ResolvedModule*> > moduleChildren; @@ -608,16 +608,16 @@ static QProcessEnvironment getProcessEnvironment(ScriptEngine *engine, EnvType e for (const QString &moduleName : qAsConst(module->moduleDependencies)) { const ResolvedModule * const depmod = moduleMap.value(moduleName); QBS_ASSERT(depmod, return env); - moduleParents[depmod].append(module.data()); - moduleChildren[module.data()].append(depmod); + moduleParents[depmod].append(module.get()); + moduleChildren[module.get()].append(depmod); } } QList<const ResolvedModule *> rootModules; for (const ResolvedModuleConstPtr &module : modules) { - if (moduleParents.value(module.data()).isEmpty()) { + if (moduleParents.value(module.get()).isEmpty()) { QBS_ASSERT(module, return env); - rootModules.append(module.data()); + rootModules.append(module.get()); } } @@ -824,9 +824,9 @@ QString ResolvedProduct::buildDirectory() const bool ResolvedProduct::isInParentProject(const ResolvedProductConstPtr &other) const { - for (const ResolvedProject *otherParent = other->project.data(); otherParent; - otherParent = otherParent->parentProject.data()) { - if (otherParent == project.data()) + for (const ResolvedProject *otherParent = other->project.get(); otherParent; + otherParent = otherParent->parentProject.get()) { + if (otherParent == project.get()) return true; } return false; @@ -871,7 +871,7 @@ TopLevelProject *ResolvedProject::topLevelProject() m_topLevelProject = tlp; return m_topLevelProject; } - QBS_CHECK(!parentProject.isNull()); + QBS_CHECK(!parentProject.expired()); m_topLevelProject = parentProject->topLevelProject(); return m_topLevelProject; } @@ -1168,7 +1168,7 @@ template<typename T> bool listsAreEqual(const QList<T> &l1, const QList<T> &l2) const T value2 = map2.value(key); if (!value2) return false; - if (!equals(map1.value(key).data(), value2.data())) + if (!equals(map1.value(key).get(), value2.get())) return false; } return true; @@ -1211,13 +1211,13 @@ bool operator==(const Rule &r1, const Rule &r2) if (r1.artifacts.count() != r2.artifacts.count()) return false; for (int i = 0; i < r1.artifacts.count(); ++i) { - if (!equals(r1.artifacts.at(i).data(), r2.artifacts.at(i).data())) + if (!equals(r1.artifacts.at(i).get(), r2.artifacts.at(i).get())) return false; } return r1.module->name == r2.module->name - && equals(r1.prepareScript.data(), r2.prepareScript.data()) - && equals(r1.outputArtifactsScript.data(), r2.outputArtifactsScript.data()) + && equals(r1.prepareScript.get(), r2.prepareScript.get()) + && equals(r1.outputArtifactsScript.get(), r2.outputArtifactsScript.get()) && r1.inputs == r2.inputs && r1.outputFileTags == r2.outputFileTags && r1.auxiliaryInputs == r2.auxiliaryInputs diff --git a/src/lib/corelib/language/language.h b/src/lib/corelib/language/language.h index cec64d276..df8d03cda 100644 --- a/src/lib/corelib/language/language.h +++ b/src/lib/corelib/language/language.h @@ -223,8 +223,8 @@ bool sourceArtifactSetsAreEqual(const QList<SourceArtifactPtr> &l1, class SourceWildCards : public PersistentObject { public: - typedef QSharedPointer<SourceWildCards> Ptr; - typedef QSharedPointer<const SourceWildCards> ConstPtr; + typedef std::shared_ptr<SourceWildCards> Ptr; + typedef std::shared_ptr<const SourceWildCards> ConstPtr; static Ptr create() { return Ptr(new SourceWildCards); } diff --git a/src/lib/corelib/language/moduleloader.cpp b/src/lib/corelib/language/moduleloader.cpp index 3f59dc14a..7be5363c9 100755 --- a/src/lib/corelib/language/moduleloader.cpp +++ b/src/lib/corelib/language/moduleloader.cpp @@ -311,7 +311,7 @@ ModuleLoaderResult ModuleLoader::load(const SetupProjectParameters ¶meters) m_elapsedTimeProbes = 0; ModuleLoaderResult result; - m_pool = result.itemPool.data(); + m_pool = result.itemPool.get(); m_reader->setPool(m_pool); const QStringList topLevelSearchPaths = parameters.finalBuildConfigurationTree() @@ -1393,7 +1393,7 @@ void ModuleLoader::handlePropertyOptions(Item *optionsItem) static void mergeProperty(Item *dst, const QString &name, const ValuePtr &value) { if (value->type() == Value::ItemValueType) { - Item *valueItem = value.staticCast<ItemValue>()->item(); + Item *valueItem = std::static_pointer_cast<ItemValue>(value)->item(); Item *subItem = dst->itemProperty(name, valueItem)->item(); for (QMap<QString, ValuePtr>::const_iterator it = valueItem->properties().constBegin(); it != valueItem->properties().constEnd(); ++it) @@ -1404,8 +1404,9 @@ static void mergeProperty(Item *dst, const QString &name, const ValuePtr &value) const ValuePtr baseValue = dst->property(name); if (baseValue) { QBS_CHECK(baseValue->type() == Value::JSSourceValueType); - const JSSourceValuePtr jsBaseValue = baseValue->clone().staticCast<JSSourceValue>(); - JSSourceValue *jsValue = static_cast<JSSourceValue *>(value.data()); + const JSSourceValuePtr jsBaseValue = std::static_pointer_cast<JSSourceValue>( + baseValue->clone()); + JSSourceValue *jsValue = static_cast<JSSourceValue *>(value.get()); jsValue->setBaseValue(jsBaseValue); } } @@ -1591,7 +1592,7 @@ bool ModuleLoader::isSomeModulePropertySet(const Item *item) } break; case Value::ItemValueType: - if (isSomeModulePropertySet(it.value().staticCast<ItemValue>()->item())) + if (isSomeModulePropertySet(std::static_pointer_cast<ItemValue>(it.value())->item())) return true; break; default: @@ -1796,7 +1797,7 @@ void ModuleLoader::adjustDefiningItemsInGroupModuleInstances(const Item::Module << ", new defining item is" << replacement << " with scope" << replacement->scope() << ", value source code is " - << v.staticCast<JSSourceValue>()->sourceCode().toString(); + << std::static_pointer_cast<JSSourceValue>(v)->sourceCode().toString(); } replacement->setPropertyDeclaration(propName, decl); replacement->setProperty(propName, v); @@ -2045,7 +2046,9 @@ void ModuleLoader::forwardParameterDeclarations(const Item *dependsItem, for (auto it = dependsItem->properties().begin(); it != dependsItem->properties().end(); ++it) { if (it.value()->type() != Value::ItemValueType) continue; - forwardParameterDeclarations(it.key(), it.value().staticCast<ItemValue>()->item(), modules); + forwardParameterDeclarations(it.key(), + std::static_pointer_cast<ItemValue>(it.value())->item(), + modules); } } @@ -2062,7 +2065,8 @@ void ModuleLoader::forwardParameterDeclarations(const QualifiedId &moduleName, I if (it.value()->type() != Value::ItemValueType) continue; forwardParameterDeclarations(QualifiedId(moduleName) << it.key(), - it.value().staticCast<ItemValue>()->item(), modules); + std::static_pointer_cast<ItemValue>(it.value())->item(), + modules); } } } @@ -2148,7 +2152,7 @@ Item *ModuleLoader::moduleInstanceItem(Item *containerItem, const QualifiedId &m const QString &moduleNameSegment = moduleName.at(i); const ValuePtr v = instance->ownProperty(moduleName.at(i)); if (v && v->type() == Value::ItemValueType) { - instance = v.staticCast<ItemValue>()->item(); + instance = std::static_pointer_cast<ItemValue>(v)->item(); } else { const ItemType itemType = i < moduleName.count() - 1 ? ItemType::ModulePrefix : ItemType::ModuleInstance; @@ -2876,7 +2880,8 @@ void ModuleLoader::copyProperties(const Item *sourceProject, Item *targetProject || it.key() == QLatin1String("sourceDirectory") || it.key() == QLatin1String("minimumQbsVersion")) { const JSSourceValueConstPtr &v - = targetProject->property(it.key()).dynamicCast<const JSSourceValue>(); + = std::dynamic_pointer_cast<const JSSourceValue>( + targetProject->property(it.key())); QBS_ASSERT(v, continue); if (v->sourceCode() == QLatin1String("undefined")) sourceProject->copyProperty(it.key(), targetProject); @@ -2934,7 +2939,7 @@ void ModuleLoader::forwardScopeToItemValues(Item *item, Item *scope) for (const ValuePtr &v : itemProperties) { if (v->type() != Value::ItemValueType) continue; - Item *k = v.staticCast<ItemValue>()->item(); + Item *k = std::static_pointer_cast<ItemValue>(v)->item(); if (k->type() == ItemType::ModulePrefix) forwardScopeToItemValues(k, scope); else diff --git a/src/lib/corelib/language/moduleloader.h b/src/lib/corelib/language/moduleloader.h index 9ca6cc55d..7a0866a63 100644 --- a/src/lib/corelib/language/moduleloader.h +++ b/src/lib/corelib/language/moduleloader.h @@ -95,7 +95,7 @@ struct ModuleLoaderResult ErrorInfo delayedError; }; - QSharedPointer<ItemPool> itemPool; + std::shared_ptr<ItemPool> itemPool; Item *root; QHash<Item *, ProductInfo> productInfos; QList<ProbeConstPtr> projectProbes; diff --git a/src/lib/corelib/language/modulemerger.cpp b/src/lib/corelib/language/modulemerger.cpp index bfeec9ba2..e9267e4c9 100644 --- a/src/lib/corelib/language/modulemerger.cpp +++ b/src/lib/corelib/language/modulemerger.cpp @@ -68,7 +68,7 @@ void ModuleMerger::replaceItemInValues(QualifiedId moduleName, Item *containerIt for (auto it = properties.begin(); it != properties.end(); ++it) { if (it.key() != moduleNamePrefix) continue; - Value * const val = it.value().data(); + Value * const val = it.value().get(); QBS_CHECK(val); QBS_CHECK(val->type() == Value::ItemValueType); ItemValue * const itemVal = static_cast<ItemValue *>(val); @@ -189,10 +189,10 @@ void ModuleMerger::mergeOutProps(Item::PropertyMap *dst, const Item::PropertyMap continue; } // possible conflict - JSSourceValuePtr dstVal = v.dynamicCast<JSSourceValue>(); + JSSourceValuePtr dstVal = std::dynamic_pointer_cast<JSSourceValue>(v); if (!dstVal) continue; - JSSourceValuePtr srcVal = it.value().dynamicCast<JSSourceValue>(); + JSSourceValuePtr srcVal = std::dynamic_pointer_cast<JSSourceValue>(it.value()); if (!srcVal) continue; diff --git a/src/lib/corelib/language/projectresolver.cpp b/src/lib/corelib/language/projectresolver.cpp index c81c1fd0a..fdca9c40e 100644 --- a/src/lib/corelib/language/projectresolver.cpp +++ b/src/lib/corelib/language/projectresolver.cpp @@ -190,7 +190,8 @@ QString ProjectResolver::verbatimValue(const ValueConstPtr &value, bool *propert { QString result; if (value && value->type() == Value::JSSourceValueType) { - const JSSourceValueConstPtr sourceValue = value.staticCast<const JSSourceValue>(); + const JSSourceValueConstPtr sourceValue = std::static_pointer_cast<const JSSourceValue>( + value); result = sourceCodeForEvaluation(sourceValue); if (propertyWasSet) *propertyWasSet = (result != QLatin1String("undefined")); @@ -585,7 +586,7 @@ static void gatherAssignedProperties(ItemValue *iv, const QualifiedId &prefix, properties << (QualifiedId(prefix) << it.key()); break; case Value::ItemValueType: - gatherAssignedProperties(it.value().staticCast<ItemValue>().data(), + gatherAssignedProperties(std::static_pointer_cast<ItemValue>(it.value()).get(), QualifiedId(prefix) << it.key(), properties); break; default: @@ -601,7 +602,7 @@ QVariantMap ProjectResolver::resolveAdditionalModuleProperties(const Item *group QList<QualifiedId> propsSetInGroup; for (auto it = group->properties().cbegin(); it != group->properties().cend(); ++it) { if (it.value()->type() == Value::ItemValueType) { - gatherAssignedProperties(it.value().staticCast<ItemValue>().data(), + gatherAssignedProperties(std::static_pointer_cast<ItemValue>(it.value()).get(), QualifiedId(it.key()), propsSetInGroup); } } @@ -899,7 +900,8 @@ void ProjectResolver::resolveRuleArtifact(const RulePtr &rule, Item *item) { if (it.value()->type() != Value::ItemValueType) continue; - resolveRuleArtifactBinding(artifact, it.value().staticCast<ItemValue>()->item(), + resolveRuleArtifactBinding(artifact, + std::static_pointer_cast<ItemValue>(it.value())->item(), QStringList(it.key()), &seenBindings); } } @@ -916,13 +918,13 @@ void ProjectResolver::resolveRuleArtifactBinding(const RuleArtifactPtr &ruleArti const QStringList name = QStringList(namePrefix) << it.key(); if (it.value()->type() == Value::ItemValueType) { resolveRuleArtifactBinding(ruleArtifact, - it.value().staticCast<ItemValue>()->item(), name, + std::static_pointer_cast<ItemValue>(it.value())->item(), name, seenBindings); } else if (it.value()->type() == Value::JSSourceValueType) { const auto insertResult = seenBindings->insert(name); if (!insertResult.second) continue; - JSSourceValuePtr sourceValue = it.value().staticCast<JSSourceValue>(); + JSSourceValuePtr sourceValue = std::static_pointer_cast<JSSourceValue>(it.value()); RuleArtifact::Binding rab; rab.name = name; rab.code = sourceCodeForEvaluation(sourceValue); @@ -1072,19 +1074,19 @@ static bool hasDependencyCycle(Set<ResolvedProduct *> *checked, const ResolvedProductPtr &product, ErrorInfo *error) { - if (branch->contains(product.data())) + if (branch->contains(product.get())) return true; - if (checked->contains(product.data())) + if (checked->contains(product.get())) return false; - checked->insert(product.data()); - branch->insert(product.data()); + checked->insert(product.get()); + branch->insert(product.get()); for (const ResolvedProductPtr &dep : qAsConst(product->dependencies)) { if (hasDependencyCycle(checked, branch, dep, error)) { error->prepend(dep->name, dep->location); return true; } } - branch->remove(product.data()); + branch->remove(product.get()); return false; } @@ -1095,9 +1097,9 @@ void gatherDependencies(ResolvedProduct *product, DependencyMap &dependencies) return; Set<ResolvedProduct *> &productDeps = dependencies[product]; for (const ResolvedProductPtr &dep : qAsConst(product->dependencies)) { - productDeps << dep.data(); - gatherDependencies(dep.data(), dependencies); - productDeps += dependencies.value(dep.data()); + productDeps << dep.get(); + gatherDependencies(dep.get(), dependencies); + productDeps += dependencies.value(dep.get()); } } @@ -1107,7 +1109,7 @@ static DependencyMap allDependencies(const QList<ResolvedProductPtr> &products) { DependencyMap dependencies; for (const ResolvedProductPtr &product : products) - gatherDependencies(product.data(), dependencies); + gatherDependencies(product.get(), dependencies); return dependencies; } @@ -1267,7 +1269,7 @@ QVariantMap ProjectResolver::evaluateProperties(const Item *item, const Item *pr { if (result.contains(it.key())) break; - VariantValuePtr vvp = it.value().staticCast<VariantValue>(); + VariantValuePtr vvp = std::static_pointer_cast<VariantValue>(it.value()); QVariant v = vvp->value(); if (v.isNull() && !item->propertyDeclaration(it.key()).isScalar()) // QTBUG-51237 diff --git a/src/lib/corelib/language/tst_language.cpp b/src/lib/corelib/language/tst_language.cpp index 729705764..579441687 100644 --- a/src/lib/corelib/language/tst_language.cpp +++ b/src/lib/corelib/language/tst_language.cpp @@ -131,7 +131,7 @@ void TestLanguage::handleInitCleanupDataTags(const char *projectFileName, bool * try { defaultParameters.setProjectFilePath(testProject(projectFileName)); project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); } catch (const ErrorInfo &e) { exceptionCaught = true; qDebug() << e.toString(); @@ -139,7 +139,7 @@ void TestLanguage::handleInitCleanupDataTags(const char *projectFileName, bool * QCOMPARE(exceptionCaught, false); } else if (dataTag == "cleanup") { *handled = true; - project.clear(); + project.reset(); } else { *handled = false; } @@ -155,7 +155,7 @@ void TestLanguage::init() handleInitCleanupDataTags(fn, &handled);\ if (handled)\ return;\ - QVERIFY(project);\ + QVERIFY(!!project);\ } void TestLanguage::initTestCase() @@ -183,10 +183,10 @@ void TestLanguage::baseProperty() try { defaultParameters.setProjectFilePath(testProject("baseproperty.qbs")); project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); ResolvedProductPtr product = products.value("product1"); - QVERIFY(product); + QVERIFY(!!product); QVariantMap cfg = product->productProperties; QCOMPARE(cfg.value("narf").toStringList(), QStringList() << "boo"); QCOMPARE(cfg.value("zort").toStringList(), QStringList() << "bar" << "boo"); @@ -220,7 +220,7 @@ void TestLanguage::buildConfigStringListSyntax() parameters.setOverriddenValues(overriddenValues); parameters.setProjectFilePath(testProject("buildconfigstringlistsyntax.qbs")); project = loader->loadProject(parameters); - QVERIFY(project); + QVERIFY(!!project); QCOMPARE(project->projectProperties().value("someStrings").toStringList(), QStringList() << "foo" << "bar" << "baz"); } catch (const ErrorInfo &e) { @@ -236,7 +236,7 @@ void TestLanguage::builtinFunctionInSearchPathsProperty() try { SetupProjectParameters parameters = defaultParameters; parameters.setProjectFilePath(testProject("builtinFunctionInSearchPathsProperty.qbs")); - QVERIFY(loader->loadProject(parameters)); + QVERIFY(!!loader->loadProject(parameters)); } catch (const ErrorInfo &e) { exceptionCaught = true; qDebug() << e.toString(); @@ -251,7 +251,7 @@ void TestLanguage::chainedProbes() SetupProjectParameters parameters = defaultParameters; parameters.setProjectFilePath(testProject("chained-probes/chained-probes.qbs")); const TopLevelProjectConstPtr project = loader->loadProject(parameters); - QVERIFY(project); + QVERIFY(!!project); QCOMPARE(project->products.count(), 1); const QString prop2Val = project->products.first()->moduleProperties ->moduleProperty("m", "prop2").toString(); @@ -270,7 +270,7 @@ void TestLanguage::versionCompare() try { SetupProjectParameters parameters = defaultParameters; parameters.setProjectFilePath(testProject("versionCompare.qbs")); - QVERIFY(loader->loadProject(parameters)); + QVERIFY(!!loader->loadProject(parameters)); } catch (const ErrorInfo &e) { exceptionCaught = true; qDebug() << e.toString(); @@ -284,10 +284,10 @@ void TestLanguage::canonicalArchitecture() try { defaultParameters.setProjectFilePath(testProject("canonicalArchitecture.qbs")); project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); ResolvedProductPtr product = products.value(QLatin1String("x86")); - QVERIFY(product); + QVERIFY(!!product); } catch (const ErrorInfo &e) { exceptionCaught = true; qDebug() << e.toString(); @@ -301,11 +301,11 @@ void TestLanguage::rfc1034Identifier() try { defaultParameters.setProjectFilePath(testProject("rfc1034identifier.qbs")); project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); ResolvedProductPtr product = products.value(QLatin1String("this-has-special-characters-" "uh-oh-Undersc0r3s-Are.Bad")); - QVERIFY(product); + QVERIFY(!!product); } catch (const ErrorInfo &e) { exceptionCaught = true; qDebug() << e.toString(); @@ -321,65 +321,65 @@ void TestLanguage::conditionalDepends() try { defaultParameters.setProjectFilePath(testProject("conditionaldepends.qbs")); project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); product = products.value("conditionaldepends_derived"); - QVERIFY(product); + QVERIFY(!!product); dependency = findModuleByName(product, "dummy"); - QVERIFY(dependency); + QVERIFY(!!dependency); product = products.value("conditionaldepends_derived_false"); - QVERIFY(product); + QVERIFY(!!product); dependency = findModuleByName(product, "dummy"); QCOMPARE(dependency, ResolvedModuleConstPtr()); product = products.value("product_props_true"); - QVERIFY(product); + QVERIFY(!!product); dependency = findModuleByName(product, "dummy"); - QVERIFY(dependency); + QVERIFY(!!dependency); product = products.value("product_props_false"); - QVERIFY(product); + QVERIFY(!!product); dependency = findModuleByName(product, "dummy"); QCOMPARE(dependency, ResolvedModuleConstPtr()); product = products.value("project_props_true"); - QVERIFY(product); + QVERIFY(!!product); dependency = findModuleByName(product, "dummy"); - QVERIFY(dependency); + QVERIFY(!!dependency); product = products.value("project_props_false"); - QVERIFY(product); + QVERIFY(!!product); dependency = findModuleByName(product, "dummy"); QCOMPARE(dependency, ResolvedModuleConstPtr()); product = products.value("module_props_true"); - QVERIFY(product); + QVERIFY(!!product); dependency = findModuleByName(product, "dummy2"); - QVERIFY(dependency); + QVERIFY(!!dependency); dependency = findModuleByName(product, "dummy"); - QVERIFY(dependency); + QVERIFY(!!dependency); product = products.value("module_props_false"); - QVERIFY(product); + QVERIFY(!!product); dependency = findModuleByName(product, "dummy2"); - QVERIFY(dependency); + QVERIFY(!!dependency); dependency = findModuleByName(product, "dummy"); QCOMPARE(dependency, ResolvedModuleConstPtr()); product = products.value("contradictory_conditions1"); - QVERIFY(product); + QVERIFY(!!product); dependency = findModuleByName(product, "dummy"); - QVERIFY(dependency); + QVERIFY(!!dependency); product = products.value("contradictory_conditions2"); - QVERIFY(product); + QVERIFY(!!product); dependency = findModuleByName(product, "dummy"); - QVERIFY(dependency); + QVERIFY(!!dependency); product = products.value("unknown_dependency_condition_false"); - QVERIFY(product); + QVERIFY(!!product); dependency = findModuleByName(product, "doesonlyexistifhellfreezesover"); QVERIFY(!dependency); } catch (const ErrorInfo &e) { @@ -401,10 +401,10 @@ void TestLanguage::delayedError() params.setOverriddenValues(overriddenValues); project = loader->loadProject(params); QCOMPARE(productEnabled, false); - QVERIFY(project); + QVERIFY(!!project); QCOMPARE(project->products.count(), 1); const ResolvedProductConstPtr theProduct = productsFromProject(project).value("theProduct"); - QVERIFY(theProduct); + QVERIFY(!!theProduct); QCOMPARE(theProduct->enabled, false); } catch (const ErrorInfo &e) { if (!productEnabled) @@ -442,10 +442,10 @@ void qbs::Internal::TestLanguage::dependencyOnAllProfiles() overriddenValues.insert("project.profile2", "p2"); params.setOverriddenValues(overriddenValues); project = loader->loadProject(params); - QVERIFY(project); + QVERIFY(!!project); QCOMPARE(project->products.count(), 3); const ResolvedProductConstPtr mainProduct = productsFromProject(project).value("main"); - QVERIFY(mainProduct); + QVERIFY(!!mainProduct); QCOMPARE(mainProduct->dependencies.count(), 2); foreach (const ResolvedProductConstPtr &p, mainProduct->dependencies) { QCOMPARE(p->name, QLatin1String("dep")); @@ -465,7 +465,7 @@ void TestLanguage::derivedSubProject() SetupProjectParameters params = defaultParameters; params.setProjectFilePath(testProject("derived-sub-project/project.qbs")); const TopLevelProjectPtr project = loader->loadProject(params); - QVERIFY(project); + QVERIFY(!!project); const QHash<QString, ResolvedProductPtr> products = productsFromProject(project); QCOMPARE(products.count(), 1); } catch (const ErrorInfo &e) { @@ -482,7 +482,7 @@ void TestLanguage::enumerateProjectProperties() SetupProjectParameters params = defaultParameters; params.setProjectFilePath(testProject("enum-project-props.qbs")); auto project = loader->loadProject(params); - QVERIFY(project); + QVERIFY(!!project); auto products = productsFromProject(project); QCOMPARE(products.count(), 1); auto product = products.values().first(); @@ -510,11 +510,11 @@ void TestLanguage::defaultValue() overridden.insert("modules.lower.prop1", prop1Value); params.setOverriddenValues(overridden); TopLevelProjectPtr project = loader->loadProject(params); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); QCOMPARE(products.count(), 2); const ResolvedProductPtr product = products.value("egon"); - QVERIFY(product); + QVERIFY(!!product); QStringList propertyName = QStringList() << "modules" << "lower" << "prop2"; QVariant propertyValue = product->moduleProperties->property(propertyName); QFETCH(QVariant, expectedProp2Value); @@ -564,10 +564,10 @@ void TestLanguage::environmentVariable() defaultParameters.setEnvironment(origEnv); // reset environment - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); ResolvedProductPtr product = products.value(productName); - QVERIFY(product); + QVERIFY(!!product); } catch (const ErrorInfo &e) { exceptionCaught = true; qDebug() << e.toString(); @@ -706,12 +706,12 @@ void TestLanguage::exports() try { defaultParameters.setProjectFilePath(testProject("exports.qbs")); TopLevelProjectPtr project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); QCOMPARE(products.count(), 17); ResolvedProductPtr product; product = products.value("myapp"); - QVERIFY(product); + QVERIFY(!!product); QStringList propertyName = QStringList() << "modules" << "dummy" << "defines"; QVariant propertyValue = product->moduleProperties->property(propertyName); QCOMPARE(propertyValue.toStringList(), QStringList() << "BUILD_MYAPP" << "USE_MYLIB" @@ -727,34 +727,34 @@ void TestLanguage::exports() QString("myapp")); product = products.value("mylib"); - QVERIFY(product); + QVERIFY(!!product); propertyName = QStringList() << "modules" << "dummy" << "defines"; propertyValue = product->moduleProperties->property(propertyName); QCOMPARE(propertyValue.toStringList(), QStringList() << "BUILD_MYLIB"); product = products.value("mylib2"); - QVERIFY(product); + QVERIFY(!!product); propertyName = QStringList() << "modules" << "dummy" << "defines"; propertyValue = product->moduleProperties->property(propertyName); QCOMPARE(propertyValue.toStringList(), QStringList() << "BUILD_MYLIB2"); product = products.value("A"); - QVERIFY(product); + QVERIFY(!!product); QVERIFY(product->dependencies.contains(products.value("B"))); QVERIFY(product->dependencies.contains(products.value("C"))); QVERIFY(product->dependencies.contains(products.value("D"))); product = products.value("B"); - QVERIFY(product); + QVERIFY(!!product); QVERIFY(product->dependencies.isEmpty()); product = products.value("C"); - QVERIFY(product); + QVERIFY(!!product); QVERIFY(product->dependencies.isEmpty()); product = products.value("D"); - QVERIFY(product); + QVERIFY(!!product); QVERIFY(product->dependencies.isEmpty()); product = products.value("myapp2"); - QVERIFY(product); + QVERIFY(!!product); propertyName = QStringList() << "modules" << "dummy" << "cFlags"; propertyValue = product->moduleProperties->property(propertyName); QCOMPARE(propertyValue.toStringList(), QStringList() @@ -773,7 +773,7 @@ void TestLanguage::exports() // Check whether we're returning incorrect cached values. product = products.value("myapp3"); - QVERIFY(product); + QVERIFY(!!product); QCOMPARE(product->moduleProperties->moduleProperty("dummy", "productName").toString(), QString("myapp3")); QCOMPARE(product->moduleProperties->moduleProperty("dummy", @@ -781,12 +781,12 @@ void TestLanguage::exports() // Verify we refer to the right "project" variable. product = products.value("sub p2"); - QVERIFY(product); + QVERIFY(!!product); QCOMPARE(product->moduleProperties->moduleProperty("dummy", "someString").toString(), QString("sub1")); product = products.value("libE"); - QVERIFY(product); + QVERIFY(!!product); propertyName = QStringList() << "modules" << "dummy" << "defines"; propertyValue = product->moduleProperties->property(propertyName); QCOMPARE(propertyValue.toStringList(), @@ -808,10 +808,10 @@ void TestLanguage::fileContextProperties() try { defaultParameters.setProjectFilePath(testProject("filecontextproperties.qbs")); project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); ResolvedProductPtr product = products.value("product1"); - QVERIFY(product); + QVERIFY(!!product); QVariantMap cfg = product->productProperties; QCOMPARE(cfg.value("narf").toString(), defaultParameters.projectFilePath()); QString dirPath = QFileInfo(defaultParameters.projectFilePath()).absolutePath(); @@ -838,14 +838,14 @@ void TestLanguage::getNativeSetting() else expectedTargetName = QLatin1String("Unix"); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products; for (const ResolvedProductPtr &product : project->allProducts()) products.insert(product->targetName, product); ResolvedProductPtr product = products.value(expectedTargetName); - QVERIFY(product); + QVERIFY(!!product); ResolvedProductPtr product2 = products.value(QLatin1String("fallback")); - QVERIFY(product2); + QVERIFY(!!product2); } catch (const ErrorInfo &e) { exceptionCaught = true; qDebug() << e.toString(); @@ -884,7 +884,7 @@ void TestLanguage::groupConditions() const QHash<QString, ResolvedProductPtr> products = productsFromProject(project); const QString productName = QString::fromLocal8Bit(QTest::currentDataTag()); ResolvedProductPtr product = products.value(productName); - QVERIFY(product); + QVERIFY(!!product); QCOMPARE(product->name, productName); QCOMPARE(product->groups.count(), groupCount); for (int i = 0; i < groupCount; ++i) { @@ -901,31 +901,31 @@ void TestLanguage::groupName() try { defaultParameters.setProjectFilePath(testProject("groupname.qbs")); TopLevelProjectPtr project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); QCOMPARE(products.count(), 2); ResolvedProductPtr product = products.value("MyProduct"); - QVERIFY(product); + QVERIFY(!!product); QCOMPARE(product->groups.count(), 2); GroupConstPtr group = product->groups.at(0); - QVERIFY(group); + QVERIFY(!!group); QCOMPARE(group->name, QString("MyProduct")); group = product->groups.at(1); - QVERIFY(group); + QVERIFY(!!group); QCOMPARE(group->name, QString("MyProduct.MyGroup")); product = products.value("My2ndProduct"); - QVERIFY(product); + QVERIFY(!!product); QCOMPARE(product->groups.count(), 3); group = product->groups.at(0); - QVERIFY(group); + QVERIFY(!!group); QCOMPARE(group->name, QString("My2ndProduct")); group = product->groups.at(1); - QVERIFY(group); + QVERIFY(!!group); QCOMPARE(group->name, QString("My2ndProduct.MyGroup")); group = product->groups.at(2); - QVERIFY(group); + QVERIFY(!!group); QCOMPARE(group->name, QString("Group 2")); } catch (const ErrorInfo &e) { @@ -940,12 +940,12 @@ void TestLanguage::homeDirectory() try { defaultParameters.setProjectFilePath(testProject("homeDirectory.qbs")); ResolvedProjectPtr project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); QCOMPARE(products.count(), 1); ResolvedProductPtr product = products.value("home"); - QVERIFY(product); + QVERIFY(!!product); QDir dir = QDir::home(); QCOMPARE(product->productProperties.value("home").toString(), dir.path()); @@ -1046,7 +1046,7 @@ void TestLanguage::idUsage() try { defaultParameters.setProjectFilePath(testProject("idusage.qbs")); TopLevelProjectPtr project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); QCOMPARE(products.count(), 3); QVERIFY(products.contains("product1_1")); @@ -1084,7 +1084,7 @@ void TestLanguage::importCollection() try { defaultParameters.setProjectFilePath(testProject("import-collection/project.qbs")); const TopLevelProjectPtr project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); const ResolvedProductConstPtr product = products.value("da product"); QCOMPARE(product->productProperties.value("targetName").toString(), @@ -1103,7 +1103,7 @@ void TestLanguage::invalidBindingInDisabledItem() try { defaultParameters.setProjectFilePath(testProject("invalidBindingInDisabledItem.qbs")); TopLevelProjectPtr project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); QCOMPARE(products.count(), 2); } @@ -1220,11 +1220,11 @@ void TestLanguage::jsImportUsedInMultipleScopes() buildVariant)}); params.expandBuildConfiguration(); TopLevelProjectPtr project = loader->loadProject(params); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); QCOMPARE(products.count(), 1); ResolvedProductPtr product = products.values().first(); - QVERIFY(product); + QVERIFY(!!product); QCOMPARE(product->name, expectedProductName); } catch (const ErrorInfo &e) { @@ -1269,7 +1269,7 @@ void TestLanguage::moduleProperties() QHash<QString, ResolvedProductPtr> products = productsFromProject(project); const QString productName = QString::fromLocal8Bit(QTest::currentDataTag()); ResolvedProductPtr product = products.value(productName); - QVERIFY(product); + QVERIFY(!!product); QVariant values = product->moduleProperties->moduleProperty("dummy", propertyName); QStringList valueStrings; foreach (const QVariant &v, values.toList()) @@ -1283,10 +1283,10 @@ void TestLanguage::modulePropertiesInGroups() bool exceptionCaught = false; try { TopLevelProjectPtr project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); const QHash<QString, ResolvedProductPtr> products = productsFromProject(project); const ResolvedProductPtr product = products.value("grouptest"); - QVERIFY(product); + QVERIFY(!!product); GroupConstPtr g1; GroupConstPtr g11; GroupConstPtr g12; @@ -1307,12 +1307,12 @@ void TestLanguage::modulePropertiesInGroups() else if (g->name == "g2.1.1") g211 = g; } - QVERIFY(g1); - QVERIFY(g2); - QVERIFY(g11); - QVERIFY(g12); - QVERIFY(g21); - QVERIFY(g211); + QVERIFY(!!g1); + QVERIFY(!!g2); + QVERIFY(!!g11); + QVERIFY(!!g12); + QVERIFY(!!g21); + QVERIFY(!!g211); const QVariantMap productProps = product->moduleProperties->value(); const auto &productGmod1List1 = moduleProperty(productProps, "gmod.gmod1", "gmod1_list1") @@ -1473,11 +1473,11 @@ void TestLanguage::moduleScope() try { defaultParameters.setProjectFilePath(testProject("modulescope.qbs")); TopLevelProjectPtr project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); QCOMPARE(products.count(), 1); ResolvedProductPtr product = products.value("product1"); - QVERIFY(product); + QVERIFY(!!product); auto intModuleValue = [product] (const QString &name) -> int { @@ -1542,7 +1542,7 @@ void TestLanguage::modules() QHash<QString, ResolvedProductPtr> products = productsFromProject(project); const QString productName = QString::fromLocal8Bit(QTest::currentDataTag()); ResolvedProductPtr product = products.value(productName); - QVERIFY(product); + QVERIFY(!!product); QCOMPARE(product->name, productName); QStringList modulesInProduct; foreach (ResolvedModuleConstPtr m, product->modules) @@ -1568,15 +1568,15 @@ void TestLanguage::nonRequiredProducts() overriddenValues.insert("products.dependee.condition", false); params.setOverriddenValues(overriddenValues); const TopLevelProjectPtr project = loader->loadProject(params); - QVERIFY(project); + QVERIFY(!!project); const auto products = productsFromProject(project); QCOMPARE(products.count(), 4 + !!subProjectEnabled); const ResolvedProductConstPtr dependee = products.value("dependee"); - QCOMPARE(subProjectEnabled, !dependee.isNull()); + QCOMPARE(subProjectEnabled, !!dependee); if (dependee) QCOMPARE(dependeeEnabled, dependee->enabled); const ResolvedProductConstPtr depender = products.value("depender"); - QVERIFY(depender); + QVERIFY(!!depender); const QStringList defines = depender->moduleProperties->moduleProperty("dummy", "defines") .toStringList(); QCOMPARE(subProjectEnabled && dependeeEnabled, defines.contains("WITH_DEPENDEE")); @@ -1609,21 +1609,21 @@ void TestLanguage::outerInGroup() try { defaultParameters.setProjectFilePath(testProject("outerInGroup.qbs")); TopLevelProjectPtr project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); QCOMPARE(products.count(), 1); ResolvedProductPtr product = products.value("OuterInGroup"); - QVERIFY(product); + QVERIFY(!!product); QCOMPARE(product->groups.count(), 2); GroupPtr group = product->groups.at(0); - QVERIFY(group); + QVERIFY(!!group); QCOMPARE(group->name, product->name); QCOMPARE(group->files.count(), 1); SourceArtifactConstPtr artifact = group->files.first(); QVariant installDir = artifact->properties->qbsPropertyValue("installDir"); QCOMPARE(installDir.toString(), QString("/somewhere")); group = product->groups.at(1); - QVERIFY(group); + QVERIFY(!!group); QCOMPARE(group->name, QString("Special Group")); QCOMPARE(group->files.count(), 1); artifact = group->files.first(); @@ -1657,10 +1657,10 @@ void TestLanguage::pathProperties() try { defaultParameters.setProjectFilePath(testProject("pathproperties.qbs")); project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); ResolvedProductPtr product = products.value("product1"); - QVERIFY(product); + QVERIFY(!!product); QString projectFileDir = QFileInfo(defaultParameters.projectFilePath()).absolutePath(); const QVariantMap productProps = product->productProperties; QCOMPARE(productProps.value("projectFileDir").toString(), projectFileDir); @@ -1700,10 +1700,10 @@ void TestLanguage::profileValuesAndOverriddenValues() parameters.setProjectFilePath(testProject("profilevaluesandoverriddenvalues.qbs")); parameters.expandBuildConfiguration(); project = loader->loadProject(parameters); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); ResolvedProductPtr product = products.value("product1"); - QVERIFY(product); + QVERIFY(!!product); QVariantList values; values = product->moduleProperties->moduleProperty("dummy", "cxxFlags").toList(); QCOMPARE(values.length(), 1); @@ -1726,32 +1726,32 @@ void TestLanguage::productConditions() try { defaultParameters.setProjectFilePath(testProject("productconditions.qbs")); TopLevelProjectPtr project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); QCOMPARE(products.count(), 6); ResolvedProductPtr product; product = products.value("product_no_condition"); - QVERIFY(product); + QVERIFY(!!product); QVERIFY(product->enabled); product = products.value("product_true_condition"); - QVERIFY(product); + QVERIFY(!!product); QVERIFY(product->enabled); product = products.value("product_condition_dependent_of_module"); - QVERIFY(product); + QVERIFY(!!product); QVERIFY(product->enabled); product = products.value("product_false_condition"); - QVERIFY(product); + QVERIFY(!!product); QVERIFY(!product->enabled); product = products.value("product_probe_condition_false"); - QVERIFY(product); + QVERIFY(!!product); QVERIFY(!product->enabled); product = products.value("product_probe_condition_true"); - QVERIFY(product); + QVERIFY(!!product); QVERIFY(product->enabled); } catch (const ErrorInfo &e) { @@ -1767,12 +1767,12 @@ void TestLanguage::productDirectories() try { defaultParameters.setProjectFilePath(testProject("productdirectories.qbs")); ResolvedProjectPtr project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); QCOMPARE(products.count(), 1); ResolvedProductPtr product; product = products.value("MyApp"); - QVERIFY(product); + QVERIFY(!!product); const QVariantMap config = product->productProperties; QCOMPARE(config.value(QLatin1String("buildDirectory")).toString(), product->buildDirectory()); @@ -1882,11 +1882,11 @@ void TestLanguage::propertiesBlocks() QFETCH(QString, propertyName); QFETCH(QStringList, expectedValues); QFETCH(QString, expectedStringValue); - QVERIFY(project); + QVERIFY(!!project); QHash<QString, ResolvedProductPtr> products = productsFromProject(project); const QString productName = QString::fromLocal8Bit(QTest::currentDataTag()); ResolvedProductPtr product = products.value(productName); - QVERIFY(product); + QVERIFY(!!product); QCOMPARE(product->name, productName); QVariant v = productPropertyValue(product, propertyName); QCOMPARE(v.toStringList(), expectedValues); @@ -1902,7 +1902,7 @@ void TestLanguage::propertiesBlockInGroup() try { defaultParameters.setProjectFilePath(testProject("properties-block-in-group.qbs")); const TopLevelProjectPtr project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); QCOMPARE(project->allProducts().count(), 1); const ResolvedProductConstPtr product = project->allProducts().first(); const auto groupIt = std::find_if(product->groups.constBegin(), product->groups.constEnd(), @@ -1928,7 +1928,7 @@ void TestLanguage::propertiesItemInModule() defaultParameters.setProjectFilePath( testProject("properties-item-in-module.qbs")); const TopLevelProjectPtr project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); const QHash<QString, ResolvedProductPtr> products = productsFromProject(project); QCOMPARE(products.count(), 2); for (const ResolvedProductConstPtr &p : products) { @@ -1949,7 +1949,7 @@ void TestLanguage::qbsPropertiesInProjectCondition() defaultParameters.setProjectFilePath( testProject("qbs-properties-in-project-condition.qbs")); const TopLevelProjectPtr project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); const QHash<QString, ResolvedProductPtr> products = productsFromProject(project); QCOMPARE(products.count(), 0); } catch (const ErrorInfo &e) { @@ -2017,7 +2017,7 @@ void TestLanguage::requiredAndNonRequiredDependencies() const QString projectFilePath = "required-and-nonrequired-dependencies/" + projectFile; params.setProjectFilePath(testProject(projectFilePath.toLocal8Bit())); const TopLevelProjectConstPtr project = loader->loadProject(params); - QVERIFY(project); + QVERIFY(!!project); QVERIFY(!exceptionExpected); } catch (const ErrorInfo &e) { QVERIFY(exceptionExpected); @@ -2050,7 +2050,7 @@ void TestLanguage::throwingProbe() properties.insert(QLatin1String("products.theProduct.enableProbe"), enableProbe); params.setOverriddenValues(properties); const TopLevelProjectPtr project = loader->loadProject(params); - QVERIFY(project); + QVERIFY(!!project); QVERIFY(!enableProbe); } catch (const ErrorInfo &e) { QVERIFY2(enableProbe, qPrintable(e.toString())); @@ -2094,17 +2094,17 @@ void TestLanguage::recursiveProductDependencies() defaultParameters.setProjectFilePath( testProject("recursive-dependencies/recursive-dependencies.qbs")); const TopLevelProjectPtr project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); const QHash<QString, ResolvedProductPtr> products = productsFromProject(project); QCOMPARE(products.count(), 4); const ResolvedProductConstPtr p1 = products.value("p1"); - QVERIFY(p1); + QVERIFY(!!p1); const ResolvedProductConstPtr p2 = products.value("p2"); - QVERIFY(p2); + QVERIFY(!!p2); const ResolvedProductPtr p3 = products.value("p3"); - QVERIFY(p3); + QVERIFY(!!p3); const ResolvedProductPtr p4 = products.value("p4"); - QVERIFY(p4); + QVERIFY(!!p4); QVERIFY(p1->dependencies == Set<ResolvedProductPtr>() << p3 << p4); QVERIFY(p2->dependencies == Set<ResolvedProductPtr>() << p3 << p4); } catch (const ErrorInfo &e) { @@ -2138,10 +2138,10 @@ void TestLanguage::fileTags() QHash<QString, ResolvedProductPtr> products = productsFromProject(project); ResolvedProductPtr product; const QString productName = QString::fromLocal8Bit(QTest::currentDataTag()); - QVERIFY(product = products.value(productName)); + QVERIFY(!!(product = products.value(productName))); QCOMPARE(product->groups.count(), numberOfGroups); GroupPtr group = product->groups.last(); - QVERIFY(group); + QVERIFY(!!group); QCOMPARE(group->files.count(), 1); SourceArtifactConstPtr sourceFile = group->files.first(); QStringList fileTags = sourceFile->fileTags.toStringList(); @@ -2351,10 +2351,10 @@ void TestLanguage::wildcards() try { defaultParameters.setProjectFilePath(projectFilePath); project = loader->loadProject(defaultParameters); - QVERIFY(project); + QVERIFY(!!project); const QHash<QString, ResolvedProductPtr> products = productsFromProject(project); product = products.value("MyProduct"); - QVERIFY(product); + QVERIFY(!!product); GroupPtr group; if (useGroup) { QCOMPARE(product->groups.count(), HostOsInfo::isMacosHost() ? 3 : 2); @@ -2368,10 +2368,10 @@ void TestLanguage::wildcards() QCOMPARE(product->groups.count(), HostOsInfo::isMacosHost() ? 2 : 1); group = product->groups.first(); } - QVERIFY(group); + QVERIFY(!!group); QCOMPARE(group->files.count(), 0); SourceWildCards::Ptr wildcards = group->wildcards; - QVERIFY(wildcards); + QVERIFY(!!wildcards); QStringList actualFilePaths; foreach (const SourceArtifactConstPtr &artifact, wildcards->files) { QString str = artifact->absoluteFilePath; diff --git a/src/lib/corelib/language/value.cpp b/src/lib/corelib/language/value.cpp index f1ddd770a..1b73ccf17 100644 --- a/src/lib/corelib/language/value.cpp +++ b/src/lib/corelib/language/value.cpp @@ -82,7 +82,7 @@ ValuePtr Value::next() const void Value::setNext(const ValuePtr &next) { - QBS_ASSERT(next.data() != this, return); + QBS_ASSERT(next.get() != this, return); m_next = next; } @@ -101,8 +101,9 @@ JSSourceValue::JSSourceValue(const JSSourceValue &other) : Value(other) m_column = other.m_column; m_file = other.m_file; m_flags = other.m_flags; - m_baseValue = other.m_baseValue ? other.m_baseValue->clone().staticCast<JSSourceValue>() - : JSSourceValuePtr(); + m_baseValue = other.m_baseValue + ? std::static_pointer_cast<JSSourceValue>(other.m_baseValue->clone()) + : JSSourceValuePtr(); for (const Alternative &otherAlt : qAsConst(other.m_alternatives)) m_alternatives << otherAlt.clone(); } diff --git a/src/lib/corelib/language/value.h b/src/lib/corelib/language/value.h index c38095697..ab2c3187a 100644 --- a/src/lib/corelib/language/value.h +++ b/src/lib/corelib/language/value.h @@ -147,7 +147,7 @@ public: Alternative clone() const { return Alternative(condition, overrideListProperties, - value->clone().staticCast<JSSourceValue>()); + std::static_pointer_cast<JSSourceValue>(value->clone())); } QString condition; diff --git a/src/lib/corelib/tools/persistence.h b/src/lib/corelib/tools/persistence.h index c94c1b963..5ae37eab6 100644 --- a/src/lib/corelib/tools/persistence.h +++ b/src/lib/corelib/tools/persistence.h @@ -46,10 +46,10 @@ #include <QtCore/qdatastream.h> #include <QtCore/qflags.h> #include <QtCore/qprocess.h> -#include <QtCore/qsharedpointer.h> #include <QtCore/qstring.h> #include <QtCore/qvariant.h> +#include <memory> #include <type_traits> #include <vector> @@ -99,7 +99,7 @@ private: typedef int PersistentObjectId; template <typename T> T *idLoad(); - template <class T> QSharedPointer<T> idLoadS(); + template <class T> std::shared_ptr<T> idLoadS(); void storePersistentObject(const PersistentObject *object); @@ -113,7 +113,7 @@ private: QDataStream m_stream; HeadData m_headData; std::vector<PersistentObject *> m_loadedRaw; - std::vector<QSharedPointer<PersistentObject> > m_loaded; + std::vector<std::shared_ptr<PersistentObject> > m_loaded; QHash<const PersistentObject *, int> m_storageIndices; PersistentObjectId m_lastStoredObjectId; @@ -148,23 +148,23 @@ template <typename T> inline T *PersistentPool::idLoad() return t; } -template <class T> inline QSharedPointer<T> PersistentPool::idLoadS() +template <class T> inline std::shared_ptr<T> PersistentPool::idLoadS() { PersistentObjectId id; m_stream >> id; if (id < 0) - return QSharedPointer<T>(); + return std::shared_ptr<T>(); if (id < static_cast<PersistentObjectId>(m_loaded.size())) { - QSharedPointer<PersistentObject> obj = m_loaded.at(id); - return obj.dynamicCast<T>(); + std::shared_ptr<PersistentObject> obj = m_loaded.at(id); + return std::dynamic_pointer_cast<T>(obj); } m_loaded.resize(id + 1); - const QSharedPointer<T> t = T::create(); + const std::shared_ptr<T> t = T::create(); m_loaded[id] = t; - PersistentObject * const po = t.data(); + PersistentObject * const po = t.get(); po->load(*this); return t; } @@ -199,14 +199,14 @@ template<typename T> struct IsPersistentObject }; template<typename T> -struct PersistentPool::Helper<QSharedPointer<T>, +struct PersistentPool::Helper<std::shared_ptr<T>, typename std::enable_if<IsPersistentObject<T>::value>::type> { - static void store(const QSharedPointer<T> &value, PersistentPool *pool) + static void store(const std::shared_ptr<T> &value, PersistentPool *pool) { - pool->store(value.data()); + pool->store(value.get()); } - static void load(QSharedPointer<T> &value, PersistentPool *pool) + static void load(std::shared_ptr<T> &value, PersistentPool *pool) { value = pool->idLoadS<typename std::remove_const<T>::type>(); } diff --git a/src/lib/corelib/tools/projectgeneratormanager.cpp b/src/lib/corelib/tools/projectgeneratormanager.cpp index a417be5e2..9d2e1ae7c 100644 --- a/src/lib/corelib/tools/projectgeneratormanager.cpp +++ b/src/lib/corelib/tools/projectgeneratormanager.cpp @@ -72,11 +72,11 @@ ProjectGeneratorManager *ProjectGeneratorManager::instance() ProjectGeneratorManager::ProjectGeneratorManager() { - std::vector<QSharedPointer<ProjectGenerator> > generators; - generators.push_back(QSharedPointer<ClangCompilationDatabaseGenerator>::create()); + std::vector<std::shared_ptr<ProjectGenerator> > generators; + generators.push_back(std::make_shared<ClangCompilationDatabaseGenerator>()); const auto vsGenerators = qbs::VisualStudioGenerator::createGeneratorList(); std::copy(vsGenerators.cbegin(), vsGenerators.cend(), std::back_inserter(generators)); - for (QSharedPointer<ProjectGenerator> generator : qAsConst(generators)) + for (const auto &generator : qAsConst(generators)) m_generators[generator->generatorName()] = generator; } @@ -85,7 +85,7 @@ QStringList ProjectGeneratorManager::loadedGeneratorNames() return instance()->m_generators.keys(); } -QSharedPointer<ProjectGenerator> ProjectGeneratorManager::findGenerator(const QString &generatorName) +std::shared_ptr<ProjectGenerator> ProjectGeneratorManager::findGenerator(const QString &generatorName) { return instance()->m_generators.value(generatorName); } diff --git a/src/lib/corelib/tools/projectgeneratormanager.h b/src/lib/corelib/tools/projectgeneratormanager.h index 611ee3d2b..d1796ccc6 100644 --- a/src/lib/corelib/tools/projectgeneratormanager.h +++ b/src/lib/corelib/tools/projectgeneratormanager.h @@ -45,7 +45,6 @@ #include <generators/generator.h> #include <QtCore/qmap.h> -#include <QtCore/qsharedpointer.h> #include <QtCore/qstring.h> #include <QtCore/qstringlist.h> @@ -65,14 +64,14 @@ public: ~ProjectGeneratorManager(); static ProjectGeneratorManager *instance(); static QStringList loadedGeneratorNames(); - static QSharedPointer<ProjectGenerator> findGenerator(const QString &generatorName); + static std::shared_ptr<ProjectGenerator> findGenerator(const QString &generatorName); private: ProjectGeneratorManager(); private: QList<QLibrary *> m_libs; - QMap<QString, QSharedPointer<ProjectGenerator> > m_generators; + QMap<QString, std::shared_ptr<ProjectGenerator> > m_generators; }; } // namespace qbs diff --git a/src/lib/corelib/tools/set.h b/src/lib/corelib/tools/set.h index 1fd180b21..3b94d18ec 100644 --- a/src/lib/corelib/tools/set.h +++ b/src/lib/corelib/tools/set.h @@ -42,13 +42,13 @@ #include <tools/persistence.h> -#include <QtCore/qsharedpointer.h> #include <QtCore/qstringlist.h> #include <QtCore/qvector.h> #include <algorithm> #include <functional> #include <iterator> +#include <memory> #include <set> #include <type_traits> @@ -62,7 +62,7 @@ template<typename T> Set<T> operator-(const Set<T> &set1, const Set<T> &set2); namespace helper { template<typename T> struct SortAfterLoad { static const bool required = false; }; template<typename T> struct SortAfterLoad<T *> { static const bool required = true; }; -template<typename T> struct SortAfterLoad<QSharedPointer<T>> { static const bool required = true; }; +template<typename T> struct SortAfterLoad<std::shared_ptr<T>> { static const bool required = true; }; } template<typename T> class Set diff --git a/src/lib/corelib/tools/weakpointer.h b/src/lib/corelib/tools/weakpointer.h index 8f78f5d20..fecae6825 100644 --- a/src/lib/corelib/tools/weakpointer.h +++ b/src/lib/corelib/tools/weakpointer.h @@ -39,31 +39,55 @@ #ifndef QBS_WEAKPOINTER_H #define QBS_WEAKPOINTER_H -#include <QtCore/qpointer.h> +#include <memory> namespace qbs { namespace Internal { -template<typename T> class WeakPointer : public QWeakPointer<T> +template<typename T> class WeakPointer : public std::weak_ptr<T> { public: - WeakPointer() : QWeakPointer<T>() {} - WeakPointer(const QSharedPointer<T> &sharedPointer) : QWeakPointer<T>(sharedPointer) {} - template <class X> WeakPointer(const QSharedPointer<X> &sp) : QWeakPointer<T>(sp) { } - + WeakPointer() : std::weak_ptr<T>() {} + WeakPointer(const std::shared_ptr<T> &sharedPointer) : std::weak_ptr<T>(sharedPointer) {} + template <class X> WeakPointer(const std::shared_ptr<X> &sp) : std::weak_ptr<T>(sp) { } + T *get() const { auto p = std::weak_ptr<T>::lock(); return p.get(); } + operator bool() const { return !std::weak_ptr<T>::expired(); } + bool operator!() const { return std::weak_ptr<T>::expired(); } operator T*() const { return checkedData(); } T *operator->() const { return checkedData(); } T operator*() const { return *checkedData(); } private: T *checkedData() const { - T * const d = QWeakPointer<T>::data(); + T * const d = get(); Q_ASSERT(d); // Calling code is not expecting this situation. return d; } }; +template <typename T> bool operator==(const WeakPointer<T> &a, const WeakPointer<T> &b) +{ + return a.get() == b.get(); +} + +template <typename T> bool operator!=(const WeakPointer<T> &a, const WeakPointer<T> &b) +{ + return a.get() != b.get(); +} + +template <typename T, typename V> bool operator==(const WeakPointer<T> &a, + const std::shared_ptr<V> &b) +{ + return a.lock() == b; +} + +template <typename T, typename V> bool operator!=(const WeakPointer<T> &a, + const std::shared_ptr<V> &b) +{ + return a.lock() != b; +} + } // namespace Internal } // namespace qbs |