Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-122714

QDialog::exec() using Coroutines instead of QEventLoop

    XMLWordPrintable

Details

    • WebAssembly

    Description

      The QDialog::exec() function is widely used in existing codebases, particularly with QMessageBox, due to its convenience. However, exec() hampers flexibility by blocking the event loop, which poses a significant challenge when porting applications to WebAssembly. The use of Asyncify is not a universal remedy, as it does not support nested calls.

      exec() operates by displaying the dialog and halting further execution until the dialog is dismissed, at which point execution resumes within the same function. Transitioning to the asynchronous open() function as an alternative requires significant code restructuring, often necessitating the division of code across multiple functions, thus adding complexity and requiring extensive tests.

      While I am not an expert, I have observed that C++20 introduces coroutines, offering a promising mechanism to suspend execution. This feature potentially enables the development of a compatible exec() function that can pause execution and await user input without necessitating an additional event loop.

      Adopting such a solution could significantly ease the process of adapting existing code for compatibility with Qt for WebAssembly, potentially addressing other related challenges as well. Although there are discussions surrounding the use of coroutines, I have yet to find any that specifically address this scenario. However, it is reasonable to expect that the Qt development team, with their deeper understanding, would be better positioned to evaluate this approach.

      Implementing this solution could streamline the transition of existing applications to Qt WebAssembly, making it a more feasible endeavor.

      Below are some resources I have found helpful:

       

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qt.webassembly qt.webassembly
              domezuk Domenico Zucchetti
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes