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. defining the QT_SHAREDPOINTER_TRACK_POINTERS macro
Forum Updated to NodeBB v4.3 + New Features

defining the QT_SHAREDPOINTER_TRACK_POINTERS macro

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 2 Posters 2.3k Views 1 Watching
  • 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.
  • DonCoderD Offline
    DonCoderD Offline
    DonCoder
    wrote on last edited by
    #1

    http://doc.qt.io/qt-5/qsharedpointer.html

    "Optional Pointer Tracking

    A feature of QSharedPointer that can be enabled at compile-time for debugging purposes is a pointer tracking mechanism. When enabled, QSharedPointer registers in a global set all the pointers that it tracks. This allows one to catch mistakes like assigning the same pointer to two QSharedPointer objects.

    This function is enabled by defining the QT_SHAREDPOINTER_TRACK_POINTERS macro before including the QSharedPointer header."

    I need to understand how this works. Some example would help...

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Add DEFINES += QT_SHAREDPOINTER_TRACK_POINTERS in your .pro file, then do a full re-build of your application.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • DonCoderD Offline
        DonCoderD Offline
        DonCoder
        wrote on last edited by DonCoder
        #3

        @SGaist : Ofcourse. I did. But where i can see the tracking info.. ?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          What info are you looking for?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • DonCoderD Offline
            DonCoderD Offline
            DonCoder
            wrote on last edited by
            #5

            @SGaist : QSharedPointer does not have an API for displaying ref_count. SO i have seen documentation and found that QT_SHAREDPOINTER_TRACK_POINTERS provide tracking info.

            Q1) What makes the difference when i add DEFINES += QT_SHAREDPOINTER_TRACK_POINTERS in .pro file

            Q2) My intention here is to track all the QSharedPointer and QWeakPintesr which are pointing object to ensure that by the time i exit none of the holding ref count. So the object will get destroyed.

            Q3) i guess may be debugging may help me, but i can not use debugger on the embedded target i am using as i have some limitations

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6
              1. There are additional safety checks that are run
              2. What is the question ?
              3. What are the limitations ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • DonCoderD Offline
                DonCoderD Offline
                DonCoder
                wrote on last edited by
                #7
                1. Thanks, I understaood
                2. similar std::shared_ptr::use_count API, Does QSharedPointer has an API, If not how to get reference count for manager object.
                3. Embedded target which i am working will respond very slow when i try to debug the application
                1 Reply Last reply
                0
                • DonCoderD Offline
                  DonCoderD Offline
                  DonCoder
                  wrote on last edited by
                  #8

                  I fiugured it out in this way...

                  QT_SHAREDPOINTER_TRACK_POINTERS only provides a special check to ensure the ownership organized propery.
                  There is no external API to display reference count of managed object. May Be debugging can help.

                  1 Reply Last reply
                  0

                  • Login

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