[solved] Qt application crashes when accessing QList<QLlnkedList<QUrl>* > from NetworkAccessManager->get() callback



  • I am currently trying to map redirect urls back to their original urls when using QNetworkAccessManager since I haven't found a built in function.

    My application crashes when I am trying to access a QList<QLinkedList<QUrl>* > within the replyFinished(QNetworkReply* networkReply); slot of a QNetworkAccessManager.

    If the url is a redirect url, I basically loop once over the list add the redirect url to the list, load the redirected url and then exit the function:

    @foreach (QLinkedList<QUrl>* list, mList) {
    if (list->front() == url) {
    list->prepend(someUrl);
    mNetworkAccessManager->get(someUrl);
    return;
    }
    }@

    If the url I got is not a redirect url, I execute the following code:

    @QList<QLinkedList<QUrl>* >::iterator it = mList.begin();
    while (it != mList.end()) {
    QLinkedList<QUrl>* list = *it;

    if (list->front() == networkReply->url()) {
        QUrl originalUrl = list->back();
        this->someOperation(originalUrl);
        mList.erase(it);
        delete list;
        break;
    }
    

    }@

    The code above basically looks up the original url in the QLinkedList. The reason I use a QList around the QLinkedList is that I can have multiple requests running at the same time.

    Somehow my application freezes and I can't do anything. Is it because replyFinished() gets called in a different Thread and it's trying to access things in the Main Thread or what's the reason behind it?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.