View Full Version : Clearing QVariantMap generates a Debug assertion failed

27th June 2013, 12:19
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.

QVariantList createVariantList(){
QVariantList res;

for (int i = 0; i < 42; ++i){

return res;

int main(int argc, char *argv[]){
QVariantMap map;
QVariantList vList = createVariantList();

/*(1)*/ map["Chev"] = vList;
/*(2)*/ map["Turkish"] = createVariantList();
/*(3)*/ map["Frank"] = QVariantList(createVariantList());

map.clear();// exception "Debug Assertion Failed" thrown if line (2) or/and (3) is/are present

return 0;

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 :

int main(int argc, char *argv[]){
QVariantMap map;

{// Creating block for keeping vList inside scope
QVariantList vList = createVariantList();

map["Lee"] = vList;
}// Automatic vList 'deletion'


map.clear();// exception "Debug Assertion Failed" thrown

return 0;

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 ?

27th June 2013, 13:34
Show us the backtrace.

27th June 2013, 13:48
Hi, and thanks for your answer.

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

QtCored4.dll!v_clear<QList<QVariant> >(QVariant::Private * d, QList<QVariant> * __formal) Line 147 C++
QtCored4.dll!clear(QVariant::Private * d) Line 214 C++
QtCored4.dll!QVariant::~QVariant() Line 1400 C++
VariousTestingd.exe!QVariant::`scalar deleting destructor'(unsigned int) C++
VariousTestingd.exe!QMap<QString,QVariant>::freeData(QMapData * x) Line 653 C++
VariousTestingd.exe!QMap<QString,QVariant>::~QMap<QString,QVariant>() Line 185 C++
VariousTestingd.exe!QMap<QString,QVariant>::clear() Line 447 C++
VariousTestingd.exe!main(int argc, char * * argv) Line 40 C++
VariousTestingd.exe!WinMain(HINSTANCE__ * instance, HINSTANCE__ * prevInstance, char * __formal, int cmdShow) Line 131 C++
VariousTestingd.exe!__tmainCRTStartup() Line 528 C
VariousTestingd.exe!WinMainCRTStartup() Line 377 C
kernel32.dll!75beed6c() Unknown
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
ntdll.dll!774c377b() Unknown
ntdll.dll!774c374e() Unknown

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")

configure -debug-and-release -no-qt3support -no-webkit -nomake demos -nomake examples -nomake tools -platform win32-msvc2012

Thanks in advance for your ideas.

27th June 2013, 13:59
Is the snippet you posted in the previous post the exact and complete code you are executing?

27th June 2013, 14:02
Yes it is.

27th June 2013, 15:31
Can you try it with a precompiled version of Qt instead of one you built yourself?

27th June 2013, 16:05
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...?