diff options
author | Liang Qi <liang.qi@qt.io> | 2016-05-12 07:31:50 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-05-12 08:33:08 +0200 |
commit | 990969655c5fb4d03682e96df9b12101f5ee9815 (patch) | |
tree | b8fb5c50285105c8bc5a938fb50f93ff9f24889d /src/winmain | |
parent | a213011a53f12f101d08a04afc8fdacd2d54a232 (diff) | |
parent | e64b2234e829cc47872225debcf80d6c06db18f0 (diff) |
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
config_help.txt
configure
src/corelib/io/qprocess_wince.cpp
src/plugins/platforms/windows/qwindowstheme.cpp
src/plugins/platforms/xcb/qxcbbackingstore.cpp
tests/auto/corelib/tools/qtimezone/BLACKLIST
tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp
tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
Change-Id: I26644d1cb3b78412c8ff285e2a55bea1bd641c01
Diffstat (limited to 'src/winmain')
-rw-r--r-- | src/winmain/qtmain_winrt.cpp | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/src/winmain/qtmain_winrt.cpp b/src/winmain/qtmain_winrt.cpp index 91c8aa318d..e2046b1106 100644 --- a/src/winmain/qtmain_winrt.cpp +++ b/src/winmain/qtmain_winrt.cpp @@ -197,12 +197,43 @@ public: } private: + HRESULT activatedLaunch(IInspectable *activateArgs) { + QCoreApplication *app = QCoreApplication::instance(); + + // Check whether the app already runs + if (!app) { +#if _MSC_VER >= 1900 + // I*EventArgs have no launch arguments, hence we + // need to prepend the application binary manually + wchar_t fn[513]; + DWORD res = GetModuleFileName(0, fn, 512); + + if (SUCCEEDED(res)) + args.prepend(QString::fromWCharArray(fn, res).toUtf8().data()); +#endif _MSC_VER >= 1900 + + ResumeThread(mainThread); + + // We give main() a max of 100ms to create an application object. + // No eventhandling needs to happen at that point, all we want is + // append our activation event + int iterations = 0; + while (true) { + app = QCoreApplication::instance(); + if (app || iterations++ > 10) + break; + Sleep(10); + } + } + + if (app) + QCoreApplication::postEvent(app, new QActivationEvent(activateArgs)); + return S_OK; + } + HRESULT __stdcall OnActivated(IActivatedEventArgs *args) Q_DECL_OVERRIDE { - QAbstractEventDispatcher *dispatcher = QCoreApplication::eventDispatcher(); - if (dispatcher) - QCoreApplication::postEvent(dispatcher, new QActivationEvent(args)); - return S_OK; + return activatedLaunch(args); } HRESULT __stdcall OnLaunched(ILaunchActivatedEventArgs *launchArgs) Q_DECL_OVERRIDE @@ -300,8 +331,7 @@ private: HRESULT __stdcall OnFileActivated(IFileActivatedEventArgs *args) Q_DECL_OVERRIDE { - Q_UNUSED(args); - return S_OK; + return activatedLaunch(args); } HRESULT __stdcall OnSearchActivated(ISearchActivatedEventArgs *args) Q_DECL_OVERRIDE @@ -312,8 +342,7 @@ private: HRESULT __stdcall OnShareTargetActivated(IShareTargetActivatedEventArgs *args) Q_DECL_OVERRIDE { - Q_UNUSED(args); - return S_OK; + return activatedLaunch(args); } HRESULT __stdcall OnFileOpenPickerActivated(IFileOpenPickerActivatedEventArgs *args) Q_DECL_OVERRIDE @@ -344,7 +373,7 @@ private: ComPtr<Xaml::IApplication> core; QByteArray commandLine; QVarLengthArray<char *> args; - HANDLE mainThread; + HANDLE mainThread{0}; HANDLE pidFile; }; |