Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Unsolved Unhandled exception at QMap

    General and Desktop
    2
    5
    1164
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Meysam Hashemi last edited by Meysam Hashemi

      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

      1 Reply Last reply Reply Quote 0
      • kshegunov
        kshegunov Moderators last edited by kshegunov

        @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.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply Reply Quote 0
        • M
          Meysam Hashemi last edited by

          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 !!!

          kshegunov 1 Reply Last reply Reply Quote 0
          • kshegunov
            kshegunov Moderators @Meysam Hashemi last edited by

            @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.

            Read and abide by the Qt Code of Conduct

            M 1 Reply Last reply Reply Quote 0
            • M
              Meysam Hashemi @kshegunov last edited by

              @kshegunov

              Will do, Thanks alot

              1 Reply Last reply Reply Quote 0
              • First post
                Last post