Autogen: Use cm::make_unique to allocate jobs
diff --git a/Source/cmQtAutoGeneratorMocUic.cxx b/Source/cmQtAutoGeneratorMocUic.cxx
index c337ba4..e4b73e6 100644
--- a/Source/cmQtAutoGeneratorMocUic.cxx
+++ b/Source/cmQtAutoGeneratorMocUic.cxx
@@ -432,8 +432,8 @@
// Convert pre jobs to actual jobs
for (JobPre& jobPre : jobs) {
- JobHandleT jobHandle(new JobMocT(std::move(jobPre.SourceFile), FileName,
- std::move(jobPre.IncludeString)));
+ JobHandleT jobHandle = cm::make_unique<JobMocT>(
+ std::move(jobPre.SourceFile), FileName, std::move(jobPre.IncludeString));
if (jobPre.self) {
// Read dependencies from this source
static_cast<JobMocT&>(*jobHandle).FindDependencies(wrk, meta.Content);
@@ -451,8 +451,8 @@
bool success = true;
std::string const macroName = wrk.Moc().FindMacro(meta.Content);
if (!macroName.empty()) {
- JobHandleT jobHandle(
- new JobMocT(std::string(FileName), std::string(), std::string()));
+ JobHandleT jobHandle = cm::make_unique<JobMocT>(
+ std::string(FileName), std::string(), std::string());
// Read dependencies from this source
static_cast<JobMocT&>(*jobHandle).FindDependencies(wrk, meta.Content);
success = wrk.Gen().ParallelJobPushMoc(jobHandle);
@@ -518,8 +518,8 @@
std::string uiInputFile = UicFindIncludedFile(wrk, meta, includeString);
if (!uiInputFile.empty()) {
if (!wrk.Uic().skipped(uiInputFile)) {
- JobHandleT jobHandle(new JobUicT(std::move(uiInputFile), FileName,
- std::move(includeString)));
+ JobHandleT jobHandle = cm::make_unique<JobUicT>(
+ std::move(uiInputFile), FileName, std::move(includeString));
success = wrk.Gen().ParallelJobPushUic(jobHandle);
} else {
// A skipped file is successful
@@ -993,11 +993,6 @@
}
}
-void cmQtAutoGeneratorMocUic::JobDeleterT::operator()(JobT* job)
-{
- delete job;
-}
-
cmQtAutoGeneratorMocUic::WorkerT::WorkerT(cmQtAutoGeneratorMocUic* gen,
uv_loop_t* uvLoop)
: Gen_(gen)
@@ -1343,7 +1338,7 @@
Moc_.PredefsCmd = InfoGetList("AM_MOC_PREDEFS_CMD");
// Install moc predefs job
if (!Moc().PredefsCmd.empty()) {
- JobQueues_.MocPredefs.emplace_back(new JobMocPredefsT());
+ JobQueues_.MocPredefs.emplace_back(cm::make_unique<JobMocPredefsT>());
}
}
@@ -1390,7 +1385,7 @@
const bool uic = !Uic().skipped(hdr);
if ((moc || uic) && uniqueHeaders.emplace(stringHash(hdr)).second) {
JobQueues_.Headers.emplace_back(
- new JobParseT(std::move(hdr), moc, uic, true));
+ cm::make_unique<JobParseT>(std::move(hdr), moc, uic, true));
}
}
// Add source jobs
@@ -1417,15 +1412,15 @@
const bool uic = srcUic && !Uic().skipped(header);
if ((moc || uic) &&
uniqueHeaders.emplace(stringHash(header)).second) {
- JobQueues_.Headers.emplace_back(
- new JobParseT(std::move(header), moc, uic, true));
+ JobQueues_.Headers.emplace_back(cm::make_unique<JobParseT>(
+ std::move(header), moc, uic, true));
}
}
}
}
// Add source job
JobQueues_.Sources.emplace_back(
- new JobParseT(std::move(src), srcMoc, srcUic));
+ cm::make_unique<JobParseT>(std::move(src), srcMoc, srcUic));
}
}
}
@@ -1797,7 +1792,7 @@
{
bool const jobProcessed(jobHandle);
if (jobProcessed) {
- jobHandle.reset(nullptr);
+ jobHandle.reset();
}
{
std::unique_lock<std::mutex> jobsLock(JobsMutex_);
diff --git a/Source/cmQtAutoGeneratorMocUic.h b/Source/cmQtAutoGeneratorMocUic.h
index 989d9ab..e48d7f3 100644
--- a/Source/cmQtAutoGeneratorMocUic.h
+++ b/Source/cmQtAutoGeneratorMocUic.h
@@ -187,15 +187,8 @@
virtual void Process(WorkerT& wrk) = 0;
};
- /// @brief Deleter for classes derived from Job
- ///
- struct JobDeleterT
- {
- void operator()(JobT* job);
- };
-
// Job management types
- typedef std::unique_ptr<JobT, JobDeleterT> JobHandleT;
+ typedef std::unique_ptr<JobT> JobHandleT;
typedef std::deque<JobHandleT> JobQueueT;
/// @brief Parse source job