From 3f36d234213fd9e23a9402eabb2198e79c6ebe61 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Fri, 23 Aug 2002 13:46:32 -0400 Subject: [PATCH] BUG: add explicit clean up of the cachemanager at exit of programs, so dll destruction is not a problem. --- Source/CMakeLists.txt | 4 ++-- Source/CursesDialog/CMakeLists.txt | 4 ---- Source/CursesDialog/form/CMakeLists.txt | 6 +++++- Source/MFCDialog/CMakeSetup.cpp | 2 ++ Source/cmCacheManager.cxx | 15 +++++---------- Source/cmCacheManager.h | 1 + Source/cmake.cxx | 5 +++++ Source/cmake.h | 2 +- Source/cmakemain.cxx | 3 +++ Source/cmaketest.cxx | 3 +++ 10 files changed, 27 insertions(+), 18 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index a13868026..7abec3990 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -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) diff --git a/Source/CursesDialog/CMakeLists.txt b/Source/CursesDialog/CMakeLists.txt index 60e290969..bf86e1f63 100644 --- a/Source/CursesDialog/CMakeLists.txt +++ b/Source/CursesDialog/CMakeLists.txt @@ -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) \ No newline at end of file diff --git a/Source/CursesDialog/form/CMakeLists.txt b/Source/CursesDialog/form/CMakeLists.txt index b197eb63a..618aef2f1 100644 --- a/Source/CursesDialog/form/CMakeLists.txt +++ b/Source/CursesDialog/form/CMakeLists.txt @@ -45,4 +45,8 @@ SET( FORM_SRCS ) INCLUDE_DIRECTORIES(${CMAKE_FORM_SOURCE_DIR}) -ADD_LIBRARY(cmForm ${FORM_SRCS} ) \ No newline at end of file +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) diff --git a/Source/MFCDialog/CMakeSetup.cpp b/Source/MFCDialog/CMakeSetup.cpp index 260dd57c5..707b9c6e6 100644 --- a/Source/MFCDialog/CMakeSetup.cpp +++ b/Source/MFCDialog/CMakeSetup.cpp @@ -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; diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 81b5337ab..f15b4dbbd 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -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; diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index f855f2d42..3510624db 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -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*); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 68efa4616..72d44655f 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -41,6 +41,11 @@ cmake::cmake() #endif } +cmake::~cmake() +{ +} + + void cmake::Usage(const char* program) { cmStringStream errorStream; diff --git a/Source/cmake.h b/Source/cmake.h index cc832dfb2..3ccbea2b5 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -61,7 +61,7 @@ class CM_EXPORT cmake * constructor */ cmake(); - + ~cmake(); private: bool m_Verbose; bool m_Local; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index e08e19f59..696624c4c 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -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; } diff --git a/Source/cmaketest.cxx b/Source/cmaketest.cxx index 69eba7481..3ba3fadb6 100644 --- a/Source/cmaketest.cxx +++ b/Source/cmaketest.cxx @@ -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() {