Skip to content

Commit daf8fbd

Browse files
author
mhugent
committed
Higher limit for number of layers in WMS project, use hash instead of map in layer cache
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15260 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent ef37b2f commit daf8fbd

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/mapserver/qgsmslayercache.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
#include "qgsvectorlayer.h"
2020
#include "qgsmapserverlogger.h"
2121

22-
#define MAX_N_LAYERS 50
22+
//maximum number of layers in the cache (and upper limit for layers in one published project)
23+
#define MAX_N_LAYERS 100
2324

2425
QgsMSLayerCache* QgsMSLayerCache::mInstance = 0;
2526

@@ -40,7 +41,7 @@ QgsMSLayerCache::QgsMSLayerCache()
4041
QgsMSLayerCache::~QgsMSLayerCache()
4142
{
4243
QgsMSDebugMsg( "removing all entries" );
43-
QMap<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it;
44+
QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it;
4445
for ( it = mEntries.begin(); it != mEntries.end(); ++it )
4546
{
4647
delete it->layerPointer;
@@ -57,7 +58,7 @@ void QgsMSLayerCache::insertLayer( const QString& url, const QString& layerName,
5758
}
5859

5960
QPair<QString, QString> urlLayerPair = qMakePair( url, layerName );
60-
QMap<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.find( urlLayerPair );
61+
QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.find( urlLayerPair );
6162
if ( it != mEntries.end() )
6263
{
6364
delete it->layerPointer;
@@ -76,7 +77,7 @@ void QgsMSLayerCache::insertLayer( const QString& url, const QString& layerName,
7677
QgsMapLayer* QgsMSLayerCache::searchLayer( const QString& url, const QString& layerName )
7778
{
7879
QPair<QString, QString> urlNamePair = qMakePair( url, layerName );
79-
QMap<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.find( urlNamePair );
80+
QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.find( urlNamePair );
8081
if ( it == mEntries.end() )
8182
{
8283
QgsMSDebugMsg( "Layer not found in cache" );
@@ -121,8 +122,8 @@ void QgsMSLayerCache::removeLeastUsedEntry()
121122
return;
122123
}
123124
QgsMSDebugMsg( "removeLeastUsedEntry" );
124-
QMap<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.begin();
125-
QMap<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator lowest_it = it;
125+
QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.begin();
126+
QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator lowest_it = it;
126127
time_t lowest_time = it->lastUsedTime;
127128

128129
for ( ; it != mEntries.end(); ++it )

src/mapserver/qgsmslayercache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#define QGSMSLAYERCACHE_H
2020

2121
#include <time.h>
22-
#include <QMap>
22+
#include <QHash>
2323
#include <QPair>
2424
#include <QString>
2525

@@ -69,7 +69,7 @@ class QgsMSLayerCache
6969
/**Cash entries with pair url/layer name as a key. The layer name is necessary for cases where the same
7070
url is used several time in a request. It ensures that different layer instances are created for different
7171
layer names*/
72-
QMap<QPair<QString, QString>, QgsMSLayerCacheEntry> mEntries;
72+
QHash<QPair<QString, QString>, QgsMSLayerCacheEntry> mEntries;
7373
};
7474

7575
#endif

0 commit comments

Comments
 (0)