Results 1 to 1 of 1

Thread: Strange QByteArray mismatch

  1. #1
    Join Date
    May 2008
    Posts
    276
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Strange QByteArray mismatch

    I use zlib to decompress gzip data from http responses.
    Sometimes it does work.
    I have this piece of code (buffers is a a QHash of QByteArray to make buffering):
    Qt Code:
    1. ....
    2. buffers.value(host)->append(data);
    3. qDebug()<<"SOCKET FLUSH-----------------"<<
    4. proxySocket->property("flush")<<
    5. proxySocket->property("current-length")<<
    6. proxySocket->property("length")<<buffers<<
    7. buffers.value(host)->isEmpty();
    8. // did we buffer?
    9.  
    10. if (!buffers.value(host)->isEmpty())
    11. {
    12.  
    13. content = QByteArray(buffers.value(host)->data());
    14. qDebug()<<"FLUSHED BUFFER-------"<<content;
    15. }
    16. compressed = decompress(content);
    To copy to clipboard, switch view to plain text mode 
    In the output I have:
    Qt Code:
    1. SOCKET FLUSH----------------- QVariant(, ) QVariant(int, 2262) QVariant(int, 2262) QHash(("", 0x47a68c0)
    To copy to clipboard, switch view to plain text mode 

    but the size of compressed is 0! How is it possible? I have 2262 byte in content, why the decompression does not work? Also if I print the size of content at the end of the code, it is lower than the size of the buffer, e.g. 2262


    Added after 8 minutes:


    First, I found that data() is not the correct way to pass the data, because data() returns a char*, a pointer.

    Qt Code:
    1. content = QByteArray(*buffers.value(host));
    To copy to clipboard, switch view to plain text mode 
    This is right.
    Last edited by giusepped; 25th October 2011 at 17:28.

Similar Threads

  1. Sql problem - parameter mismatch count
    By Marina K. in forum Qt Programming
    Replies: 1
    Last Post: 20th June 2011, 18:27
  2. dynamicCall and QByteArray - strange characters
    By franco.amato in forum Qt Programming
    Replies: 120
    Last Post: 28th April 2010, 21:11
  3. Replies: 9
    Last Post: 25th July 2009, 13:27
  4. QSslSocket hostname mismatch
    By eleanor in forum Qt Programming
    Replies: 7
    Last Post: 11th May 2009, 17:48
  5. Class name mismatch for plugin
    By martinb0820 in forum Qt Tools
    Replies: 3
    Last Post: 20th August 2008, 13:47

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.