webservices/wsfragment/src/rsendocument.cpp
branchRCL_3
changeset 36 c5fabff9b552
parent 0 62f9d29f7211
child 37 1adb97a15c2f
--- a/webservices/wsfragment/src/rsendocument.cpp	Thu Aug 19 10:59:30 2010 +0300
+++ b/webservices/wsfragment/src/rsendocument.cpp	Tue Aug 31 16:18:26 2010 +0300
@@ -21,8 +21,8 @@
 
 
 #include "RSenDocument.h"
-#include <xmlengxestd.h>
-#include <xmlengdomimplementation.h>
+#include <xml/utils/xmlengxestd.h>
+#include <xml/dom/xmlengdomimplementation.h>
 
 LOCAL_C void CleanupRSenDocument(TAny* aDocumentData)
 	{
@@ -59,12 +59,17 @@
     RXmlEngDocument doc;
     doc.OpenL(domImpl);
     RSenDocument document;
+    CleanupClosePushL(document);
+	document.ipData =  NULL;
+	document.iInternal = NULL;
     document.ipData = new (ELeave) TSenDocumentData;
     document.iInternal =
         (reinterpret_cast<RSenDocument*>(const_cast<RXmlEngDocument*>(&doc)))->iInternal;
     document.ipData->iInternal = document.iInternal;
+	document.ipData->ipOpenDocuments = NULL;
     document.ipData->ipOpenDocuments = new (ELeave) TInt(1);
     document.ipData->iDomImpl = domImpl;
+    CleanupStack::Pop();
     TCleanupItem cleanup(CleanupRSenDocument, document.ipData);
     CleanupStack::PushL(cleanup);
     return document;
@@ -89,12 +94,17 @@
     RXmlEngDocument doc;
     doc.OpenL(domImpl, aInternal);
     RSenDocument document;
+    CleanupClosePushL(document);
+	document.ipData =  NULL;
+	document.iInternal = NULL;	 
     document.ipData = new (ELeave) TSenDocumentData;
     document.iInternal =
         (reinterpret_cast<RSenDocument*>(const_cast<RXmlEngDocument*>(&doc)))->iInternal;
     document.ipData->iInternal = document.iInternal;
+	document.ipData->ipOpenDocuments = NULL;	
     document.ipData->ipOpenDocuments = new (ELeave) TInt(1);
     document.ipData->iDomImpl = domImpl;
+     CleanupStack::Pop();
     TCleanupItem cleanup(CleanupRSenDocument, document.ipData);
     CleanupStack::PushL(cleanup);
     return document;
@@ -108,26 +118,28 @@
 
 EXPORT_C void RSenDocument::Close()
     {
-    *ipData->ipOpenDocuments = *ipData->ipOpenDocuments - 1;
-    if ( !*ipData->ipOpenDocuments )
-        {
-        RXmlEngDOMImplementation domImpl = ipData->iDomImpl;
-        iInternal = ipData->iInternal;
-        delete ipData->ipOpenDocuments;
-        delete ipData;
-        RXmlEngDocument::Close();
-        domImpl.Close();
-    	TBool* pDisabled = (TBool*)Dll::Tls();
-    	if ( !pDisabled )
-    	    {
-            XmlEngineCleanup();
-    	    }
-        }
-    else
-        {
-        iInternal = NULL;
-        }
-       
+	if(ipData && ipData->ipOpenDocuments)
+		{
+	    *ipData->ipOpenDocuments = *ipData->ipOpenDocuments - 1;
+	    if ( !*ipData->ipOpenDocuments )
+	        {
+	        RXmlEngDOMImplementation domImpl = ipData->iDomImpl;
+	        iInternal = ipData->iInternal;
+	        delete ipData->ipOpenDocuments;
+	        delete ipData;
+	        RXmlEngDocument::Close();
+	        domImpl.Close();
+	    	TBool* pDisabled = (TBool*)Dll::Tls();
+	    	if ( !pDisabled )
+	    	    {
+	            XmlEngineCleanup();
+	    	    }
+	        }
+	    else
+	        {
+	        iInternal = NULL;
+	        }
+       }
     }
 
 EXPORT_C void RSenDocument::Destroy()