src/hbcore/devicedialogbase/hbsymbianvariantconverter.cpp
changeset 34 ed14f46c0e55
parent 0 16d8024aca5e
--- a/src/hbcore/devicedialogbase/hbsymbianvariantconverter.cpp	Mon Oct 04 17:49:30 2010 +0300
+++ b/src/hbcore/devicedialogbase/hbsymbianvariantconverter.cpp	Mon Oct 18 18:23:13 2010 +0300
@@ -30,6 +30,8 @@
 #include "hbsymbianvariantconverter_p.h"
 #include "hbsymbianvariant.h"
 
+_LIT(KPanicDeviceDialogNotSupportedType, "CHbDeviceDialog: Not supported type");
+
 void HbSymbianVariantConverter::toQtVariant(const CHbSymbianVariant* source, 
                                             QVariant& result )
 {
@@ -104,7 +106,7 @@
         {
             CDesC16ArrayFlat* srcArray = source->Value<CDesC16ArrayFlat>();
             QStringList stringList;
-            for(TInt i = 0; i < srcArray->MdcaCount(); i++) {
+            for (TInt i = 0; i < srcArray->MdcaCount(); ++i) {
                 stringList.append(QString::fromUtf16(srcArray->MdcaPoint(i).Ptr(), srcArray->MdcaPoint(i).Length()));
             }
             result.setValue(stringList);
@@ -130,7 +132,7 @@
                                                QVariantMap& aQvMap)
 {
     MDesCArray& keys = aSymbianVariantMap.Keys();
-    for(TInt i = 0; i < keys.MdcaCount() ; i++) {
+    for (TInt i = 0; i < keys.MdcaCount() ; ++i) {
         TPtrC ptr = keys.MdcaPoint(i);
         QString key = QString::fromUtf16(ptr.Ptr(), ptr.Length());
         QVariant variant;
@@ -209,15 +211,16 @@
         {
             QStringList stringList = aVariant.value<QStringList>();
             QStringList::iterator i;
-            CPtrCArray* descriptorArray = 0;
+            CPtrCArray* descriptorArray = new (ELeave) CPtrCArray(stringList.count());
+            CleanupStack::PushL(descriptorArray);
             for (i = stringList.begin(); i != stringList.end(); ++i) {
-            descriptorArray = new CPtrCArray(stringList.count());
                 TPtrC listItem(static_cast<const TUint16*>((*i).utf16()),
                         (*i).length());
                 descriptorArray->AppendL(listItem);
             }
             MDesCArray* arrayInterface = static_cast<MDesCArray*>(descriptorArray);
             return_value = CHbSymbianVariant::NewL(arrayInterface, CHbSymbianVariant::EDesArray);
+            CleanupStack::PopAndDestroy(descriptorArray);
         }
         break;
         case QVariant::UInt:
@@ -234,7 +237,7 @@
         break;
         default:
         {
-            User::Panic(_L("CHbDeviceDialog: Not supported type"), aVariant.type());
+            User::Panic(KPanicDeviceDialogNotSupportedType, aVariant.type());
         }
         break;
     }
@@ -244,6 +247,7 @@
 CHbSymbianVariantMap *HbSymbianVariantConverter::fromQVariantMapL(QVariantMap& aQvMap)
 {
     CHbSymbianVariantMap* map = CHbSymbianVariantMap::NewL();
+    CleanupStack::PushL(map);
     QVariantMap::const_iterator i;
     for (i = aQvMap.constBegin(); i != aQvMap.constEnd(); ++i){
       QString keyString = i.key();
@@ -253,6 +257,7 @@
       CHbSymbianVariant* symbianVariant = fromQtVariantL(value);
       map->Add(descriptor, symbianVariant);
     }
+    CleanupStack::Pop(map);
     return map;
 }