Problem in allocating memory for QNetworkAccessManager



  • Hello,
    I have created an application in Qt which reads .txt file from url. For reading file from network url, I am using QNetworkAccessManager. I am using visual studio 2008 as development kit and Qt version is 4.8.1. Also If I am run program in debug mode, it is reading file but if I am running program in Release mode, program breaks while creating object of QNetworkAccessManager.

    See below code snippet.

    QNetworkAccessManager *manager = new QNetworkAccessManager();
        QNetworkRequest request(xmlURL);
        manager->setNetworkAccessible(QNetworkAccessManager::Accessible);
        connect(manager, SIGNAL(finished(QNetworkReply*)),
            this, SLOT(ReplyFinishedCheck(QNetworkReply*)));
        try 
        {
            pReply = manager->get(request);
        }
        catch (...)
        {
            verionLabel->setText("Error in connection with network");
        }
        
        connect(pReply, SIGNAL(error(QNetworkReply::NetworkError)),
            this, SLOT(slotError(QNetworkReply::NetworkError)));
        connect(pReply, SIGNAL(sslErrors(QList<QSslError>)),
            this, SLOT(slotSslErrors(QList<QSslError>)));
    


  • Hi @Sitaram, and welcome :)

    program breaks while creating object

    What exact error message are you getting?



  • @Paul-Colby
    I dont get ant error message. Actually program exits. But in debug mode it works.



  • @Paul-Colby

    Actually program exits while creating instance of the class for this statement.

    QNetworkAccessManager *manager = new QNetworkAccessManager();



  • Hi,

    Welcome to Forum
    Can u first check whether you are creating only one instance.
    First initialize the variable manager to NULL. Check if its NULL then create the object.

    Are u calling in slots?.


Log in to reply
 

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