PDA

View Full Version : Qt Creator Why list objects with static members not accessible during debug



p.csakany
26th June 2017, 21:24
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.



#include <iostream>
#include <list>

class Test1
{
public:
static const int NOPOS=-1;
int a;
};

class Test2
{
public:
const int NOPOS=-1;
int a;
};

int main()
{
std::list<Test1> list1;
Test1 t11;
list1.push_back(t11);
Test1 t12;
list1.push_back(t12);

std::list<Test2> list2;
Test2 t21;
list2.push_back(t21);
Test2 t22;
list2.push_back(t22);

return 0;
}

12503

Santosh Reddy
30th June 2017, 05:06
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"

p.csakany
30th June 2017, 08:20
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.

Santosh Reddy
30th June 2017, 11:09
What is the version of Qt Creator, Qt Kit, Compiler and OS you are using?

p.csakany
30th June 2017, 11:57
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

p.csakany
13th July 2017, 10:35
This problem does not come up in the new Creator 4.3.1.