Unsolved QSharedPointer and QML
-
Hello,
I'm porting QWidget library to QQuickItem. Important to note that there are uses of QSharedPointer in library.
I register class to access in qmlqmlRegisterType()
.
Now my problem that I need to create and delete class object quite often and sometimes application crashes of segmentation fault. After following stack trace it leads to class destructor and QSharedPointer.So is QSharedPointer compatible with QML? And what are the solutions to incompatibility?
-
@Eligijus Did I understand correctly that you've got a class which inherits QQuickItem and has a QSharedPointer data member?
What else handles the shared thing and in which way? Can you repeat the bug consistently? Have you debugged the program and the state of the pointer? Have you tried "Optional Pointer Tracking" for the pointer?
Can you show at least the header, possibly the constructor if it does something with the pointer, and the destructor?
-
@Eeli-K said in QSharedPointer and QML:
@Eligijus Did I understand correctly that you've got a class which inherits QQuickItem and has a QSharedPointer data member?
Correct.
What else handles the shared thing and in which way? Can you repeat the bug consistently? Have you debugged the program and the state of the pointer? Have you tried "Optional Pointer Tracking" for the pointer?
Everything QSharedPointer is left for c++ to handle qml doesn't interfere.
I first noticed it when I removed 3 unused random(not shared just int or anything else name type doesn't really matter) pointers from private then it crashed every time and adding them back seems to have fixed it. If I remove 1 unused pointer it crashed maybe from 2nd or 3rd time.Can you show at least the header, possibly the constructor if it does something with the pointer, and the destructor?
I'm porting this library http://www.qcustomplot.com/index.php/download
-
Hi,
It would also be useful if we could take a look at the code you wrote to port that library.
-
@SGaist Sure thing.
My port.
I guess one would be the most intrested in this commit. -
Why not create a new class rather than changing the original QWidget based class ?