[QGIS Commit] r15260 - trunk/qgis/src/mapserver

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Feb 24 16:01:23 EST 2011


Author: mhugent
Date: 2011-02-24 13:01:23 -0800 (Thu, 24 Feb 2011)
New Revision: 15260

Modified:
   trunk/qgis/src/mapserver/qgsmslayercache.cpp
   trunk/qgis/src/mapserver/qgsmslayercache.h
Log:
Higher limit for number of layers in WMS project, use hash instead of map in layer cache

Modified: trunk/qgis/src/mapserver/qgsmslayercache.cpp
===================================================================
--- trunk/qgis/src/mapserver/qgsmslayercache.cpp	2011-02-24 20:32:38 UTC (rev 15259)
+++ trunk/qgis/src/mapserver/qgsmslayercache.cpp	2011-02-24 21:01:23 UTC (rev 15260)
@@ -19,7 +19,8 @@
 #include "qgsvectorlayer.h"
 #include "qgsmapserverlogger.h"
 
-#define MAX_N_LAYERS 50
+//maximum number of layers in the cache (and upper limit for layers in one published project)
+#define MAX_N_LAYERS 100
 
 QgsMSLayerCache* QgsMSLayerCache::mInstance = 0;
 
@@ -40,7 +41,7 @@
 QgsMSLayerCache::~QgsMSLayerCache()
 {
   QgsMSDebugMsg( "removing all entries" );
-  QMap<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it;
+  QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it;
   for ( it = mEntries.begin(); it != mEntries.end(); ++it )
   {
     delete it->layerPointer;
@@ -57,7 +58,7 @@
   }
 
   QPair<QString, QString> urlLayerPair = qMakePair( url, layerName );
-  QMap<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.find( urlLayerPair );
+  QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.find( urlLayerPair );
   if ( it != mEntries.end() )
   {
     delete it->layerPointer;
@@ -76,7 +77,7 @@
 QgsMapLayer* QgsMSLayerCache::searchLayer( const QString& url, const QString& layerName )
 {
   QPair<QString, QString> urlNamePair = qMakePair( url, layerName );
-  QMap<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.find( urlNamePair );
+  QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.find( urlNamePair );
   if ( it == mEntries.end() )
   {
     QgsMSDebugMsg( "Layer not found in cache" );
@@ -121,8 +122,8 @@
     return;
   }
   QgsMSDebugMsg( "removeLeastUsedEntry" );
-  QMap<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.begin();
-  QMap<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator lowest_it = it;
+  QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.begin();
+  QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator lowest_it = it;
   time_t lowest_time = it->lastUsedTime;
 
   for ( ; it != mEntries.end(); ++it )

Modified: trunk/qgis/src/mapserver/qgsmslayercache.h
===================================================================
--- trunk/qgis/src/mapserver/qgsmslayercache.h	2011-02-24 20:32:38 UTC (rev 15259)
+++ trunk/qgis/src/mapserver/qgsmslayercache.h	2011-02-24 21:01:23 UTC (rev 15260)
@@ -19,7 +19,7 @@
 #define QGSMSLAYERCACHE_H
 
 #include <time.h>
-#include <QMap>
+#include <QHash>
 #include <QPair>
 #include <QString>
 
@@ -69,7 +69,7 @@
     /**Cash entries with pair url/layer name as a key. The layer name is necessary for cases where the same
       url is used several time in a request. It ensures that different layer instances are created for different
       layer names*/
-    QMap<QPair<QString, QString>, QgsMSLayerCacheEntry> mEntries;
+    QHash<QPair<QString, QString>, QgsMSLayerCacheEntry> mEntries;
 };
 
 #endif



More information about the QGIS-commit mailing list