Qt application freezes when accessing QList<QLlnkedList<QUrl>* > from NetworkAccessManager->get() callback

116 views Asked by At

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

I basically loop once over the list add something to the list and then exit the function:

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

In the other scenario I do the following:

QList<QLinkedList<QUrl>* >::iterator it = mList.begin();
while (it != mList.end()) {
    QLinkedList<QUrl>* list = *it;
    if (list->front() == networkReply->url()) {
        // some operation with list->back();
        mList.erase(it);
        delete list;
        break;
    }
}

Is there any way to make this construct safe?

1

There are 1 answers

0
Niklas On BEST ANSWER

I was caught in an endless loop, since

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

never increased the iterator ..