ENH: add callback for message display
This commit is contained in:
parent
88c32dacc7
commit
539318f587
|
@ -12,7 +12,15 @@
|
||||||
#include "../cmake.h"
|
#include "../cmake.h"
|
||||||
#include "../cmMakefileGenerator.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
|
* Constructor
|
||||||
|
@ -20,6 +28,7 @@
|
||||||
CMakeSetupGUIImplementation
|
CMakeSetupGUIImplementation
|
||||||
::CMakeSetupGUIImplementation():m_CacheEntriesList( this )
|
::CMakeSetupGUIImplementation():m_CacheEntriesList( this )
|
||||||
{
|
{
|
||||||
|
cmSystemTools::SetErrorCallback(FLTKMessageCallback);
|
||||||
m_BuildPathChanged = false;
|
m_BuildPathChanged = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -359,6 +368,7 @@ CMakeSetupGUIImplementation
|
||||||
arg += m_WhereBuild;
|
arg += m_WhereBuild;
|
||||||
args.push_back(arg);
|
args.push_back(arg);
|
||||||
arg = "-G";
|
arg = "-G";
|
||||||
|
m_GeneratorChoiceString = "Unix Makefiles";
|
||||||
arg += m_GeneratorChoiceString;
|
arg += m_GeneratorChoiceString;
|
||||||
args.push_back(arg);
|
args.push_back(arg);
|
||||||
// run the generate process
|
// run the generate process
|
||||||
|
|
|
@ -438,7 +438,14 @@ void cmCacheManager::OutputHelpString(std::ofstream& fout,
|
||||||
|
|
||||||
void cmCacheManager::RemoveCacheEntry(const char* key)
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -93,6 +93,8 @@ inline int Chdir(const char* dir)
|
||||||
|
|
||||||
bool cmSystemTools::s_ErrorOccured = false;
|
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
|
// adds the elements of the env variable path to the arg passed in
|
||||||
void cmSystemTools::GetPath(std::vector<std::string>& path)
|
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");
|
cmSystemTools::Message(message.c_str(),"Error");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void cmSystemTools::SetErrorCallback(ErrorCallback f)
|
||||||
|
{
|
||||||
|
s_ErrorCallback = f;
|
||||||
|
}
|
||||||
|
|
||||||
void cmSystemTools::Message(const char* m1, const char *title)
|
void cmSystemTools::Message(const char* m1, const char *title)
|
||||||
{
|
{
|
||||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
|
||||||
static bool disableMessages = false;
|
static bool disableMessages = false;
|
||||||
if(disableMessages)
|
if(disableMessages)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(s_ErrorCallback)
|
||||||
|
{
|
||||||
|
(*s_ErrorCallback)(m1, title, disableMessages);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||||
std::string message = m1;
|
std::string message = m1;
|
||||||
message += "\n\n(Press Cancel to suppress any further messages.)";
|
message += "\n\n(Press Cancel to suppress any further messages.)";
|
||||||
if(::MessageBox(0, message.c_str(), title,
|
if(::MessageBox(0, message.c_str(), title,
|
||||||
|
|
|
@ -156,7 +156,16 @@ public:
|
||||||
* on the current platform ("" for unix, ".exe" for Windows).
|
* on the current platform ("" for unix, ".exe" for Windows).
|
||||||
*/
|
*/
|
||||||
static const char* GetExecutableExtension();
|
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.
|
* Display an error message.
|
||||||
*/
|
*/
|
||||||
|
@ -273,6 +282,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool s_ErrorOccured;
|
static bool s_ErrorOccured;
|
||||||
|
static ErrorCallback s_ErrorCallback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue