[QGIS Commit] r10546 - trunk/qgis/src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sun Apr 12 15:31:56 EDT 2009


Author: mhugent
Date: 2009-04-12 15:31:56 -0400 (Sun, 12 Apr 2009)
New Revision: 10546

Modified:
   trunk/qgis/src/core/qgsvectorlayer.cpp
Log:
Save and read provider encoding from project file. Fixes bug #1310

Modified: trunk/qgis/src/core/qgsvectorlayer.cpp
===================================================================
--- trunk/qgis/src/core/qgsvectorlayer.cpp	2009-04-12 17:09:22 UTC (rev 10545)
+++ trunk/qgis/src/core/qgsvectorlayer.cpp	2009-04-12 19:31:56 UTC (rev 10546)
@@ -2116,11 +2116,14 @@
     return false;
   }
 
-  //read provider encoding
-  QDomNode encodingNode = layer_node.namedItem( "encoding" );
-  if ( ! encodingNode.isNull() && mDataProvider )
+  QDomElement pkeyElem = pkeyNode.toElement();
+  if(!pkeyElem.isNull())
   {
-    mDataProvider->setEncoding( encodingNode.toElement().text() );
+    QString encodingString = pkeyElem.attribute("encoding");
+    if(!encodingString.isEmpty())
+    {
+       mDataProvider->setEncoding(encodingString);
+    }
   }
 
   QString errorMsg;
@@ -2252,10 +2255,14 @@
   mapLayerNode.setAttribute( "geometry", QGis::qgisVectorGeometryType[geometryType()] );
 
   // add provider node
-  QDomElement provider  = document.createElement( "provider" );
-  QDomText providerText = document.createTextNode( providerType() );
-  provider.appendChild( providerText );
-  layer_node.appendChild( provider );
+  if(mDataProvider)
+    {
+        QDomElement provider  = document.createElement( "provider" );
+        provider.setAttribute("encoding", mDataProvider->encoding());
+        QDomText providerText = document.createTextNode( providerType() );
+        provider.appendChild( providerText );
+        layer_node.appendChild( provider );
+    }
 
   // renderer specific settings
 



More information about the QGIS-commit mailing list