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 +#include +#include #include #include #include @@ -168,16 +170,20 @@ bool QWinRTMessageDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModa } } - ComPtr> op; - hr = dialog->ShowAsync(&op); - RETURN_FALSE_IF_FAILED("Failed to show dialog"); - hr = op->put_Completed(Callback(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> op; + hr = dialog->ShowAsync(&op); + RETURN_HR_IF_FAILED("Failed to show dialog"); + hr = op->put_Completed(Callback(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; }