Solved defining the QT_SHAREDPOINTER_TRACK_POINTERS macro
-
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...
-
Hi,
Add
DEFINES += QT_SHAREDPOINTER_TRACK_POINTERS
in your .pro file, then do a full re-build of your application. -
@SGaist : Ofcourse. I did. But where i can see the tracking info.. ?
-
What info are you looking for?
-
@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
-
- There are additional safety checks that are run
- What is the question ?
- What are the limitations ?
-
- Thanks, I understaood
- similar std::shared_ptr::use_count API, Does QSharedPointer has an API, If not how to get reference count for manager object.
- Embedded target which i am working will respond very slow when i try to debug the application
-
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.