Results 1 to 5 of 5

Thread: QList and QVariant crashes with VS2010

  1. #1
    Join Date
    Jun 2010
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default QList and QVariant crashes with VS2010

    Hi,

    i have Qt 4.7.1 and VS2010 Express

    the following code crashes with no reason:
    Qt Code:
    1. #include "QApplication"
    2. #include <QtCore>
    3.  
    4. void test( )
    5. {
    6. QVariant v, v2;
    7. QList<QVariant> list;
    8. v.setValue(1); // init variant with integer = 1
    9. list.append(v); // add variant to list
    10. v2.setValue(list); // add list to variant
    11. qDebug() << v;
    12. qDebug() << list;
    13. qDebug() << v2;
    14. // leaving this function will crash with a corrupted heap
    15. // output see below
    16. }
    17.  
    18. int main( int argc , char *argv[] )
    19. {
    20. test();
    21. QApplication app(argc, argv);
    22. return app.exec();
    23. }
    To copy to clipboard, switch view to plain text mode 

    my output:
    Qt Code:
    1. QVariant(int, 1)
    2. (QVariant(int, 1) )
    3. QVariant(QVariantList, (QVariant(int, 1) ) )
    To copy to clipboard, switch view to plain text mode 

    after the crash it points me to "qguivariant.cpp" line 280:
    Qt Code:
    1. qcoreVariantHandler()->clear(d);
    To copy to clipboard, switch view to plain text mode 

    any help ?
    thanks

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QList and QVariant crashes with VS2010

    Have you builded Qt framework with VS2010? Or you are using the already build with VS2008 downloaded from qt.nokia site?
    If you didn't build Qt with VS2010 you should do it, else you can get errors at run-time (like corrupted heap) or if you already rebuild Qt with 2010 you should give a little more information about the error.

    //i'm not at my system with VS right now, but i will test your code a little bit later

  3. #3
    Join Date
    Jun 2010
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QList and QVariant crashes with VS2010

    i am using the build i downloaded from qt.nokia download section
    i have not tried to compile qt with vs2010 because i assumed that 4.7.x should work with it

    the only info i have is this small test code.
    i require this data structure as some Qt functions do return such a structure (COM objects)

  4. #4
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QList and QVariant crashes with VS2010

    The dlls are not compatible, you should build Qt with VS2010
    As another example see this topic too.
    Some applications work with dlls builded with Vs2008, but some give strange errors at run-time, and then you need to build Qt with the same compiler version as application using it's dlls.

    //i tested your function with VS2010 and Qt (built with VS2010) and it doesn't crash

  5. #5
    Join Date
    Jun 2010
    Posts
    11
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QList and QVariant crashes with VS2010

    thank you for your help

Similar Threads

  1. Linking fail when compileing Qt 4.7.1 with VS2010 on win 7 x64
    By BiceMaster in forum Installation and Deployment
    Replies: 7
    Last Post: 7th February 2011, 13:42
  2. VS2010 Support
    By Dato0011 in forum Qt Tools
    Replies: 3
    Last Post: 19th February 2010, 17:57
  3. Store QList<T> in QVariant and stream to QDataStream?
    By razvan.petru in forum Qt Programming
    Replies: 3
    Last Post: 18th September 2009, 09:10
  4. QVariant, QList, QSettings
    By TheKedge in forum Qt Programming
    Replies: 6
    Last Post: 6th March 2007, 15:50
  5. Casting QStringList to QList<QVariant>
    By Valheru in forum Newbie
    Replies: 3
    Last Post: 5th October 2006, 22:24

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.