Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting QObject? #2

Open
HamedMasafi opened this issue Dec 7, 2018 · 2 comments
Open

Deleting QObject? #2

HamedMasafi opened this issue Dec 7, 2018 · 2 comments

Comments

@HamedMasafi
Copy link

Why you are deleting object that inherited from QObject??
https://github.com/soroush/Qtz/blob/94ac5ed435cbaeff90c359fabc9c65c62c6716f2/qtz/core/qtz-single-core-application.cpp#L428

@soroush
Copy link
Owner

soroush commented Dec 9, 2018

Because it has no parent, and failure to manually delete it will lead us to memory leak.

@HamedMasafi
Copy link
Author

It can have a parent if the QObject's constructor is called on this line
https://github.com/soroush/Qtz/blob/94ac5ed435cbaeff90c359fabc9c65c62c6716f2/qtz/core/qtz-single-core-application.cpp#L50

And about deleting QObjects, from qdoc:

You must not delete the QObject directly if it exists in a different thread than the one currently executing. Use deleteLater() instead, which will cause the event loop to delete the object after all pending events have been delivered to it.

http://doc.qt.io/qt-5/qobject.html#dtor.QObject

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants