summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2009-06-15 17:51:07 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2009-06-15 17:51:07 (GMT)
commit15ad6db1702ffb4d89d97344abdce20e052affd3 (patch)
tree86b1a4fb732b1ce9ef03c19faad3fee0eea008b4
parentdbc4e2f101e87336fb3eaed16232a7dea1e9bd2c (diff)
downloadCMake-15ad6db1702ffb4d89d97344abdce20e052affd3.zip
CMake-15ad6db1702ffb4d89d97344abdce20e052affd3.tar.gz
CMake-15ad6db1702ffb4d89d97344abdce20e052affd3.tar.bz2
BUG: fix crash when running ctest coverage for VTK
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.cxx12
1 files changed, 12 insertions, 0 deletions
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index a35aacf..80d6984 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -159,6 +159,14 @@ void CMakeStdoutCallback(const char* m, int len, void* s)
std::string* out = (std::string*)s;
out->append(m, len);
}
+struct cmSetupOutputCaptureCleanup
+{
+ ~cmSetupOutputCaptureCleanup()
+ {
+ cmSystemTools::SetErrorCallback(0, 0);
+ cmSystemTools::SetStdoutCallback(0, 0);
+ }
+};
//----------------------------------------------------------------------
int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
@@ -167,6 +175,10 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
std::string cmakeOutString;
cmSystemTools::SetErrorCallback(CMakeMessageCallback, &cmakeOutString);
cmSystemTools::SetStdoutCallback(CMakeStdoutCallback, &cmakeOutString);
+ // make sure SetStdoutCallback and SetErrorCallback are set to null
+ // after this function exits so that they do not point at a destroyed
+ // string cmakeOutString
+ cmSetupOutputCaptureCleanup cleanup;
cmOStringStream out;
// if the generator and make program are not specified then it is an error