Results 1 to 7 of 7

Thread: Clearing QVariantMap generates a Debug assertion failed

  1. #1
    Join Date
    Oct 2012
    Location
    France
    Posts
    29
    Thanks
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Clearing QVariantMap generates a Debug assertion failed

    Hello everyone.

    I have a problem using the QVariantMap object.

    The idea is to fill a QVariantMap with a QVariantList created in another function.
    An "Assertion Debug Failed" exception is thrown when I try to clear the QVariantMap.

    Below is a most concise example from my program.

    Qt Code:
    1. QVariantList createVariantList(){
    2. QVariantList res;
    3.  
    4. for (int i = 0; i < 42; ++i){
    5. res.append(i);
    6. }
    7.  
    8. return res;
    9. }
    10.  
    11. int main(int argc, char *argv[]){
    12. QVariantMap map;
    13. QVariantList vList = createVariantList();
    14.  
    15. /*(1)*/ map["Chev"] = vList;
    16. /*(2)*/ map["Turkish"] = createVariantList();
    17. /*(3)*/ map["Frank"] = QVariantList(createVariantList());
    18.  
    19. map.clear();// exception "Debug Assertion Failed" thrown if line (2) or/and (3) is/are present
    20.  
    21. return 0;
    22. }
    To copy to clipboard, switch view to plain text mode 
    The exception I'm getting seems to be a heap error, telling me an element is deleted twice.

    And below is a small example producing the same problem :
    Qt Code:
    1. int main(int argc, char *argv[]){
    2. QVariantMap map;
    3.  
    4. {// Creating block for keeping vList inside scope
    5. QVariantList vList = createVariantList();
    6.  
    7. map["Lee"] = vList;
    8. }// Automatic vList 'deletion'
    9.  
    10. /*(4)*/
    11.  
    12. map.clear();// exception "Debug Assertion Failed" thrown
    13.  
    14. return 0;
    15. }
    To copy to clipboard, switch view to plain text mode 

    I don't understand why the QVariantMap clearing the acts as if it was deleting the reference to the QVariantList already removed previously.
    (For testing, I successfully parsed the list at the position (4))


    One thing that could be important, is telling the error occurs in debug mode, but not in release mode (since the exception is "Debug...", I guess I should have gotten another one...).

    I'm using Qt 4.8.4, compiled with VS2012 with the options -debug-and-release for the configure.exe

    Could anyone enlighten me ?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Clearing QVariantMap generates a Debug assertion failed

    Show us the backtrace.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2012
    Location
    France
    Posts
    29
    Thanks
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Clearing QVariantMap generates a Debug assertion failed

    Hi, and thanks for your answer.

    Here is the Call stack (I hope it's the same as the backtrace)


    Qt Code:
    1. QtCored4.dll!v_clear<QList<QVariant> >(QVariant::Private * d, QList<QVariant> * __formal) Line 147 C++
    2. QtCored4.dll!clear(QVariant::Private * d) Line 214 C++
    3. QtCored4.dll!QVariant::~QVariant() Line 1400 C++
    4. VariousTestingd.exe!QVariant::`scalar deleting destructor'(unsigned int) C++
    5. VariousTestingd.exe!QMap<QString,QVariant>::freeData(QMapData * x) Line 653 C++
    6. VariousTestingd.exe!QMap<QString,QVariant>::~QMap<QString,QVariant>() Line 185 C++
    7. VariousTestingd.exe!QMap<QString,QVariant>::clear() Line 447 C++
    8. VariousTestingd.exe!main(int argc, char * * argv) Line 40 C++
    9. VariousTestingd.exe!WinMain(HINSTANCE__ * instance, HINSTANCE__ * prevInstance, char * __formal, int cmdShow) Line 131 C++
    10. VariousTestingd.exe!__tmainCRTStartup() Line 528 C
    11. VariousTestingd.exe!WinMainCRTStartup() Line 377 C
    12. kernel32.dll!75beed6c() Unknown
    13. [Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
    14. ntdll.dll!774c377b() Unknown
    15. ntdll.dll!774c374e() Unknown
    To copy to clipboard, switch view to plain text mode 


    Also, I've got new inputs.

    I tried compiling and debugging the previous code with Qt 4.8.2 (compiled with vs2010) under Visual c++ 2010 express edition.
    No error...
    I tried it before with Qt 4.8.4 and Visual studio 2012 Professional.

    It means :
    (1)- VS2012 isn't as permissive as the express edition
    (2)- My Qt 4.8.4 built is broken
    (3)- Another answer...?


    I hope to think the answer is number (2).
    I'm switching to the way I built my Qt library; so you can check if it sounds good to you.

    1. I downloaded the last Qt sources
    2. I opened a command prompt VS2012
    4. I went into the created Qt folder and executed the following commands (I chose the "open license")
    Qt Code:
    1. configure -debug-and-release -no-qt3support -no-webkit -nomake demos -nomake examples -nomake tools -platform win32-msvc2012
    2. nmake
    To copy to clipboard, switch view to plain text mode 

    Thanks in advance for your ideas.
    Last edited by bouchebeu; 27th June 2013 at 12:46.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Clearing QVariantMap generates a Debug assertion failed

    Is the snippet you posted in the previous post the exact and complete code you are executing?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Oct 2012
    Location
    France
    Posts
    29
    Thanks
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Clearing QVariantMap generates a Debug assertion failed

    Yes it is.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Clearing QVariantMap generates a Debug assertion failed

    Can you try it with a precompiled version of Qt instead of one you built yourself?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Oct 2012
    Location
    France
    Posts
    29
    Thanks
    1
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Clearing QVariantMap generates a Debug assertion failed

    Yes I can !

    I downloaded and installed the precompiled library of Qt 4.8.4 for VS2010.
    No error when I try the code above.

    The problem is that having no precompiled libraries of Qt 4.8 for vs2012, I still don't know if my built is faulty or if the vs2012 compiler too severe ...

    Any thoughts...?

Similar Threads

  1. Debug Assertion Failed
    By beethoven07 in forum Newbie
    Replies: 13
    Last Post: 23rd February 2013, 17:09
  2. Replies: 2
    Last Post: 17th December 2010, 08:26
  3. "Debug Assertion failed" in debug mode
    By hed in forum Qt Programming
    Replies: 10
    Last Post: 4th February 2008, 12:10
  4. Debug Assertion Failed
    By ^NyAw^ in forum General Programming
    Replies: 5
    Last Post: 28th December 2007, 11:48
  5. ASSERT(Failed assertion in Qt == Qt bug)
    By 0xBulbizarre in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2006, 19:06

Tags for this Thread

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.