• May 09, 2024, 12:29:06 pm

Author Topic: Using a "R" class  (Read 1554 times)

0 Members and 1 Guest are viewing this topic.

Offline huellif

  • Developer
  • Christmas Santa
  • ****
  • Posts: 402
  • Reputation: 212
Using a "R" class
« on: November 02, 2013, 09:05:07 pm »
Symbian classes which start with an R (e.g. RFs, RAknKeyLock, REikAppUiSession etc.) aren't safe.
=> This means you have to make them save by yourself to catch all exceptions.

The safe way for objects:

Code: [Select]
RClass object;
CleanupClosePushL(object);
User::LeaveIfError(object.Connect());
//your code here [...]
CleanupStack::PopAndDestroy(&object);


The safe way for object pointers:

Code: [Select]
RClass* object =  RClass::NewLC();
User::LeaveIfError(object.Connect());
CleanupStack::PopAndDestroy(object);
(NewLC creates the object and pushes it on CleanupStack)

PopAndDestroy does close the connection to the server (from object.Connect()) automatically.

doing this without of exception handling can cause memory leaks and crash your app

Thanks Il.Socio for your help :)