×
Namespaces

Variants
Actions

Archived:Using TCleanupItem

From Nokia Developer Wiki
Jump to: navigation, search

Archived.pngArchived: 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}}.


Article Metadata
Tested with
Devices(s): Nokia N95
Compatibility
Platform(s): S60 3rd Edition, MR
S60 3rd Edition (initial release)
Article
Keywords: TCleanupItem, CleanupStack, RImageTypeDescriptionArray
Created: tepaa (22 May 2008)
Last edited: lpvalente (03 Sep 2012)

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);
This page was last modified on 3 September 2012, at 00:43.
48 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×