CPackWIX: Delay creation of cmWIXPatch until CPack has initialized Logger

Without the fix CPack will crash when the cmWIXPatch class tries to issue
any diagnostics.
This commit is contained in:
Nils Gladitz 2014-04-18 22:45:30 +02:00
parent 3970b5de0f
commit cb59f5da97
2 changed files with 16 additions and 6 deletions

View File

@ -33,14 +33,23 @@
cmCPackWIXGenerator::cmCPackWIXGenerator(): cmCPackWIXGenerator::cmCPackWIXGenerator():
HasDesktopShortcuts(false), HasDesktopShortcuts(false),
Patch(Logger) Patch(0)
{ {
} }
cmCPackWIXGenerator::~cmCPackWIXGenerator()
{
if(this->Patch)
{
delete this->Patch;
}
}
int cmCPackWIXGenerator::InitializeInternal() int cmCPackWIXGenerator::InitializeInternal()
{ {
componentPackageMethod = ONE_PACKAGE; componentPackageMethod = ONE_PACKAGE;
this->Patch = new cmWIXPatch(this->Logger);
return this->Superclass::InitializeInternal(); return this->Superclass::InitializeInternal();
} }
@ -232,7 +241,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE"); const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE");
if(patchFilePath) if(patchFilePath)
{ {
this->Patch.LoadFragments(patchFilePath); this->Patch->LoadFragments(patchFilePath);
} }
return true; return true;
@ -525,7 +534,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
return false; return false;
} }
return this->Patch.CheckForUnappliedFragments(); return this->Patch->CheckForUnappliedFragments();
} }
std::string cmCPackWIXGenerator::GetProgramFilesFolderId() const std::string cmCPackWIXGenerator::GetProgramFilesFolderId() const
@ -857,13 +866,13 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
desktopExecutables, desktopExecutables,
shortcutMap); shortcutMap);
this->Patch.ApplyFragment(subDirectoryId, directoryDefinitions); this->Patch->ApplyFragment(subDirectoryId, directoryDefinitions);
directoryDefinitions.EndElement("Directory"); directoryDefinitions.EndElement("Directory");
} }
else else
{ {
std::string componentId = fileDefinitions.EmitComponentFile( std::string componentId = fileDefinitions.EmitComponentFile(
directoryId, id, fullPath, this->Patch); directoryId, id, fullPath, *(this->Patch));
featureDefinitions.EmitComponentRef(componentId); featureDefinitions.EmitComponentRef(componentId);

View File

@ -35,6 +35,7 @@ public:
cmCPackTypeMacro(cmCPackWIXGenerator, cmCPackGenerator); cmCPackTypeMacro(cmCPackWIXGenerator, cmCPackGenerator);
cmCPackWIXGenerator(); cmCPackWIXGenerator();
~cmCPackWIXGenerator();
protected: protected:
virtual int InitializeInternal(); virtual int InitializeInternal();
@ -166,7 +167,7 @@ private:
std::string CPackTopLevel; std::string CPackTopLevel;
cmWIXPatch Patch; cmWIXPatch* Patch;
}; };
#endif #endif