diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2001-10-29 15:19:34 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2001-10-29 15:19:34 (GMT) |
commit | 539318f5875de0c0d0e008f820a3bd721d322f09 (patch) | |
tree | edb941b33c894e7571f47d857e84a54f48b671d9 | |
parent | 88c32dacc7a193a0a05b5c85daa973a56d580d67 (diff) | |
download | CMake-539318f5875de0c0d0e008f820a3bd721d322f09.zip CMake-539318f5875de0c0d0e008f820a3bd721d322f09.tar.gz CMake-539318f5875de0c0d0e008f820a3bd721d322f09.tar.bz2 |
ENH: add callback for message display
-rw-r--r-- | Source/FLTKDialog/CMakeSetupGUIImplementation.cxx | 12 | ||||
-rw-r--r-- | Source/cmCacheManager.cxx | 9 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 15 | ||||
-rw-r--r-- | Source/cmSystemTools.h | 12 |
4 files changed, 44 insertions, 4 deletions
diff --git a/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx b/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx index 1961a36..dd02b56 100644 --- a/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx +++ b/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx @@ -12,7 +12,15 @@ #include "../cmake.h" #include "../cmMakefileGenerator.h" - +void FLTKMessageCallback(const char* message, const char* title, bool& nomore) +{ + int ok = + fl_ask(message, "Press cancel to suppress any further messages."); + if(!ok) + { + nomore = true; + } +} /** * Constructor @@ -20,6 +28,7 @@ CMakeSetupGUIImplementation ::CMakeSetupGUIImplementation():m_CacheEntriesList( this ) { + cmSystemTools::SetErrorCallback(FLTKMessageCallback); m_BuildPathChanged = false; } @@ -359,6 +368,7 @@ CMakeSetupGUIImplementation arg += m_WhereBuild; args.push_back(arg); arg = "-G"; + m_GeneratorChoiceString = "Unix Makefiles"; arg += m_GeneratorChoiceString; args.push_back(arg); // run the generate process diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index b07ab5f..c0919fb 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -438,7 +438,14 @@ void cmCacheManager::OutputHelpString(std::ofstream& fout, void cmCacheManager::RemoveCacheEntry(const char* key) { - m_Cache.erase(key); + if(m_Cache.count(key)) + { + m_Cache.erase(key); + } + else + { + std::cerr << "Failed to remove entry" << std::endl; + } } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 44474a5..577c8f0 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -93,6 +93,8 @@ inline int Chdir(const char* dir) bool cmSystemTools::s_ErrorOccured = false; +void (*cmSystemTools::s_ErrorCallback)(const char*, const char*, bool&); + // adds the elements of the env variable path to the arg passed in void cmSystemTools::GetPath(std::vector<std::string>& path) { @@ -689,14 +691,25 @@ void cmSystemTools::Error(const char* m1, const char* m2, cmSystemTools::Message(message.c_str(),"Error"); } + +void cmSystemTools::SetErrorCallback(ErrorCallback f) +{ + s_ErrorCallback = f; +} + void cmSystemTools::Message(const char* m1, const char *title) { -#if defined(_WIN32) && !defined(__CYGWIN__) static bool disableMessages = false; if(disableMessages) { return; } + if(s_ErrorCallback) + { + (*s_ErrorCallback)(m1, title, disableMessages); + return; + } +#if defined(_WIN32) && !defined(__CYGWIN__) std::string message = m1; message += "\n\n(Press Cancel to suppress any further messages.)"; if(::MessageBox(0, message.c_str(), title, diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 2f03f47..fa6782c 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -156,7 +156,16 @@ public: * on the current platform ("" for unix, ".exe" for Windows). */ static const char* GetExecutableExtension(); - + + typedef void (*ErrorCallback)(const char*, const char*, bool&); + /** + * Set the function used by GUI's to display error messages + * Function gets passed: message as a const char*, + * title as a const char*, and a reference to bool that when + * set to false, will disable furthur messages (cancel). + */ + static void SetErrorCallback(ErrorCallback f); + /** * Display an error message. */ @@ -273,6 +282,7 @@ public: private: static bool s_ErrorOccured; + static ErrorCallback s_ErrorCallback; }; |