[mapguide-commits] r5382 - trunk/MgDev/Server/src/Services/Feature

svn_mapguide at osgeo.org svn_mapguide at osgeo.org
Tue Nov 9 17:57:50 EST 2010


Author: brucedechant
Date: 2010-11-09 14:57:50 -0800 (Tue, 09 Nov 2010)
New Revision: 5382

Modified:
   trunk/MgDev/Server/src/Services/Feature/FdoFeatureReader.cpp
   trunk/MgDev/Server/src/Services/Feature/FdoFeatureReader.h
Log:
Fixed an error where SQLite feature source can not be previewed.

Notes:
- MgFdoFeatureReader class does not use the FDO API in a correct manner, calling ReadNext  
  even in a previous call ReadNext returned false. This makes the sqlite engine to  
  move again to the first row creating an infinite loop. 
  Also in MgFdoFeatureReader ReadNext somehow compiler optimized the code making  
  ReadNext to be called multiple times. Fixed by avoid calling ReadNext() after  
  reader(s) were depleted using a flag for it. 

Submitted on behalf of Romica Dascalescu


Modified: trunk/MgDev/Server/src/Services/Feature/FdoFeatureReader.cpp
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/FdoFeatureReader.cpp	2010-11-09 21:49:53 UTC (rev 5381)
+++ trunk/MgDev/Server/src/Services/Feature/FdoFeatureReader.cpp	2010-11-09 22:57:50 UTC (rev 5382)
@@ -28,11 +28,13 @@
 // Class MgFdoFeatureReader
 MgFdoFeatureReader::MgFdoFeatureReader() : m_currentReaderId(-1)
 {
+    m_readerDepleted = false;
     m_readerCollection = MgFdoReaderCollection::Create();
 }
 
 MgFdoFeatureReader::MgFdoFeatureReader(MgFdoReaderCollection *readerCollection) : m_currentReaderId(-1)
 {
+    m_readerDepleted = false;
     m_readerCollection = FDO_SAFE_ADDREF(readerCollection);
 }
 
@@ -421,35 +423,25 @@
 
 bool MgFdoFeatureReader::ReadNext( )
 {
-   bool retVal = false;
+    if (m_readerDepleted)
+        return false;
+
    if (m_currentReader == NULL)
-   {
        Initialize();
-   }
 
    if (m_currentReader->ReadNext())
-   {
-        retVal = true;
-   }
-   else
-   {
-       m_currentReaderId++;
-       if (m_readerCollection->GetCount() > m_currentReaderId)
-       {
-           m_currentReader = (FdoIFeatureReader*)m_readerCollection->GetItem(m_currentReaderId);
-           if (m_currentReader == NULL)
-           {
-               retVal = false;
-           }
-           else
-           {
-                retVal = m_currentReader->ReadNext();
-           }
-       }
-   }
+       return true;
 
-   return retVal;
+   m_currentReader = NULL;
+   m_currentReaderId++;
+   if ((m_readerCollection->GetCount() > m_currentReaderId))
+       m_currentReader = static_cast<FdoIFeatureReader*>(m_readerCollection->GetItem(m_currentReaderId));
 
+   if (m_currentReader != NULL)
+       return this->ReadNext();
+
+   m_readerDepleted = true;
+   return false;
 }
 
 void MgFdoFeatureReader::Close( )

Modified: trunk/MgDev/Server/src/Services/Feature/FdoFeatureReader.h
===================================================================
--- trunk/MgDev/Server/src/Services/Feature/FdoFeatureReader.h	2010-11-09 21:49:53 UTC (rev 5381)
+++ trunk/MgDev/Server/src/Services/Feature/FdoFeatureReader.h	2010-11-09 22:57:50 UTC (rev 5382)
@@ -92,6 +92,7 @@
     FdoPtr<MgFdoReaderCollection> m_readerCollection;
     FdoPtr<FdoIFeatureReader> m_currentReader;
     FdoInt32 m_currentReaderId;
+    FdoBoolean m_readerDepleted;
     void Initialize();
 
 };



More information about the mapguide-commits mailing list