Results 1 to 2 of 2

Thread: QDataStream and QHash<QString,QVariant> crash on read

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QDataStream and QHash<QString,QVariant> crash on read

    Hi,

    I'm using Qt 4.3.0 on Windows with Visual Studio 2003 .NET.

    I have a QHash defined as:
    Qt Code:
    1. QHash<QString,QVariant> m_qHash;
    To copy to clipboard, switch view to plain text mode 

    The "m_qHash" containg 16 elements.

    Then I use a QDataStream to store it to a file.
    When trying to load from the file, the first value(hash pair) is correctly loaded,but it crash on "QDataStream &operator>>(QDataStream &in, QString &str)" into "qstring.cpp", when reading the second value(hash pair). When it reads the "bytes" on line 6829, it reads that it contains 0 bytes and so it returns an empty string.
    Then on "QDataStream& operator>>(QDataStream &s, QVariant &p)" into "qvariant.cpp" crash on line 1775:

    Qt Code:
    1. Q_ASSERT_X(false, "QVariant::load", "Invalid type to load");
    To copy to clipboard, switch view to plain text mode 

    I'm debugging the application and I don't find where is the problem.

    Thanks,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QDataStream and QHash<QString,QVariant> crash on read

    Hi,

    I've found my error:

    I was setting the QDataStream version to Qt 4.1 on writting but I've forgiven to set the same version on the QDataStream when reading. So, as I updated the Qt version from 4.1 to 4.3 it crashed.

    Thanks,
    Òscar Llarch i Galán

Similar Threads

  1. External Lib read from QBuffer on Calback problem
    By patrik08 in forum Qt Programming
    Replies: 2
    Last Post: 2nd June 2008, 19:43
  2. How to read CD with read?
    By vishal.chauhan in forum Qt Programming
    Replies: 6
    Last Post: 29th June 2007, 08:20
  3. QIODevice read()
    By ShaChris23 in forum Newbie
    Replies: 1
    Last Post: 3rd May 2007, 00:29

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.