bouchebeu
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){
res.append(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'
/*(4)*/
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 ?
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){
res.append(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'
/*(4)*/
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 ?