Unhandled exception at QMap



  • Greeting

    Im using QT 4.8.5 With Visual Studio 2008. I use QT Webkit in my project. In some functions i need to pass Java Script Object into C++ and vise versa. So i stringify Java Script's Object to JSON and pass them as QString into C++ and C++ make JSON and in Java Script i parse them to Java Script Object. Since QtJSON is not provided in QT 4.8.5 i downloaded Qt Json in order to handle it. This library get QString and will parse it QVariantMap. This library working fine but in 1 case when ever i want to return from function i get unhandled exception. This happens when there is QVariantMap inside another QVariantMap. (In Java Script there is Object within another Object)

    I checked where exactly it happens and it happens in the following code in QMap.

    #if defined(_MSC_VER)
    #pragma warning(push)
    #pragma warning(disable:4189)
    #endif
    template <class Key, class T>
    Q_OUTOFLINE_TEMPLATE void QMap<Key, T>::freeData(QMapData *x)
    {
        if (QTypeInfo<Key>::isComplex || QTypeInfo<T>::isComplex) {
            QMapData *cur = x;
            QMapData *next = cur->forward[0];
            while (next != x) {
                cur = next;
                next = cur->forward[0];
                Node *concreteNode = concrete(reinterpret_cast<QMapData::Node *>(cur));
                concreteNode->key.~Key();
                concreteNode->value.~T();            <<< This Line !!!
            }
        }
        x->continueFreeData(payload());
    }
    #if defined(_MSC_VER)
    #pragma warning(pop)
    #endif
    

    Whats wrong here ?

    Thanks in advance


  • Qt Champions 2016

    @Meysam-Hashemi
    Hello,
    Don't jump the gun, QMap has been quite thoroughly tested and I, for one, have never ever found anything wrong with it for years.

    concreteNode->key.~Key();
    concreteNode->value.~T(); <<< This Line !!!

    If I were to guess QMap makes some in-place allocations and these lines are just the cleanup. What is your code that triggers this error?

    Kind regards.



  • As i mentioned , My code use this library. I believe what cause this exception is inside the library, I'm checking it to find out !!!


  • Qt Champions 2016

    @Meysam-Hashemi
    Hello,
    Right, but I have not used that library and there might be a bug in it. In any case, you should try and debug the code that uses the aforementioned library first, then the library itself and only then think about a bug in Qt. My advice is, since you've already found the end-point of the stack where the problem occurs, to go about the stack trace and look up in the debugger what is called where/when with what arguments. As you've put your original question, unfortunately, I'm very doubtful anyone can provide adequate assistance. Please try to find the relevant code in the library itself and in your application, so we have a more complete information on the issue.

    Kind regards.



  • @kshegunov

    Will do, Thanks alot


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.