From 58f41c789ffd102cdf3c9c8e49a2fe3b5da21a0b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 20 May 2015 00:22:51 +0200 Subject: [PATCH 1/5] QtAutogen: Remove repeated setters. These methods are called already just before calling the static method. --- Source/cmQtAutoGenerators.cxx | 3 --- 1 file changed, 3 deletions(-) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 3e7989f08..79e7f7057 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1209,9 +1209,6 @@ static cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, cmGlobalGenerator* gg = new cmGlobalGenerator(); gg->SetCMakeInstance(cm); - cm->SetHomeOutputDirectory(targetDirectory); - cm->SetHomeDirectory(targetDirectory); - cmLocalGenerator* lg = gg->MakeLocalGenerator(); lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); From 460e8fb9ad4eb58e06cefa0fce0df6f14644af4e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 20 May 2015 00:17:30 +0200 Subject: [PATCH 2/5] QtAutogen: Inline static factory method. --- Source/cmQtAutoGenerators.cxx | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 79e7f7057..853a7069e 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1203,20 +1203,6 @@ std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) return std::string(); } -static cmGlobalGenerator* CreateGlobalGenerator(cmake* cm, - const std::string& targetDirectory) -{ - cmGlobalGenerator* gg = new cmGlobalGenerator(); - gg->SetCMakeInstance(cm); - - cmLocalGenerator* lg = gg->MakeLocalGenerator(); - lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); - lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); - gg->SetCurrentLocalGenerator(lg); - - return gg; -} - bool cmQtAutoGenerators::Run(const std::string& targetDirectory, const std::string& config) { @@ -1224,7 +1210,14 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, cmake cm; cm.SetHomeOutputDirectory(targetDirectory); cm.SetHomeDirectory(targetDirectory); - cmGlobalGenerator* gg = CreateGlobalGenerator(&cm, targetDirectory); + cmGlobalGenerator* gg = new cmGlobalGenerator(); + gg->SetCMakeInstance(&cm); + + cmLocalGenerator* lg = gg->MakeLocalGenerator(); + lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); + lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); + gg->SetCurrentLocalGenerator(lg); + cmMakefile* makefile = gg->GetCurrentLocalGenerator()->GetMakefile(); this->ReadAutogenInfoFile(makefile, targetDirectory, config); From c95a55ad5ab99a817c79558a5a7d8aaeb34a131b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 20 May 2015 00:18:19 +0200 Subject: [PATCH 3/5] QtAutogen: Remove the need for a local makefile variable. --- Source/cmQtAutoGenerators.cxx | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 853a7069e..68f8d098d 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1218,16 +1218,14 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); gg->SetCurrentLocalGenerator(lg); - cmMakefile* makefile = gg->GetCurrentLocalGenerator()->GetMakefile(); - - this->ReadAutogenInfoFile(makefile, targetDirectory, config); - this->ReadOldMocDefinitionsFile(makefile, targetDirectory); + this->ReadAutogenInfoFile(lg->GetMakefile(), targetDirectory, config); + this->ReadOldMocDefinitionsFile(lg->GetMakefile(), targetDirectory); this->Init(); if (this->QtMajorVersion == "4" || this->QtMajorVersion == "5") { - success = this->RunAutogen(makefile); + success = this->RunAutogen(lg->GetMakefile()); } this->WriteOldMocDefinitionsFile(targetDirectory); @@ -1235,7 +1233,6 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, delete gg->GetCurrentLocalGenerator(); delete gg; gg = NULL; - makefile = NULL; return success; } From fe401ede2a6d8eb845005d26487c96f42d8425fc Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 20 May 2015 00:20:21 +0200 Subject: [PATCH 4/5] QtAutogen: Use a more-obvious delete-target. --- Source/cmQtAutoGenerators.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 68f8d098d..7d389c0b7 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1230,7 +1230,7 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, this->WriteOldMocDefinitionsFile(targetDirectory); - delete gg->GetCurrentLocalGenerator(); + delete lg; delete gg; gg = NULL; return success; From a5b59fae15767be07fcc0c3750b706d3ed50f1f5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 20 May 2015 00:21:20 +0200 Subject: [PATCH 5/5] QtAutogen: Create global generator on the stack. --- Source/cmQtAutoGenerators.cxx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 7d389c0b7..d963f99da 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -1210,13 +1210,13 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, cmake cm; cm.SetHomeOutputDirectory(targetDirectory); cm.SetHomeDirectory(targetDirectory); - cmGlobalGenerator* gg = new cmGlobalGenerator(); - gg->SetCMakeInstance(&cm); + cmGlobalGenerator gg; + gg.SetCMakeInstance(&cm); - cmLocalGenerator* lg = gg->MakeLocalGenerator(); + cmLocalGenerator* lg = gg.MakeLocalGenerator(); lg->GetMakefile()->SetCurrentBinaryDirectory(targetDirectory); lg->GetMakefile()->SetCurrentSourceDirectory(targetDirectory); - gg->SetCurrentLocalGenerator(lg); + gg.SetCurrentLocalGenerator(lg); this->ReadAutogenInfoFile(lg->GetMakefile(), targetDirectory, config); this->ReadOldMocDefinitionsFile(lg->GetMakefile(), targetDirectory); @@ -1231,8 +1231,6 @@ bool cmQtAutoGenerators::Run(const std::string& targetDirectory, this->WriteOldMocDefinitionsFile(targetDirectory); delete lg; - delete gg; - gg = NULL; return success; }