RPointerArray<CStuff> array=new (ELeave) RPointerArray<CStuff>(count);
create and insert stuff into array
The contents of the method can Leave, and it will also leave the array on the stack (since it will ALWAYS be used after a call to the function). The problem i am having is what happens if a leave occurs. CleanupClosePushL will only call Close() on the array, right? so how do the objects contained in the array get deleted? have i missed something?
This seems to be an omisssion in the general areas of the close functions. If you look in MMFControllerPluginResolver.h there is an implementation of CleanupResetAndDestroyPushL which is what you should be using
I would be careful with this approach as the Close will free the underlying pointer array and then the destructor will reset and destroy an empty array, which means leaks.
I suggest you simulate a leave by User::Leave(KErrGeneral) and verify that all the pointers are in fact cleaned up.
Also, looking at the code I am not sure why it is not compiling, though i put this down to typing errors, array is pointer to an RPointerArray, not an RPointerArray.
I'm new to this symbian stuff, so previously I was fighting with the SDK over which kind of array to use. I'm now deriving my class from CArrayPtrSeg, so there is no Close to mess things up (fingers crossed that nothing else messes it up ). I just have to make sure I delete it when I've finished.