[rkward/releases/0.6.4] rkward: Start on Windows without the annoying console window.
Thomas Friedrichsmeier
thomas.friedrichsmeier at ruhr-uni-bochum.de
Sat Feb 20 21:38:24 UTC 2016
Git commit 6562658cd3373fe075330ab0ef80cb6753c64d33 by Thomas Friedrichsmeier.
Committed on 20/02/2016 at 21:37.
Pushed by tfry into branch 'releases/0.6.4'.
Start on Windows without the annoying console window.
I had hoped this would also fix a mysterious startup crash on Win7, which apparently, it does not.
But it is certainly useful in its own right.
M +26 -3 rkward/rkward_startup_wrapper.cpp
http://commits.kde.org/rkward/6562658cd3373fe075330ab0ef80cb6753c64d33
diff --git a/rkward/rkward_startup_wrapper.cpp b/rkward/rkward_startup_wrapper.cpp
index 6c14e32..7df8e74 100644
--- a/rkward/rkward_startup_wrapper.cpp
+++ b/rkward/rkward_startup_wrapper.cpp
@@ -57,6 +57,7 @@ QString findRKWardAtPath (const QString &path) {
#ifdef Q_WS_WIN
#include <windows.h>
+#include <QTemporaryFile>
#endif
QString quoteCommand (const QString &orig) {
#ifdef Q_WS_WIN
@@ -287,10 +288,32 @@ int main (int argc, char *argv[]) {
InteractiveProcess proc;
#ifdef Q_WS_WIN
- proc.setProcessChannelMode (debugger_args.isEmpty () ? QProcess::MergedChannels : QProcess::ForwardedChannels); // ForwardedChannels causes console window to pop up!
-#else
- proc.setProcessChannelMode (QProcess::ForwardedChannels);
+ if (debugger_args.isEmpty ()) {
+ // start _without_ opening an annoying console window
+ QTemporaryFile *vbsf = new QTemporaryFile (QDir::tempPath () + "/rkwardlaunchXXXXXX.vbs");
+ vbsf->setAutoRemove (false);
+ if (vbsf->open ()) {
+ QTextStream vbs (vbsf);
+ vbs << "Dim WinScriptHost\r\nSet WinScriptHost = CreateObject(\"WScript.Shell\")\r\nWinScriptHost.Run \"" << quoteCommand (r_exe);
+ for (int i = 0; i < call_args.length (); ++i) {
+ vbs << " " << call_args[i];
+ }
+ vbs << "\", 0\r\nSet WomScriptHost = Nothing\r\n";
+ vbsf->close ();
+ QString filename = vbsf->fileName ();
+ delete (vbsf); // somehow, if creating vbsf on the stack, we cannot launch it, because "file is in use by another process", despite we have closed it.
+ proc.start ("WScript.exe", QStringList (filename));
+ bool ok = proc.waitForFinished (-1);
+ if (proc.exitCode () || !ok) {
+ QMessageBox::critical (0, "Error starting RKWard", QString ("Starting RKWard failed with error \"%1\"").arg (proc.errorString ()));
+ }
+ QFile (filename).remove ();
+ return (0);
+ }
+ }
+ // if that did not work or not on windows:
#endif
+ proc.setProcessChannelMode (QProcess::ForwardedChannels);
proc.start (quoteCommand (r_exe), call_args);
bool ok = proc.waitForFinished (-1);
if (proc.exitCode () || !ok) {
More information about the rkward-tracker
mailing list