Results 1 to 6 of 6

Thread: Why list objects with static members not accessible during debug

  1. #1
    Join Date
    Oct 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Why list objects with static members not accessible during debug

    I have been struggling to debug a large code using std::list extensively. It seems that objects in a list are not accessible in the debugger using Creator if they contain a static member. I tried various version including the latest 4.3.0.

    I managed to distil the problem to the below example. As shown in the attached image, objects of Test1 are labelled <not accessible>, whilst Test2 are fine inside the list. Objects outside of the list are accessible independently from having a static member or not.

    Any help would be greatly appreciated.

    Qt Code:
    1. #include <iostream>
    2. #include <list>
    3.  
    4. class Test1
    5. {
    6. public:
    7. static const int NOPOS=-1;
    8. int a;
    9. };
    10.  
    11. class Test2
    12. {
    13. public:
    14. const int NOPOS=-1;
    15. int a;
    16. };
    17.  
    18. int main()
    19. {
    20. std::list<Test1> list1;
    21. Test1 t11;
    22. list1.push_back(t11);
    23. Test1 t12;
    24. list1.push_back(t12);
    25.  
    26. std::list<Test2> list2;
    27. Test2 t21;
    28. list2.push_back(t21);
    29. Test2 t22;
    30. list2.push_back(t22);
    31.  
    32. return 0;
    33. }
    To copy to clipboard, switch view to plain text mode 

    debug.jpg

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Why list objects with static members not accessible during debug

    If the break point is the context of the class having the static member variables, then the static member variables are shown under "[static]" in Auto/Local variables view, else you will have to add them as Expression in the watch window right click -> "Add New Expression"
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Oct 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why list objects with static members not accessible during debug

    The issue is not that the static member is not visible, but that none of the members are visible as shown in the attached image. In case if a single object it would be a work around to add the individual members separately as en expression to watch. However individual objects are correctly displayed. It is when the object is added to a list and has a static member then none of their members are visible. Adding every member of ever object in a list as an expression is not really a solution. think about if you have 2 or 3 lists holding 10 object each with 2 or 3 member per object. It is doable but you need to do it again at another part of the code.

    I really wonder if it is a bug or something to do with extending debug helpers.

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Why list objects with static members not accessible during debug

    What is the version of Qt Creator, Qt Kit, Compiler and OS you are using?
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  5. #5
    Join Date
    Oct 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why list objects with static members not accessible during debug

    Creator is 4.3.0 right now, but had the same issue with the earlier versions on various machines. I tested the issue with Qt5.3.1 as well as the latest Qt5.9.1, The compilers respectively MinGW 4.8.2 and 5.3.0. I had the same result on both Win10 and win7

  6. #6
    Join Date
    Oct 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why list objects with static members not accessible during debug

    This problem does not come up in the new Creator 4.3.1.

Similar Threads

  1. Replies: 1
    Last Post: 29th June 2013, 17:23
  2. Qt Creator Cannot see members of QNetworkRequest class in debug mode
    By eser in forum Qt Tools
    Replies: 0
    Last Post: 29th June 2013, 11:01
  3. Globally accessible objects in threads
    By Cruz in forum Qt Programming
    Replies: 13
    Last Post: 21st June 2011, 16:55
  4. static class members
    By space_otter in forum General Programming
    Replies: 3
    Last Post: 11th March 2010, 01:07
  5. Objects and members
    By mickey in forum General Programming
    Replies: 8
    Last Post: 1st February 2006, 01:13

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.