Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with main_executor for Qt on application exit #515

Open
magpier84 opened this issue Jan 11, 2023 · 3 comments
Open

Problem with main_executor for Qt on application exit #515

magpier84 opened this issue Jan 11, 2023 · 3 comments

Comments

@magpier84
Copy link

magpier84 commented Jan 11, 2023

There is a crash on the application exit with main_executor for Qt.
Solved by checking application existence. Or there is any way to cancel the task?

    void operator()(F f) const {
        // --> The existence of the application instance should be checked
        if (auto* app = QCoreApplication::instance()) {
            auto event = std::make_unique<executor_event>();
            event->set_task(std::move(f));
            auto receiver = event->receiver();
            QCoreApplication::postEvent(receiver, event.release());
        }
    }
@magpier84
Copy link
Author

Looks like problem with default_executor (on version 1.6.2)

@sean-parent
Copy link
Member

Is it an assert? If you are using default_executor requires a call to pre_exit() prior to exiting the application. https://stlab.cc/libraries/concurrency/default_executor.hpp/

@magpier84
Copy link
Author

magpier84 commented Jan 12, 2023

Sorry, a little bit details here:

  1. Platform macOS (libdispatch)
  2. I'm using serial_queue
  3. queue([](){...}).then(main_executor([](){...});
  4. I see path through default_executor in stack trace
  5. The problem is in c-tor of executor_event, application instance is NULL
        executor_event() : QEvent(QEvent::User), _receiver(new event_receiver()) {
            _receiver->moveToThread(QCoreApplication::instance()->thread());
        }

So, the issue can be solved either by checking the application's existence or preventing its deletion. For the second case, it seems pre_exit should help, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants