Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Unhandled exception at QMap
Forum Update on Monday, May 27th 2025

Unhandled exception at QMap

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 1.5k Views
  • 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 Offline
    M Offline
    Meysam Hashemi
    wrote on 31 Jan 2016, 09:44 last edited by Meysam Hashemi
    #1

    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
    0
    • K Offline
      K Offline
      kshegunov
      Moderators
      wrote on 31 Jan 2016, 12:51 last edited by kshegunov
      #2

      @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
      0
      • M Offline
        M Offline
        Meysam Hashemi
        wrote on 31 Jan 2016, 13:19 last edited by
        #3

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

        K 1 Reply Last reply 31 Jan 2016, 13:28
        0
        • M Meysam Hashemi
          31 Jan 2016, 13:19

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

          K Offline
          K Offline
          kshegunov
          Moderators
          wrote on 31 Jan 2016, 13:28 last edited by
          #4

          @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 31 Jan 2016, 13:54
          0
          • K kshegunov
            31 Jan 2016, 13:28

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

            M Offline
            M Offline
            Meysam Hashemi
            wrote on 31 Jan 2016, 13:54 last edited by
            #5

            @kshegunov

            Will do, Thanks alot

            1 Reply Last reply
            0

            1/5

            31 Jan 2016, 09:44

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved