summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Cedilnik <andy.cedilnik@kitware.com>2002-09-18 14:18:43 -0400
committerAndy Cedilnik <andy.cedilnik@kitware.com>2002-09-18 14:18:43 -0400
commit6769e8447291ab73cbf904a9470e4a7094c34e4d (patch)
tree0139f69c88217afb66567f20495b272f0562d1df
parenteab24670e3e2a8b2a7469ba418e183c363ff27d1 (diff)
downloadcmake-6769e8447291ab73cbf904a9470e4a7094c34e4d.tar.gz
Improve message handler to include client data.
-rw-r--r--Source/CursesDialog/ccmake.cxx7
-rw-r--r--Source/cmSystemTools.cxx8
-rw-r--r--Source/cmSystemTools.h5
3 files changed, 12 insertions, 8 deletions
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index b852ca7e4f..289ff757c3 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -52,9 +52,10 @@ void onsig(int)
}
-void CMakeErrorHandler(const char* message, const char* title, bool&)
+void CMakeErrorHandler(const char* message, const char* title, bool&, void* clientData)
{
- cmCursesForm::CurrentForm->AddError(message, title);
+ cmCursesForm* self = static_cast<cmCursesForm*>( clientData );
+ self->AddError(message, title);
}
int main(int argc, char** argv)
@@ -128,7 +129,7 @@ int main(int argc, char** argv)
myform = new cmCursesMainForm(args, x);
myform->LoadCache(cacheDir.c_str());
- cmSystemTools::SetErrorCallback(CMakeErrorHandler);
+ cmSystemTools::SetErrorCallback(CMakeErrorHandler, myform);
cmCursesForm::CurrentForm = myform;
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 6139292b44..1ffd4f7a07 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -74,7 +74,8 @@ bool cmSystemTools::s_DisableRunCommandOutput = false;
bool cmSystemTools::s_ErrorOccured = false;
bool cmSystemTools::s_DisableMessages = false;
-void (*cmSystemTools::s_ErrorCallback)(const char*, const char*, bool&);
+void (*cmSystemTools::s_ErrorCallback)(const char*, const char*, bool&, void*);
+void* cmSystemTools::s_ErrorCallbackClientData = 0;
// adds the elements of the env variable path to the arg passed in
void cmSystemTools::GetPath(std::vector<std::string>& path)
@@ -984,9 +985,10 @@ void cmSystemTools::Error(const char* m1, const char* m2,
}
-void cmSystemTools::SetErrorCallback(ErrorCallback f)
+void cmSystemTools::SetErrorCallback(ErrorCallback f, void* clientData)
{
s_ErrorCallback = f;
+ s_ErrorCallbackClientData = clientData;
}
void cmSystemTools::Message(const char* m1, const char *title)
@@ -997,7 +999,7 @@ void cmSystemTools::Message(const char* m1, const char *title)
}
if(s_ErrorCallback)
{
- (*s_ErrorCallback)(m1, title, s_DisableMessages);
+ (*s_ErrorCallback)(m1, title, s_DisableMessages, s_ErrorCallbackClientData);
return;
}
else
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 229232f4d4..7ec22d2bc5 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -149,14 +149,14 @@ public:
*/
static const char* GetExecutableExtension();
- typedef void (*ErrorCallback)(const char*, const char*, bool&);
+ typedef void (*ErrorCallback)(const char*, const char*, bool&, void*);
/**
* 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);
+ static void SetErrorCallback(ErrorCallback f, void* clientData=0);
/**
* Display an error message.
@@ -308,6 +308,7 @@ private:
static bool s_DisableMessages;
static bool s_DisableRunCommandOutput;
static ErrorCallback s_ErrorCallback;
+ static void* s_ErrorCallbackClientData;
};