Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Problem in allocating memory for QNetworkAccessManager
Forum Updated to NodeBB v4.3 + New Features

Problem in allocating memory for QNetworkAccessManager

Scheduled Pinned Locked Moved Unsolved Qt WebKit
5 Posts 3 Posters 1.5k Views 2 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.
  • S Offline
    S Offline
    Sitaram
    wrote on last edited by p3c0
    #1

    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>)));
    
    Paul ColbyP 1 Reply Last reply
    0
    • S Sitaram

      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>)));
      
      Paul ColbyP Offline
      Paul ColbyP Offline
      Paul Colby
      wrote on last edited by
      #2

      Hi @Sitaram, and welcome :)

      program breaks while creating object

      What exact error message are you getting?

      S 2 Replies Last reply
      1
      • Paul ColbyP Paul Colby

        Hi @Sitaram, and welcome :)

        program breaks while creating object

        What exact error message are you getting?

        S Offline
        S Offline
        Sitaram
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • Paul ColbyP Paul Colby

          Hi @Sitaram, and welcome :)

          program breaks while creating object

          What exact error message are you getting?

          S Offline
          S Offline
          Sitaram
          wrote on last edited by
          #4

          @Paul-Colby

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

          QNetworkAccessManager *manager = new QNetworkAccessManager();

          1 Reply Last reply
          0
          • Pradeep KumarP Offline
            Pradeep KumarP Offline
            Pradeep Kumar
            wrote on last edited by
            #5

            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?.

            Pradeep Kumar
            Qt,QML Developer

            1 Reply Last reply
            2

            • Login

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