Results 1 to 3 of 3

Thread: "Segmentation Fault" for QHttp::setHost()

  1. #1
    Join Date
    Feb 2010
    Posts
    2
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Question "Segmentation Fault" for QHttp::setHost()

    Hi,

    I'm trying a sample QT program available on trolltech webdoc [http://doc.trolltech.com/4.6/qhttp.html#details] to interface to HTTP.
    But it's giving "SegFault" for QHttp::setHost(). Kindly help me to figure out the root cause and fix to resolve it.

    Following is the code snippet that I've tried.
    ---------------------------------------------
    QHttp m_pHttp = new QHttp();
    void CHttpClient::execute()
    {
    QHttpRequestHeader header("GET", QUrl::toPercentEncoding("/index.html"));
    header.setValue("Host", "qt.nokia.com");
    m_pHttp->setHost("qt.nokia.com");
    m_pHttp->request(header);
    }

    Call stack
    ----------------------------
    0 QBasicAtomicInt:perator!= qbasicatomic.h 75 0x680ac32a
    1 QList<QHttpRequest*>::detach qlist.h 122 0x680a669f
    2 QList<QHttpRequest*>::append qlist.h 468 0x680a661b
    3 QHttpPrivate::addRequest qhttp.cpp 2385 0x6801206e
    4 QHttp::setHost qhttp.cpp 2037 0x680113a0
    5 CHttpClient::execute CCommunicator.cpp 93 0x004078f3
    ...


    Excerpt:qbasicatomic.h
    ----------------------------

    inline bool operator!=(int value) const
    {
    return _q_value != value;
    }


    here, this = 0x0 => resultuing into seg fault
    ----------------------------

    regards,
    pritam

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: "Segmentation Fault" for QHttp::setHost()

    QHttp m_pHttp = new QHttp();
    Is it same in code ? I guess you are missing the pointer. Still I wonder how its compiling
    Also am not sure if the request header object should be in a bigger scope.

  3. #3
    Join Date
    Feb 2010
    Posts
    2
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: "Segmentation Fault" for QHttp::setHost()

    Sorry for the confusion,
    it's pointer only, i.e.

    QHttp* m_pHttp = new QHttp();
    It's data member of my CHttpClient class, for reference I kept it outside.

Similar Threads

  1. linux "Segmentation fault"
    By harrison in forum Newbie
    Replies: 5
    Last Post: 3rd March 2010, 09:33
  2. why is there so strange "Segmentation fault" ?
    By lanmanck in forum Qt Programming
    Replies: 9
    Last Post: 2nd March 2010, 12:55
  3. why qstringlist *ps "Segmentation fault"?
    By lanmanck in forum Qt Programming
    Replies: 6
    Last Post: 23rd September 2009, 07:46
  4. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05
  5. QHttp "PUT METHOD" QT Problem File Upload. RFC 2616
    By patrik08 in forum Qt Programming
    Replies: 7
    Last Post: 25th October 2006, 22:02

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.