Skip to content

Commit fa8c9ba

Browse files
committedMay 11, 2012
Empty config file entry in layer cache for sld layers
1 parent 0971879 commit fa8c9ba

File tree

5 files changed

+29
-22
lines changed

5 files changed

+29
-22
lines changed
 

‎src/mapserver/qgshostedrdsbuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ QgsMapLayer* QgsHostedRDSBuilder::createMapLayer( const QDomElement& elem,
6767
rl = new QgsRasterLayer( uri, layerNameFromUri( uri ) );
6868
if ( allowCaching )
6969
{
70-
QgsMSLayerCache::instance()->insertLayer( uri, layerName, rl, "" /*todo: add project file path*/ );
70+
QgsMSLayerCache::instance()->insertLayer( uri, layerName, rl );
7171
}
7272
else
7373
{

‎src/mapserver/qgshostedvdsbuilder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ QgsMapLayer* QgsHostedVDSBuilder::createMapLayer( const QDomElement& elem,
7575

7676
if ( allowCaching )
7777
{
78-
QgsMSLayerCache::instance()->insertLayer( uri, layerName, ml, "" /*todo: add project file path*/ );
78+
QgsMSLayerCache::instance()->insertLayer( uri, layerName, ml );
7979
}
8080
else
8181
{

‎src/mapserver/qgsmslayercache.cpp

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,18 @@ void QgsMSLayerCache::insertLayer( const QString& url, const QString& layerName,
7575
mEntries.insert( urlLayerPair, newEntry );
7676

7777
//update config file map
78-
QHash< QString, int >::iterator configIt = mConfigFiles.find( configFile );
79-
if ( configIt == mConfigFiles.end() )
78+
if ( !configFile.isEmpty() )
8079
{
81-
mConfigFiles.insert( configFile, 1 );
82-
mFileSystemWatcher.addPath( configFile );
83-
}
84-
else
85-
{
86-
mConfigFiles[configFile] = configIt.value() + 1; //increment reference counter
80+
QHash< QString, int >::iterator configIt = mConfigFiles.find( configFile );
81+
if ( configIt == mConfigFiles.end() )
82+
{
83+
mConfigFiles.insert( configFile, 1 );
84+
mFileSystemWatcher.addPath( configFile );
85+
}
86+
else
87+
{
88+
mConfigFiles[configFile] = configIt.value() + 1; //increment reference counter
89+
}
8790
}
8891
}
8992

@@ -190,14 +193,17 @@ void QgsMSLayerCache::freeEntryRessources( QgsMSLayerCacheEntry& entry )
190193
}
191194

192195
//counter
193-
int configFileCount = mConfigFiles[entry.configFile];
194-
if ( configFileCount < 2 )
196+
if ( !entry.configFile.isEmpty() )
195197
{
196-
mConfigFiles.remove( entry.configFile );
197-
mFileSystemWatcher.removePath( entry.configFile );
198-
}
199-
else
200-
{
201-
mConfigFiles[entry.configFile] = configFileCount - 1;
198+
int configFileCount = mConfigFiles[entry.configFile];
199+
if ( configFileCount < 2 )
200+
{
201+
mConfigFiles.remove( entry.configFile );
202+
mFileSystemWatcher.removePath( entry.configFile );
203+
}
204+
else
205+
{
206+
mConfigFiles[entry.configFile] = configFileCount - 1;
207+
}
202208
}
203209
}

‎src/mapserver/qgsmslayercache.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ class QgsMSLayerCache: public QObject
4848
/**Inserts a new layer into the cash
4949
@param url the layer datasource
5050
@param layerName the layer name (to distinguish between different layers in a request using the same datasource
51+
@param configFile path of the config file (to invalidate entries if file changes). Can be empty (e.g. layers from sld)
5152
@param tempFiles some layers have temporary files. The cash makes sure they are removed when removing the layer from the cash*/
52-
void insertLayer( const QString& url, const QString& layerName, QgsMapLayer* layer, const QString& configFile, const QList<QString>& tempFiles = QList<QString>() );
53+
void insertLayer( const QString& url, const QString& layerName, QgsMapLayer* layer, const QString& configFile = QString(), const QList<QString>& tempFiles = QList<QString>() );
5354
/**Searches for the layer with the given url.
5455
@return a pointer to the layer or 0 if no such layer*/
5556
QgsMapLayer* searchLayer( const QString& url, const QString& layerName );

‎src/mapserver/qgsremoteowsbuilder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ QgsMapLayer* QgsRemoteOWSBuilder::createMapLayer(
115115
{
116116
if ( allowCaching )
117117
{
118-
QgsMSLayerCache::instance()->insertLayer( url, layerName, result, "" /*todo: add project file path*/ );
118+
QgsMSLayerCache::instance()->insertLayer( url, layerName, result );
119119
}
120120
else
121121
{
@@ -215,7 +215,7 @@ QgsRasterLayer* QgsRemoteOWSBuilder::wmsLayerFromUrl( const QString& url, const
215215
//insert into cache
216216
if ( allowCaching )
217217
{
218-
QgsMSLayerCache::instance()->insertLayer( url, layerName, result, "" /*todo: add project file path*/ );
218+
QgsMSLayerCache::instance()->insertLayer( url, layerName, result );
219219
}
220220
else
221221
{
@@ -414,7 +414,7 @@ QgsVectorLayer* QgsRemoteOWSBuilder::sosLayer( const QDomElement& remoteOWSElem,
414414
{
415415
if ( allowCaching )
416416
{
417-
QgsMSLayerCache::instance()->insertLayer( providerUrl, layerName, sosLayer, "" /*todo: add project file path*/ );
417+
QgsMSLayerCache::instance()->insertLayer( providerUrl, layerName, sosLayer );
418418
}
419419
else
420420
{

0 commit comments

Comments
 (0)
Please sign in to comment.