QtCreator debugger whats happened?
-
@jsulm, please explain why this is an issue?
I have a linked list with a static member that points to the head of the list, the linked list is derived from QObject as it uses signals and slots.
If this is the real issue then it's a serious limitation.
-
@Simon-Platten Why do you have a STATIC member which points to the head of the list? What happens if you create more than one instance on that list? To which head of the list will that static member point?
Example:MyList list1; list1.append(...); ... MyList list2; list2.appen(...); ... list1.head <- To which lists head does it point if "head" is static?
If this static member is a pointer then there is no issue with QApplication instance. But I don't get why this member is static.
-
@jsulm, there will only ever be one list of this type in the application. The head of the list is a static pointer, simply because all instances of that class will get the same head pointer, if it isn't static, how else would they get it? The alternative is for every node to traverse the list everytime to find the head. There are over a hundred nodes in the list...
-
@Simon-Platten said in QtCreator debugger whats happened?:
there will only ever be one list of this type in the application. The head of the list is a static pointer, simply because all instances of that class will get the same head poi
I don't get it: you say you will have only one instance ("there will only ever be one list of this type in the application") and then you say: "simply because all instances of that class". So, how many instances are you going to have? And even if there will be only one instance there is no reason to have head as static.
Each instance can simply have its own head pointer (not static):template<typename T> class MyList { private: struct Node { T data; Node* next; }; Node* first; // This is actually the pointer to the head };
-
@jsulm, in your example this means that every node has its own 'first' pointer, where as a static 'first' would be common to all nodes of that type without having to maintain it for every instance, just the static 'first' would be modified. This is not a very elegant solution. This is exactly the sort of thing that static members are intended for.
To clarify, I have a single class that is used for the nodes and the linked list, there is only one instance of this linked list in the application. There are well over 100 nodes in the linked list.
Can you explain why using statics would cause the debugger to behave this way?
-
@Simon-Platten Not every node but every list has its own pointer to the first element in the list.
Maybe we are talking about different things? What do you mean if you say "node"? Don't you mean "list"? Node is actually one entry in a list/tree.
MyList - a class representing a list.
Node - an entry in the list (contains a data field and pointer to next node).
head - points to the first node in the list.
Maybe I just don't understand your use case and you really want all MyList instances to handle exactly same data (in this case a static head pointer is the way to go).
I don't know whether this static is the problem with the debugger - that was just an assumption. -
@jsulm, In my code the list and the node are one in the same, thats why I have a static pointer to head. Every node has access to the head of the list, I don't need another structure or class to define the list, because the list and the nodes share the same class.
Simply example:
class clsNode { private: static clsNode* mpobjHead; clsNode* mpobjNext; /* other members... for the node instance */ public: clsNode(); static clsNode* pobjGetHead() { return mpobjHead; } clsNode* pobjGetNext() { return mpobjNext; } };
-
Hi,
Since you are using Qt and you are implementing a linked list, why not use QLinkedList ?
-
@SGaist , Thank you, I'm pretty sure that the implementation of my linked list is ok, as this application is working fine without problems and the linked list has been established for over a year now....its just the debugger which is not behaving well...pointers and 'this' not showing correctly, in every other aspect the application and debugger is ok....so frustrating.
-
I'm still no further forward in finding a reason why the debugger has stopped working properly, its very annoying and seems to be something in my code that has broken the debugger, but how can anything in the code being debugged break the debugger?
-
I don't think this is a problem in your code... I have almost the same problem since I upgraded to Qt Creator 4.2.1 with Desktop Qt 5.7.1 MSVC2015_64bit.
I can't access "this" pointer whichever the class, and one time out of two (and even more) I also can't access member object/variable...
So annoying when it come to debug the code... I have to "qDebug" everything...
Hope someone will find what's wrong...
(PS. I don't have any static variable/object, so IT AIN'T THE PROBLEM)
-
@OlivierDuguay, thank you for posting, nice to know I'm not the only one experiencing this, now how do we escalate this issue so someone at Qt investigates the problem?
-
@Simon-Platten You can file a bug report if there isn't one already (https://bugreports.qt.io/secure/Dashboard.jspa)
-
@jsulm, thank you, I'll do it now.
-
Can you share the link to the report ? That will make it easier to find.
-
-
Better, but not completely fixed, visit https://bugreports.qt.io/browse/QTCREATORBUG-18030 for solution.