[Qt-interest] It works...not sure how (QT state machine object ownership) :)

Mandeep Sandhu mandeepsandhu.chd at gmail.com
Mon May 31 07:50:31 CEST 2010


> Your states are children of the state machine. Your transitions are
> children of your states. What makes you think that this is not the
> case?

I never said they're not children of state machine...I said they are
not children of my "application" (though the statemachine is QObject
child of my app)...so I guess indirectly they are! :)
>
>> Since my app's destructor will be calling QStateMachine's destructor,
>> I'm guessing the QSM will be further doing the state/transtion
>> cleanup. Is it so?
>>
>
> Yes. The documentation on QStateMachine::addState,
> QStateMachine::removeState, QState::addTransition,
> QState::removeTransition are clear enough about ownership: adding an
> object transfers ownership of that object.

Well, it wasn't clear from QStateMachine::addState that the SM is
taking ownership (though QStateMachine::removeState mentions it
explicitly).

I had written this code sometime back and forgot about the ownership
comments. Thanks for pointing them out.
>
> If you are still in doubt, despite the documentation, you could set a
> debugger breakpoint in your state/transition destructor and look at
> the call stack to see where they are being called.

I did that already! I had put debugs in the destructor to see if the
cleanup occurred or not.

Thanks,
-mandeep

>
> --
> HTH,
>
> Stephen Jackson
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>



More information about the Qt-interest-old mailing list