The Store framework makes extensive use of the cleanup stack.
Before read streams or write streams are disposed of, for example,
when an RStoreWriteStream
or RStoreReadStream
object
goes out of scope, resources acquired by the stream objects must be
released.
The easiest way to do this is to use the CreateLC()
,
OpenLC()
, AppendLC()
and ReplaceLC()
variants that put a cleanup item onto the cleanup stack.
Before disposing of the read or write stream object, but after any
data is committed, call CleanupStack::PopAndDestroy()
. For
example:
...
TStreamId id = outstream.CreateLC(*store);
...
outstream.CommitL();
...
CleanupStack::PopAndDestroy();
...
For write streams, data must be committed to the stream before releasing resources.
Alternatively, if the CreateL()
, OpenL()
,
AppendL()
and ReplaceL()
variants are used, then an
explicit call to PushL()
must be made to put a cleanup item onto
the cleanup stack. For example:
...
TStreamId id = outstream.CreateL(*store);
outstream.PushL();
...
outstream.CommitL();
...
CleanupStack::PopAndDestroy();
...