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>
This commit is contained in:
parent
cb82b3e891
commit
69e78b9a07
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user