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.