diff options
author | Andrew Knight <andrew.knight@digia.com> | 2013-10-03 12:19:52 +0300 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-10-04 12:40:03 +0200 |
commit | 69e78b9a0764ea5ec56689f09311741d4fc5870e (patch) | |
tree | 741fae0e1ad5577920cee098c565b458a5cc99dd /src/winmain/qtmain_winrt.cpp | |
parent | cb82b3e8913e9d7952e9b3d4fa680c4af9965434 (diff) |
WinRT winmain: enable debugger waiting
WinRT applications are not invoked directly, so a debugger may attach too
late to be useful. While the application can be launched with a debugging
server, attaching directly to the running process is simpler and less
resource-intensive. For this reason, it is useful for applications to
wait for the direct debugger to attach. If the existing -qdebug parameter
is passed to the application, wait idly until the debugger attaches.
Change-Id: I7b4957beb9728ab6311b459e4d809dc5f4767780
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/winmain/qtmain_winrt.cpp')
-rw-r--r-- | src/winmain/qtmain_winrt.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/winmain/qtmain_winrt.cpp b/src/winmain/qtmain_winrt.cpp index d0f138269f..c0542ff242 100644 --- a/src/winmain/qtmain_winrt.cpp +++ b/src/winmain/qtmain_winrt.cpp @@ -69,7 +69,7 @@ typedef ITypedEventHandler<Core::CoreApplicationView *, Activation::IActivatedEv class AppContainer : public Microsoft::WRL::RuntimeClass<Core::IFrameworkView> { public: - AppContainer(int argc, wchar_t **argv) : m_argc(argc) + AppContainer(int argc, wchar_t **argv) : m_argc(argc), m_debugWait(false) { m_argv.reserve(argc); for (int i = 0; i < argc; ++i) { @@ -95,6 +95,11 @@ public: HRESULT __stdcall Load(HSTRING) { return S_OK; } HRESULT __stdcall Run() { + // Wait for debugger before continuing + if (m_debugWait) { + while (!IsDebuggerPresent()) + WaitForSingleObjectEx(GetCurrentThread(), 1, true); + } return main(m_argv.count(), m_argv.data()); } HRESULT __stdcall Uninitialize() { return S_OK; } @@ -113,6 +118,8 @@ private: foreach (const QByteArray &arg, QString::fromWCharArray( WindowsGetStringRawBuffer(arguments, nullptr)).toLocal8Bit().split(' ')) { m_argv.append(qstrdup(arg.constData())); + if (arg == "-qdebug") + m_debugWait = true; } } return S_OK; @@ -120,6 +127,7 @@ private: int m_argc; QVector<char *> m_argv; + bool m_debugWait; EventRegistrationToken m_activationToken; }; |