Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QNetworkAccessManager throw "QWaitCondition" warning.
Forum Updated to NodeBB v4.3 + New Features

QNetworkAccessManager throw "QWaitCondition" warning.

Scheduled Pinned Locked Moved General and Desktop
qnetworkaccessm
2 Posts 1 Posters 1.5k 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.
  • K Offline
    K Offline
    kartlee144
    wrote on last edited by kartlee144
    #1

    I am seeing a strange error "QWaitCondition: destroyed while thread is still running" under Windows using QNetworkAccessManager in blocking mode and quitting the event loop once the QNetworkReply emit finished(..). On seeing with process explorer, I see stack trace of two threads locked in _endthreadex call.

    ntdll.dll!ZwWaitForMultipleObjects+0xa
    KERNELBASE.dll!GetCurrentProcess+0x40
    kernel32.dll!WaitForMultipleObjectsEx+0xb3
    USER32.dll!GetScrollBarInfo+0x1dd
    USER32.dll!MsgWaitForMultipleObjectsEx+0x2e
    QtCore4.dll!QEventDispatcherWin32::processEvents+0x5d8
    QtCore4.dll!QEventLoop::exec+0x21f
    QtCore4.dll!QThread::exec+0xf6
    QtCore4.dll!QEventDispatcherWin32::default constructor closure'+0x9f8
    MSVCR120.dll!beginthreadex+0x107
    MSVCR120.dll!endthreadex+0x192
    kernel32.dll!BaseThreadInitThunk+0xd
    ntdll.dll!RtlUserThreadStart+0x21
    
    `
     // The QCoreApplication below is created once for the entire
     // lifetime of the app
     int qargc = 1;
     char* qargv[] = ;
     QCoreApplication ourQapp = new QCoreApplication(qargc, qargv);
    
     // Entry to function
     <...function ...>
     auto mgr = std::make_shared<QNetworkAccessManager>();
     QObject::connect(mgr.get(), SIGNAL(finished(QNetworkReply*)), ourQapp,    
         SLOT(quit()));
     QNetworkRequest req(url);
     std::shared_ptr<QNetworkReply> response;
     response = std::shared_ptr<QNetworkReply>(mgr.get()->get(req));
     ourQapp->exec();
    
     QNetworkReply::NetworkError status = response->error();
     if(status == QNetworkReply::NoError) {
         // do something
     } else {
         // do something
     }
    
     <....return from function....>`
    

    Once we return from the function, I see two threads hanging around and as a result, when the application exit, I see the above warning.

    So my question is -

    1. Why are those two threads left behind even when QNetworkAccessManager emit finished?
    2. If we have to wait for threads to cleanup and have the event loop running, whats the best way to do it and return from function? Please note, I need this as a blocking call for now and doesn't need it to operate in event loop async fashion.
    3. Why is this warning seen only under Windows? Linux and Mac seem to go fine.

    The qt i am using is 4.8.

    BTW, I should also mention that QNetworkReply show the status as finished if I check in the finished slot.

    -Kartlee

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kartlee144
      wrote on last edited by
      #2

      I found this link discussing about the trace seen in Windows https://bugreports.qt.io/browse/QTBUG-7691 Not sure if this is still related to mine.

      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