summaryrefslogtreecommitdiffstats
path: root/src/winmain
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@digia.com>2014-01-20 19:33:16 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-30 22:09:55 +0100
commitf3df57e7b839fe8cee0ea377a4f2951073e7255a (patch)
tree7157126114b145cf97a3884c8abf2e85897f6b7b /src/winmain
parent604849018dc48736b7304521ecc04aa26a053ce4 (diff)
WinRT winmain: handle -qdevel parameter for additional debugging tooling
This adds an additional command line argument, -qdevel, for tooling support. Since Windows Phone deployment APIs don't return the PID, this writes the PID to a lock file that can be read by deployment tools. Since arguments may be passed from one of several entry points, the special argument checks are now done in Run() instead of onActivated(). Change-Id: Ib3af157ccf687769d43d60adef9a0ab480e835b7 Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Diffstat (limited to 'src/winmain')
-rw-r--r--src/winmain/qtmain_winrt.cpp29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/winmain/qtmain_winrt.cpp b/src/winmain/qtmain_winrt.cpp
index 18bd619383..151294d2c4 100644
--- a/src/winmain/qtmain_winrt.cpp
+++ b/src/winmain/qtmain_winrt.cpp
@@ -65,6 +65,8 @@ extern "C" {
#include <qstring.h>
#include <qlist.h>
#include <qvector.h>
+#include <qdir.h>
+#include <qstandardpaths.h>
#include <wrl.h>
#include <Windows.ApplicationModel.core.h>
@@ -82,7 +84,7 @@ static int g_mainExitCode;
class AppContainer : public Microsoft::WRL::RuntimeClass<Core::IFrameworkView>
{
public:
- AppContainer(int argc, char *argv[]) : m_argc(argc), m_debugWait(false)
+ AppContainer(int argc, char *argv[]) : m_argc(argc)
{
m_argv.reserve(argc);
for (int i = 0; i < argc; ++i)
@@ -106,8 +108,28 @@ public:
HRESULT __stdcall Load(HSTRING) { return S_OK; }
HRESULT __stdcall Run()
{
+ bool develMode = false;
+ bool debugWait = false;
+ foreach (const QByteArray &arg, m_argv) {
+ if (arg == "-qdevel")
+ develMode = true;
+ if (arg == "-qdebug")
+ debugWait = true;
+ }
+ if (develMode) {
+ // Write a PID file to help runner
+ const QString pidFileName = QDir(QStandardPaths::writableLocation(QStandardPaths::DataLocation))
+ .absoluteFilePath(QString::number(uint(GetCurrentProcessId())) + QStringLiteral(".pid"));
+ CREATEFILE2_EXTENDED_PARAMETERS params = {
+ sizeof(CREATEFILE2_EXTENDED_PARAMETERS),
+ FILE_ATTRIBUTE_NORMAL, FILE_FLAG_DELETE_ON_CLOSE
+ };
+ // (Unused) handle will automatically be closed when the app exits
+ CreateFile2(reinterpret_cast<LPCWSTR>(pidFileName.utf16()),
+ 0, FILE_SHARE_READ|FILE_SHARE_DELETE, CREATE_ALWAYS, &params);
+ }
// Wait for debugger before continuing
- if (m_debugWait) {
+ if (debugWait) {
while (!IsDebuggerPresent())
WaitForSingleObjectEx(GetCurrentThread(), 1, true);
}
@@ -131,8 +153,6 @@ private:
foreach (const QByteArray &arg, QString::fromWCharArray(
WindowsGetStringRawBuffer(arguments, nullptr)).toLocal8Bit().split(' ')) {
m_argv.append(qstrdup(arg.constData()));
- if (arg == "-qdebug")
- m_debugWait = true;
}
}
}
@@ -141,7 +161,6 @@ private:
int m_argc;
QVector<char *> m_argv;
- bool m_debugWait;
EventRegistrationToken m_activationToken;
};