Some cleanup requirements must be handled by the cleanup code after the trap harness.
Some cleanup requirements must be handled by the cleanup code after the trap harness, on discovering that the leave code is not KErrNone . The cleanup requirements may include:
rolling back changes to restore an object to the state it was in before the function which left was invoked
For instance, a “set font” command might have been issued for some characters in a line, and might fail because of lack of memory: the line should be restored to its previous state.
Rollback is not always easy. Often, it’s simpler to prepare a change that would be guaranteed to work, and apply it if the change was prepared successfully. If a leave occurred in the act of preparing a change, the change can be destroyed. It’s usually easier to destroy a change than to roll it back.
destroying a partially-constructed object
Most requirements for destroying partially-constructed objects will be dealt with by the cleanup stack. There may be a requirement to destroy some partially-constructed objects as part of rollback processing.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License v1.0.