diff options
author | Samuel Nevala <samuel.nevala@intopalo.com> | 2015-08-26 15:11:39 +0300 |
---|---|---|
committer | Samuel Nevala <samuel.nevala@intopalo.com> | 2015-08-27 09:47:38 +0000 |
commit | 9cdbf48c3375feb9bff2e8a4749ec47b9831b15c (patch) | |
tree | 41a24723a5753fd785998d99ecd585e21b61d249 /src/plugins/platforms/winrt | |
parent | df49755d7427a1f67ab0a8944c720d66a820dfeb (diff) |
winrt: Fix MessageDialog show on windows phone.
Run native dialog show on XAML thread.
Change-Id: I6273340e87d70aae21c838d9d7646a233c1f48be
Task-Id: QTBUG-47938
Reviewed-by: Andrew Knight <andrew.knight@intopalo.com>
Diffstat (limited to 'src/plugins/platforms/winrt')
-rw-r--r-- | src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp b/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp index 4fc1fea626..68bf1fdcac 100644 --- a/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp +++ b/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp @@ -38,7 +38,9 @@ #include "qwinrttheme.h" #include <QtCore/qfunctions_winrt.h> +#include <private/qeventdispatcher_winrt_p.h> +#include <functional> #include <windows.ui.popups.h> #include <windows.foundation.h> #include <windows.foundation.collections.h> @@ -168,16 +170,20 @@ bool QWinRTMessageDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModa } } - ComPtr<IAsyncOperation<IUICommand *>> op; - hr = dialog->ShowAsync(&op); - RETURN_FALSE_IF_FAILED("Failed to show dialog"); - hr = op->put_Completed(Callback<DialogCompletedHandler>(this, &QWinRTMessageDialogHelper::onCompleted).Get()); - RETURN_FALSE_IF_FAILED("Failed to set dialog callback"); - - d->shown = true; - hr = op.As(&d->info); - RETURN_FALSE_IF_FAILED("Failed to acquire AsyncInfo for MessageDialog"); - + hr = QEventDispatcherWinRT::runOnXamlThread([this, d, dialog]() { + HRESULT hr; + ComPtr<IAsyncOperation<IUICommand *>> op; + hr = dialog->ShowAsync(&op); + RETURN_HR_IF_FAILED("Failed to show dialog"); + hr = op->put_Completed(Callback<DialogCompletedHandler>(this, &QWinRTMessageDialogHelper::onCompleted).Get()); + RETURN_HR_IF_FAILED("Failed to set dialog callback"); + d->shown = true; + hr = op.As(&d->info); + RETURN_HR_IF_FAILED("Failed to acquire AsyncInfo for MessageDialog"); + return hr; + }); + + RETURN_FALSE_IF_FAILED("Failed to show dialog") return true; } |