mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-25 16:43:33 +00:00
Fix crash on destructed stream usage
This commit is contained in:
parent
e744090339
commit
29f262e514
@ -97,9 +97,13 @@ int wrapApplication(int (*innerApplication)(int argc, char *argv[]), int argc, c
|
|||||||
std::streambuf* cout_rdbuf = std::cout.rdbuf ();
|
std::streambuf* cout_rdbuf = std::cout.rdbuf ();
|
||||||
std::streambuf* cerr_rdbuf = std::cerr.rdbuf ();
|
std::streambuf* cerr_rdbuf = std::cerr.rdbuf ();
|
||||||
|
|
||||||
#if !(defined(_WIN32) && defined(_DEBUG))
|
#if defined(_WIN32) && defined(_DEBUG)
|
||||||
|
boost::iostreams::stream_buffer<Debug::DebugOutput> sb;
|
||||||
|
#else
|
||||||
boost::iostreams::stream_buffer<Debug::Tee> coutsb;
|
boost::iostreams::stream_buffer<Debug::Tee> coutsb;
|
||||||
boost::iostreams::stream_buffer<Debug::Tee> cerrsb;
|
boost::iostreams::stream_buffer<Debug::Tee> cerrsb;
|
||||||
|
std::ostream oldcout(cout_rdbuf);
|
||||||
|
std::ostream oldcerr(cerr_rdbuf);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const std::string logName = Misc::StringUtils::lowerCase(appName) + ".log";
|
const std::string logName = Misc::StringUtils::lowerCase(appName) + ".log";
|
||||||
@ -113,7 +117,6 @@ int wrapApplication(int (*innerApplication)(int argc, char *argv[]), int argc, c
|
|||||||
|
|
||||||
#if defined(_WIN32) && defined(_DEBUG)
|
#if defined(_WIN32) && defined(_DEBUG)
|
||||||
// Redirect cout and cerr to VS debug output when running in debug mode
|
// Redirect cout and cerr to VS debug output when running in debug mode
|
||||||
boost::iostreams::stream_buffer<Debug::DebugOutput> sb;
|
|
||||||
sb.open(Debug::DebugOutput());
|
sb.open(Debug::DebugOutput());
|
||||||
std::cout.rdbuf (&sb);
|
std::cout.rdbuf (&sb);
|
||||||
std::cerr.rdbuf (&sb);
|
std::cerr.rdbuf (&sb);
|
||||||
@ -121,8 +124,6 @@ int wrapApplication(int (*innerApplication)(int argc, char *argv[]), int argc, c
|
|||||||
// Redirect cout and cerr to the log file
|
// Redirect cout and cerr to the log file
|
||||||
logfile.open (boost::filesystem::path(cfgMgr.getLogPath() / logName));
|
logfile.open (boost::filesystem::path(cfgMgr.getLogPath() / logName));
|
||||||
|
|
||||||
std::ostream oldcout(cout_rdbuf);
|
|
||||||
std::ostream oldcerr(cerr_rdbuf);
|
|
||||||
coutsb.open (Debug::Tee(logfile, oldcout));
|
coutsb.open (Debug::Tee(logfile, oldcout));
|
||||||
cerrsb.open (Debug::Tee(logfile, oldcerr));
|
cerrsb.open (Debug::Tee(logfile, oldcerr));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user