BUG: add explicit clean up of the cachemanager at exit of programs, so dll destruction is not a problem.

This commit is contained in:
Bill Hoffman 2002-08-23 13:46:32 -04:00
parent 40cf734152
commit 3f36d23421
10 changed files with 27 additions and 18 deletions

View File

@ -53,7 +53,8 @@ INCLUDE_DIRECTORIES(${CMake_SOURCE_DIR}/Source)
ADD_DEFINITIONS(-DCMAKE_BUILD_WITH_CMAKE)
IF (WIN32)
SET(SRCS ${SRCS}
IF(NOT UNIX)
SET(SRCS ${SRCS}
cmDSWWriter.cxx
cmDSPWriter.cxx
cmMSProjectGenerator.cxx
@ -67,7 +68,6 @@ IF (WIN32)
cmNMakeMakefileGenerator.h
cmMSDotNETGenerator.h
)
IF(NOT UNIX)
IF( NOT BORLAND )
LINK_LIBRARIES( rpcrt4.lib )
SUBDIRS(MFCDialog)

View File

@ -24,9 +24,5 @@ INCLUDE_DIRECTORIES(${CURSES_INCLUDE_PATH})
ADD_EXECUTABLE(ccmake ${CURSES_SRCS} )
TARGET_LINK_LIBRARIES(ccmake CMakeLib)
TARGET_LINK_LIBRARIES(ccmake cmForm)
TARGET_LINK_LIBRARIES(ccmake ${CURSES_LIBRARY})
IF(CURSES_EXTRA_LIBRARY)
TARGET_LINK_LIBRARIES(ccmake ${CURSES_EXTRA_LIBRARY})
ENDIF(CURSES_EXTRA_LIBRARY)
INSTALL_TARGETS(/bin ccmake)

View File

@ -45,4 +45,8 @@ SET( FORM_SRCS
)
INCLUDE_DIRECTORIES(${CMAKE_FORM_SOURCE_DIR})
ADD_LIBRARY(cmForm ${FORM_SRCS} )
ADD_LIBRARY(cmForm ${FORM_SRCS} )
TARGET_LINK_LIBRARIES(cmForm ${CURSES_LIBRARY})
IF(CURSES_EXTRA_LIBRARY)
TARGET_LINK_LIBRARIES(cmForm ${CURSES_EXTRA_LIBRARY})
ENDIF(CURSES_EXTRA_LIBRARY)

View File

@ -7,6 +7,7 @@
#include "CMakeCommandLineInfo.h"
#include "../cmListFileCache.h"
#include "../cmMakefileGenerator.h"
#include "../cmCacheManager.h"
#ifdef _DEBUG
#define new DEBUG_NEW
@ -78,6 +79,7 @@ BOOL CMakeSetup::InitInstance()
// clean up globals
cmListFileCache::GetInstance()->ClearCache();
cmMakefileGenerator::UnRegisterGenerators();
cmCacheManager::DeleteInstance();
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;

View File

@ -50,17 +50,13 @@ cmCacheManager::CacheEntryType cmCacheManager::StringToType(const char* s)
return STRING;
}
struct CleanUpCacheManager
void cmCacheManager::DeleteInstance()
{
~CleanUpCacheManager()
{
delete cmCacheManager::GetInstance();
}
void Use() {}
};
delete cmCacheManager::GetInstance();
cmCacheManager::s_Instance = 0;
}
CleanUpCacheManager cleanup;
cmCacheManager* cmCacheManager::s_Instance = 0;
@ -68,7 +64,6 @@ cmCacheManager* cmCacheManager::GetInstance()
{
if(!cmCacheManager::s_Instance)
{
cleanup.Use();
cmCacheManager::s_Instance = new cmCacheManager;
}
return cmCacheManager::s_Instance;

View File

@ -71,6 +71,7 @@ public:
static CacheEntryType StringToType(const char*);
///! Singleton pattern get instance of the cmCacheManager.
CM_EXPORT static cmCacheManager* GetInstance();
CM_EXPORT static void DeleteInstance();
///! Load a cache for given makefile. Loads from ouput home.
CM_EXPORT bool LoadCache(cmMakefile*);

View File

@ -41,6 +41,11 @@ cmake::cmake()
#endif
}
cmake::~cmake()
{
}
void cmake::Usage(const char* program)
{
cmStringStream errorStream;

View File

@ -61,7 +61,7 @@ class CM_EXPORT cmake
* constructor
*/
cmake();
~cmake();
private:
bool m_Verbose;
bool m_Local;

View File

@ -17,6 +17,7 @@
#include "cmakewizard.h"
#include "cmake.h"
#include "cmMakefileGenerator.h"
#include "cmCacheManager.h"
int main(int ac, char** av)
{
@ -52,10 +53,12 @@ int main(int ac, char** av)
cmakewizard wizard;
wizard.RunWizard(args);
cmMakefileGenerator::UnRegisterGenerators();
cmCacheManager::DeleteInstance();
return 0;
}
cmake cm;
int ret = cm.Generate(args);
cmMakefileGenerator::UnRegisterGenerators();
cmCacheManager::DeleteInstance();
return ret;
}

View File

@ -20,6 +20,7 @@
#include "cmake.h"
#include "cmListFileCache.h"
#include "cmMakefileGenerator.h"
#include "cmCacheManager.h"
#if defined(_WIN32) && !defined(__CYGWIN__)
#include "windows.h"
#endif
@ -31,6 +32,8 @@ struct CleanUp
~CleanUp()
{
cmMakefileGenerator::UnRegisterGenerators();
cmCacheManager::DeleteInstance();
}
void UseIt()
{