I've some problems with deleting QSA's referred objects. In constructor, I've wrote:
QSProject * project = {initialization of QSProject}
MyWrapper * wrapper = new MyWrapper; // MyWrapper is QObject's child. It comes without parent here
project->addObject(wrapper);
I've wrote in descructor:
project->clearObjects();
delete project;
delete wrapper;
This code cause to segfault at destructor's execution, exactly -- when I'm trying to delete wrapper.
I've made some research and I know that:
- QSProject doesn't delete his "children objects", so this is not a "double delete" problem
- If I don't add wrapper to QSProject in constructor, it works well.
- If I don't delete wrapper in descructor, it works well (but memory leaks).
What's up?
First, I'm not familiar with QSA, but given how the Qt API usually works QSProject is likely taking ownership of the object. This means QSProject is reparenting the object using QObject::setParent().
In which case you are doubly deleting the object.
Have you verified with a tool such as valgrind that you are in fact leaking memory when you omit the delete?