ENH: Remove memory leak and remember global generator for next time

This commit is contained in:
Andy Cedilnik 2005-05-08 13:48:09 -04:00
parent 4e49c3bf6e
commit 0842958977
2 changed files with 41 additions and 7 deletions

View File

@ -21,6 +21,24 @@
#include "cmake.h" #include "cmake.h"
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
//----------------------------------------------------------------------------
cmCTestBuildCommand::cmCTestBuildCommand()
{
m_GlobalGenerator = 0;
}
//----------------------------------------------------------------------------
cmCTestBuildCommand::~cmCTestBuildCommand()
{
if ( m_GlobalGenerator )
{
delete m_GlobalGenerator;
m_GlobalGenerator = 0;
}
}
//----------------------------------------------------------------------------
bool cmCTestBuildCommand::InitialPass( bool cmCTestBuildCommand::InitialPass(
std::vector<std::string> const& args) std::vector<std::string> const& args)
{ {
@ -97,13 +115,24 @@ bool cmCTestBuildCommand::InitialPass(
{ {
cmakeBuildConfiguration = "Release"; cmakeBuildConfiguration = "Release";
} }
cmGlobalGenerator* gen = if ( m_GlobalGenerator )
{
if ( strcmp(m_GlobalGenerator->GetName(), cmakeGeneratorName) != 0 )
{
delete m_GlobalGenerator;
m_GlobalGenerator = 0;
}
}
if ( !m_GlobalGenerator )
{
m_GlobalGenerator =
m_Makefile->GetCMakeInstance()->CreateGlobalGenerator(cmakeGeneratorName); m_Makefile->GetCMakeInstance()->CreateGlobalGenerator(cmakeGeneratorName);
gen->FindMakeProgram(m_Makefile); }
m_GlobalGenerator->FindMakeProgram(m_Makefile);
const char* cmakeMakeProgram = m_Makefile->GetDefinition("CMAKE_MAKE_PROGRAM"); const char* cmakeMakeProgram = m_Makefile->GetDefinition("CMAKE_MAKE_PROGRAM");
std::string buildCommand = gen->GenerateBuildCommand(cmakeMakeProgram, cmakeProjectName, std::string buildCommand
= m_GlobalGenerator->GenerateBuildCommand(cmakeMakeProgram, cmakeProjectName,
0, cmakeBuildConfiguration, true); 0, cmakeBuildConfiguration, true);
m_CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str()); m_CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str());
} }
else else

View File

@ -19,6 +19,8 @@
#include "cmCTestCommand.h" #include "cmCTestCommand.h"
class cmGlobalGenerator;
/** \class cmCTestBuild /** \class cmCTestBuild
* \brief Run a ctest script * \brief Run a ctest script
* *
@ -28,7 +30,8 @@ class cmCTestBuildCommand : public cmCTestCommand
{ {
public: public:
cmCTestBuildCommand() {} cmCTestBuildCommand();
~cmCTestBuildCommand();
/** /**
* This is a virtual constructor for the command. * This is a virtual constructor for the command.
@ -71,6 +74,8 @@ public:
} }
cmTypeMacro(cmCTestBuildCommand, cmCTestCommand); cmTypeMacro(cmCTestBuildCommand, cmCTestCommand);
cmGlobalGenerator* m_GlobalGenerator;
}; };