From 404ef26380d3e5a9199743c0de4db94d3f6b5b9b Mon Sep 17 00:00:00 2001
From: DarkGod <darkgod@te4.org>
Date: Tue, 6 May 2014 15:52:25 +0200
Subject: [PATCH] update test

---
 src/main.c                           | 3 +++
 src/web-cef3/build/windows/build.bat | 4 ++++
 src/web-cef3/spawn.cpp               | 4 ++++
 src/web-cef3/web.cpp                 | 5 +++++
 4 files changed, 16 insertions(+)

diff --git a/src/main.c b/src/main.c
index 2e6f1ec450..d88e218385 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1522,8 +1522,11 @@ int main(int argc, char *argv[])
 	
 	printf("Terminating!\n");
 	te4_web_terminate();
+	printf("Webcore shutdown complete\n");
 	SDL_Quit();
+	printf("SDL shutdown complete\n");
 	deinit_openal();
+	printf("OpenAL shutdown complete\n");
 	printf("Thanks for having fun!\n");
 
 #ifdef SELFEXE_WINDOWS
diff --git a/src/web-cef3/build/windows/build.bat b/src/web-cef3/build/windows/build.bat
index dcfea2b987..beb5eff211 100644
--- a/src/web-cef3/build/windows/build.bat
+++ b/src/web-cef3/build/windows/build.bat
@@ -12,6 +12,8 @@
 @set CXX=cl
 @set CXXFLAGS=/nologo /MT /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE /EHsc /DSELFEXE_WINDOWS
 @rem @set CXXFLAGS=/nologo /MT /Od /Zi /Wall /D_CRT_SECURE_NO_DEPRECATE /EHsc
+@set SPAWNNAME=cef3spawn.exe
+@set SPAWN_C=spawn.cpp
 @set DLLNAME=te4-web.dll
 @set LIBNAME=te4-web.lib
 @set TE4_WEB_C=web.cpp web-utils.cpp
@@ -20,6 +22,8 @@
 
 %CXX% %CXXFLAGS% /LD /Fe%DLLNAME% %TE4_WEB_INCLUDES% %TE4_WEB_C% %TE4_WEB_LIBS%
 
+%CXX% %CXXFLAGS% /Fe%SPAWNNAME% %TE4_WEB_INCLUDES% %SPAWN_C% %TE4_WEB_LIBS%
+
 @if errorlevel 1 goto :COMPILATION_ERROR
 
 @rem All done.
diff --git a/src/web-cef3/spawn.cpp b/src/web-cef3/spawn.cpp
index 92a6a87bed..9855c6fbf4 100644
--- a/src/web-cef3/spawn.cpp
+++ b/src/web-cef3/spawn.cpp
@@ -19,6 +19,10 @@
     darkgod@te4.org
 */
 
+#ifdef _WIN32
+#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
+#endif
+
 extern "C" {
 #include "web-external.h"
 #include <stdio.h>
diff --git a/src/web-cef3/web.cpp b/src/web-cef3/web.cpp
index bfe9de3ea3..a856da6456 100644
--- a/src/web-cef3/web.cpp
+++ b/src/web-cef3/web.cpp
@@ -870,7 +870,9 @@ void te4_web_shutdown() {
 		all[it->first] = it->second;
 	}
 
+	fprintf(logfile, "[WEBCORE] Sending kill to all browsers (%d)\n", all_browsers_nb);
 	for (std::map<BrowserClient*, bool>::iterator it=all.begin(); it != all.end(); ++it) {
+		fprintf(logfile, "[WEBCORE] Sending kill to a browser (crash status %d)\n", it->first->opaque->crashed);
 		if (!it->first->opaque->crashed) {
 			it->first->browser->GetHost()->CloseBrowser(true);
 		}
@@ -880,7 +882,10 @@ void te4_web_shutdown() {
 		CefDoMessageLoopWork();
 		fprintf(logfile, "Waiting browsers to close: %d left\n", all_browsers.size());
 	}
+	
+	fprintf(logfile, "[WEBCORE] all browsers dead, shutting down\n");
 	CefShutdown();
+	fprintf(logfile, "[WEBCORE] all browsers dead, shutdown completed\n");
 
 	fclose(logfile);
 }
-- 
GitLab