[rkward-cvs] SF.net SVN: rkward:[2524] trunk/rkward/rkward/main.cpp

tfry at users.sourceforge.net tfry at users.sourceforge.net
Wed Jun 10 19:41:30 UTC 2009


Revision: 2524
          http://rkward.svn.sourceforge.net/rkward/?rev=2524&view=rev
Author:   tfry
Date:     2009-06-10 19:41:28 +0000 (Wed, 10 Jun 2009)

Log Message:
-----------
Work around exit hang on windows

Modified Paths:
--------------
    trunk/rkward/rkward/main.cpp

Modified: trunk/rkward/rkward/main.cpp
===================================================================
--- trunk/rkward/rkward/main.cpp	2009-06-09 20:51:32 UTC (rev 2523)
+++ trunk/rkward/rkward/main.cpp	2009-06-10 19:41:28 UTC (rev 2524)
@@ -59,6 +59,12 @@
 #include "rkward.h"
 #include "rkwardapplication.h"
 
+#ifdef Q_WS_WIN
+	// these are needed for the exit hack.
+#	include <stdio.h>
+#	include <windows.h>
+#endif
+
 #include "debug.h"
 
 #include "version.h"
@@ -131,5 +137,20 @@
 
 	// do it!
 	int status = app.exec ();
+#ifdef Q_WS_WIN
+	// HACK: Somehow, if we created a windows graph-device during runtime (possibly also on other conditions), we just can't exit cleanly anymore.
+	// We get out of the event loop, but once we return from main (including using _endthread(), _exit(), exit(), abort(), raise(SIGSEGV),
+	// ExitProcess(), and I don't know, what else I tried), the process just continues to sit there, hogging up one CPU.
+	// R 2.9.0, KDElibs 4.2.3, Qt 4.4.3, WinXP SP2
+	// So what we do is
+	// 1) Make extra sure, everything important is flushed
+	// 2) Use TerminateProcess () to kill all threads
+	// Alternatives: Use system ("taskkill ..."), but this command was not introduced before WinXP
+	app.flush();
+	app.processEvents();
+	_flushall ();
+
+	TerminateProcess (GetCurrentProcess (), 0);
+#endif
 	return status;
 }


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list