diff --git a/source/global/management/include/G4strstreambuf.icc b/source/global/management/include/G4strstreambuf.icc index e8ff09e63485867a8d3ff908d4f233f51abe395b..2bbf2951f5d278225884fd511ff9bcdc56138096 100644 --- a/source/global/management/include/G4strstreambuf.icc +++ b/source/global/management/include/G4strstreambuf.icc @@ -44,10 +44,6 @@ inline G4strstreambuf::G4strstreambuf() inline G4strstreambuf::~G4strstreambuf() //////////////////////////////////////// { - // flushing buffer... - // std::cout is used because destination object may not be alive. - if(count !=0) std::cout << buffer; - delete [] buffer; } diff --git a/source/global/management/src/G4ios.cc b/source/global/management/src/G4ios.cc index 7d40723c6e2835e93ae676a833df23456fd7010c..073c9559f7c9a4454d4e25e420abfc3da83c9ee7 100644 --- a/source/global/management/src/G4ios.cc +++ b/source/global/management/src/G4ios.cc @@ -78,6 +78,8 @@ void G4iosInitialization() void G4iosFinalization() { + _G4cout_p()->flush(); + _G4cerr_p()->flush(); delete _G4cout_p(); _G4cout_p() = &std::cout; delete _G4cerr_p(); _G4cerr_p() = &std::cerr; delete _G4coutbuf_p(); _G4coutbuf_p() = nullptr; @@ -104,6 +106,9 @@ std::ostream G4cout(&G4coutbuf); std::ostream G4cerr(&G4cerrbuf); void G4iosInitialization() {} -void G4iosFinalization() {} +void G4iosFinalization() { + G4cout.flush(); + G4cerr.flush(); +} #endif