Namespaces
Variants
Actions

Archived:Using TCleanupItem

Jump to: navigation, search
Archived.png
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}}.


Article Metadata

Tested with
Devices(s): Nokia N95

Compatibility
Platform(s): S60 3rd Edition, MR

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.
265 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved