diff options
author | Liang Qi <liang.qi@qt.io> | 2016-04-22 09:31:58 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-04-25 14:03:45 +0200 |
commit | bb4b86618dc930e0035c5829e336f2606d140ada (patch) | |
tree | 6e36808ca46244373bc70aabbb926cc114538beb /src/winmain | |
parent | 276adc5a09914fd89d976bb90cc0cd67de9d3d6e (diff) | |
parent | bbd1228b17ee3f3a5483f88b0a581d6a60c41cad (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
config.tests/unix/compile.test
configure
src/android/jar/src/org/qtproject/qt5/android/QtMessageDialogHelper.java
src/corelib/global/qglobal.cpp
src/widgets/kernel/qapplication.cpp
src/widgets/styles/qwindowsvistastyle.cpp
tests/auto/corelib/kernel/qobject/tst_qobject.cpp
Change-Id: I067083f34e5290aa5f7565e40c30a069cc37b83a
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; }; |