]> git.sesse.net Git - casparcg/commitdiff
Fixed CRT debugging.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Tue, 13 Dec 2011 12:42:27 +0000 (12:42 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Tue, 13 Dec 2011 12:42:27 +0000 (12:42 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/trunk@1892 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

shell/main.cpp

index 89dec91afff97fd0855602951aac078c775586a7..f746d988a75614fc536319226f7ae439e75ba4e3 100644 (file)
 // tbbmalloc_proxy: \r
 // Replace the standard memory allocation routines in Microsoft* C/C++ RTL \r
 // (malloc/free, global new/delete, etc.) with the TBB memory allocator. \r
-#include <tbb/tbbmalloc_proxy.h>\r
-\r
-#include "resource.h"\r
-\r
-#include "server.h"\r
 \r
 #ifdef _DEBUG\r
        #define _CRTDBG_MAP_ALLOC\r
        #include <stdlib.h>\r
        #include <crtdbg.h>\r
+#else\r
+       #include <tbb/tbbmalloc_proxy.h>\r
 #endif\r
 \r
+#include "resource.h"\r
+\r
+#include "server.h"\r
+\r
 #define NOMINMAX\r
 #define WIN32_LEAN_AND_MEAN\r
 \r
@@ -168,10 +169,17 @@ int main(int argc, wchar_t* argv[])
        \r
        // Set debug mode.\r
        #ifdef _DEBUG\r
-               _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF );\r
-               _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_DEBUG );\r
-               _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_DEBUG );\r
-               _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_DEBUG );\r
+               HANDLE hLogFile;\r
+               hLogFile = CreateFile(L"crt_log.txt", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);\r
+               std::shared_ptr<void> crt_log(nullptr, [](HANDLE h){::CloseHandle(h);});\r
+\r
+               _CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);\r
+               _CrtSetReportMode(_CRT_WARN,    _CRTDBG_MODE_FILE);\r
+               _CrtSetReportFile(_CRT_WARN,    hLogFile);\r
+               _CrtSetReportMode(_CRT_ERROR,   _CRTDBG_MODE_FILE);\r
+               _CrtSetReportFile(_CRT_ERROR,   hLogFile);\r
+               _CrtSetReportMode(_CRT_ASSERT,  _CRTDBG_MODE_FILE);\r
+               _CrtSetReportFile(_CRT_ASSERT,  hLogFile);\r
        #endif\r
 \r
        // Increase process priotity.\r