QObject deleteLater and disconnect



  • Hi,
    I have a hierarchy of QObjects in single thread application. There is one root QObject and all other QObjects are direct or indirect childs of the root. Some of the QObjects' signals and slots are connected between themselves (direct connection). Additionally, in these slots methods of another QObjects (QObjects belonging to the mentioned hierarchy) can be called.

    Is it safe to deleteLater root QObject once I want to clean up? E.g. if there is possibility, that after deleteLater of root QObject some signal of another QObject is invoked and in the connected slot already deleted QObject is manipulated, then I think the app can crash.... but I don't know if it is possible...


  • Qt Champions 2016

    Hi,

    @MartinD said in QObject deleteLater and disconnect:

    Is it safe to deleteLater root QObject once I want to clean up?

    Yes, completely safe.

    E.g. if there is possibility, that after deleteLater of root QObject some signal of another QObject is invoked and in the connected slot already deleted QObject is manipulated, then I think the app can crash.... but I don't know if it is possible...

    It is not. You're in the clear.

    Kind regards.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.