diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp | 78 |
1 files changed, 39 insertions, 39 deletions
diff --git a/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp b/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp index 68bf1fdcac..bb04144563 100644 --- a/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp +++ b/src/plugins/platforms/winrt/qwinrtmessagedialoghelper.cpp @@ -133,45 +133,46 @@ bool QWinRTMessageDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModa RETURN_FALSE_IF_FAILED("Failed to create dialog"); } - // Add Buttons - ComPtr<IVector<IUICommand *>> dialogCommands; - hr = dialog->get_Commands(&dialogCommands); - RETURN_FALSE_IF_FAILED("Failed to get dialog commands"); - - // If no button is specified we need to create one to get close notification - int buttons = options->standardButtons(); - if (buttons == 0) - buttons = Ok; - - for (int i = FirstButton; i < LastButton; i<<=1) { - if (!(buttons & i)) - continue; - // Add native command - const QString label = d->theme->standardButtonText(i); - HStringReference nativeLabel(reinterpret_cast<LPCWSTR>(label.utf16()), label.size()); - ComPtr<IUICommand> command; - hr = commandFactory->Create(nativeLabel.Get(), &command); - RETURN_FALSE_IF_FAILED("Failed to create message box command"); - ComPtr<IInspectable> id = Make<CommandId>(static_cast<StandardButton>(i)); - hr = command->put_Id(id.Get()); - RETURN_FALSE_IF_FAILED("Failed to set command ID"); - hr = dialogCommands->Append(command.Get()); - if (hr == E_BOUNDS) { - qErrnoWarning(hr, "The WinRT message dialog supports a maximum of three buttons"); - continue; - } - RETURN_FALSE_IF_FAILED("Failed to append message box command"); - if (i == Abort || i == Cancel || i == Close) { - quint32 size; - hr = dialogCommands->get_Size(&size); - RETURN_FALSE_IF_FAILED("Failed to get command list size"); - hr = dialog->put_CancelCommandIndex(size - 1); - RETURN_FALSE_IF_FAILED("Failed to set cancel index"); + hr = QEventDispatcherWinRT::runOnXamlThread([this, d, options, commandFactory, dialog]() { + HRESULT hr; + + // Add Buttons + ComPtr<IVector<IUICommand *>> dialogCommands; + hr = dialog->get_Commands(&dialogCommands); + RETURN_HR_IF_FAILED("Failed to get dialog commands"); + + // If no button is specified we need to create one to get close notification + int buttons = options->standardButtons(); + if (buttons == 0) + buttons = Ok; + + for (int i = FirstButton; i < LastButton; i<<=1) { + if (!(buttons & i)) + continue; + // Add native command + const QString label = d->theme->standardButtonText(i); + HStringReference nativeLabel(reinterpret_cast<LPCWSTR>(label.utf16()), label.size()); + ComPtr<IUICommand> command; + hr = commandFactory->Create(nativeLabel.Get(), &command); + RETURN_HR_IF_FAILED("Failed to create message box command"); + ComPtr<IInspectable> id = Make<CommandId>(static_cast<StandardButton>(i)); + hr = command->put_Id(id.Get()); + RETURN_HR_IF_FAILED("Failed to set command ID"); + hr = dialogCommands->Append(command.Get()); + if (hr == E_BOUNDS) { + qErrnoWarning(hr, "The WinRT message dialog supports a maximum of three buttons"); + continue; + } + RETURN_HR_IF_FAILED("Failed to append message box command"); + if (i == Abort || i == Cancel || i == Close) { + quint32 size; + hr = dialogCommands->get_Size(&size); + RETURN_HR_IF_FAILED("Failed to get command list size"); + hr = dialog->put_CancelCommandIndex(size - 1); + RETURN_HR_IF_FAILED("Failed to set cancel index"); + } } - } - hr = QEventDispatcherWinRT::runOnXamlThread([this, d, dialog]() { - HRESULT hr; ComPtr<IAsyncOperation<IUICommand *>> op; hr = dialog->ShowAsync(&op); RETURN_HR_IF_FAILED("Failed to show dialog"); @@ -206,8 +207,7 @@ HRESULT QWinRTMessageDialogHelper::onCompleted(IAsyncOperation<IUICommand *> *as Q_UNUSED(status); Q_D(QWinRTMessageDialogHelper); - if (d->loop.isRunning()) - d->loop.exit(); + QEventLoopLocker locker(&d->loop); d->shown = false; |