Unsolved Strange crash with QPointers in a container
-
It's even stranger than I thought:
having this is allowed:
QPointer<BaseTOP> a; QPointer<BaseTOP> b; QPointer<BaseTOP> c; QPointer<BaseTOP> d; QPointer<BaseTOP> e;
But this is not:
std::array<QPointer<BaseTOP>, 4> test;
What is going on here?
-
-
@Pl45m4
I have a single threaded application, i create the objects in QGraphhicsView's mouseDoubleClickEvent function. Nothing strange i can think of ... -
Still no answer where exactly it is crashing and what's the code where it is crashing + backtrace....
-
@aart said in Strange crash with QPointers in a container:
This is where it goes wrong:
class SomeClass : public QObject{
Q_OBJECT
public:
...
protected:
QVector<QPointer<SomeClass>> test{ 3 };
}I dont think that this is the part of your code where it crashes :)
Where do you push the objects in your vector? Where do you try to access them / use the pointers?
Without any code, nobody can help you.@aart said in Strange crash with QPointers in a container:
QVector<QPointer<SomeClass>> test{ 3 };
This doesnt look wrong (QVector, Lenght 3, with QPointers to SomeClass-object)
-
@Christian-Ehrlicher The thing is that it doesnt actaully crash but just gets stuck and stops responding, I cant really post all the code here because that would be way too much. Is there any way i can get some sort of error log that people can get information out of?
-
Use a debugger to see where it hangs. I don't see why it should 'hang' because of a pointer in a vector.
-
Hi
I tried your SomeClass in a small project but nothing happened.
Im not really sure its related to QPointer as there is no reason why it should
do odd stuff. Code seems pretty normal.Do you have s small sample that will produce the "odd part" ?
-
@Christian-Ehrlicher
Okay so using the debugger i found where the problem lays. I'm very new to qt and qt creator, so i didnt understand how to use the debugger :p The issue was indeed not in the class with the vector but elsewhere in the code where i was using the data stored in the vector. Thanks for the help everyone. The thread can be closed. -
@aart said in Strange crash with QPointers in a container:
The thread can be closed.
This can be done by you by editing the first post and setting it to resolved. :)
-
@Christian-Ehrlicher said in Strange crash with QPointers in a container:
@aart said in Strange crash with QPointers in a container:
The thread can be closed.
This can be done by you by editing the first post and setting it to resolved. :)
No, just use the button Topic Tools. There is an entry Mark as Resolved.