Archived:Using TCleanupItem
Archived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.
Contents |
Overview
This code snippet specifies a custom cleanup method for the RImageTypeDescriptionArray. This way it is possible to simply call CleanupStack::PopAndDestroy() in that method on the array and do whatever additional cleanup is needed there.
In this case ResetAndDestroy() is called on the array to release resources consumed by it. In general, creating a custom cleanup method allows the cleanup to be more sophisticated than simply deleting objects, for example, releasing access to a shared resource.
MMP file
The following capabilities and libraries are required:
CAPABILITY None
LIBRARY imageconversion.lib
Header
#include <imageconversion.h>Source
void CleanupRArray( TAny* object )
{
((RImageTypeDescriptionArray*)object)->ResetAndDestroy();
}
RImageTypeDescriptionArray imageTypes;
// Create a custom cleanup item and specify CleanupRArray to be the
// method that is called once CleanupStack::PopAndDestroy() is called
CleanupStack::PushL( TCleanupItem(CleanupRArray, &imageTypes) );
// Here is some code that can leave
// ...
// This will lead to a call to CleanupRArray, the custom cleanup method.
CleanupStack::PopAndDestroy(&imageTypes);


(no comments yet)