Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. desktop app crashed when multiple event loops are used in code
Forum Updated to NodeBB v4.3 + New Features

desktop app crashed when multiple event loops are used in code

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
2 Posts 2 Posters 520 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rahush
    wrote on last edited by
    #1

    I am trying to write some data to an url using get request from QNetworkAccessManager class. I am creating an event loop in it. There is another event loop running in the main thread which is the main event loop for the application. The application is getting crashed when it reaches eventLoop.exec(); line in the code below. Any idea why is it happening??

    bool Write(QNetworkRequest request) const
    {
    QEventLoop eventLoop;
    connect(networkAccessManager.get(), &QNetworkAccessManager::finished, &eventLoop, &QEventLoop::quit);
    int count = 0;
    while (count < retryCount)
    {
    QNetworkReply* reply = networkAccessManager->get(request);
    eventLoop.exec();
    if (reply != NULL && reply->error() == 0)
    return true;
    count++;
    }
    return false;
    }

    **networkAccessManager is the QNetworkAccessManager object.

    K 1 Reply Last reply
    0
    • R rahush

      I am trying to write some data to an url using get request from QNetworkAccessManager class. I am creating an event loop in it. There is another event loop running in the main thread which is the main event loop for the application. The application is getting crashed when it reaches eventLoop.exec(); line in the code below. Any idea why is it happening??

      bool Write(QNetworkRequest request) const
      {
      QEventLoop eventLoop;
      connect(networkAccessManager.get(), &QNetworkAccessManager::finished, &eventLoop, &QEventLoop::quit);
      int count = 0;
      while (count < retryCount)
      {
      QNetworkReply* reply = networkAccessManager->get(request);
      eventLoop.exec();
      if (reply != NULL && reply->error() == 0)
      return true;
      count++;
      }
      return false;
      }

      **networkAccessManager is the QNetworkAccessManager object.

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @rahush

      There is no need to have duplicated threads in this forum.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved