Skip to content
Permalink
Browse files
Empty config file entry in layer cache for sld layers
  • Loading branch information
mhugent committed May 11, 2012
1 parent 0971879 commit fa8c9ba843b6802117f0af992a78cb66a6255d70
@@ -67,7 +67,7 @@ QgsMapLayer* QgsHostedRDSBuilder::createMapLayer( const QDomElement& elem,
rl = new QgsRasterLayer( uri, layerNameFromUri( uri ) );
if ( allowCaching )
{
QgsMSLayerCache::instance()->insertLayer( uri, layerName, rl, "" /*todo: add project file path*/ );
QgsMSLayerCache::instance()->insertLayer( uri, layerName, rl );
}
else
{
@@ -75,7 +75,7 @@ QgsMapLayer* QgsHostedVDSBuilder::createMapLayer( const QDomElement& elem,

if ( allowCaching )
{
QgsMSLayerCache::instance()->insertLayer( uri, layerName, ml, "" /*todo: add project file path*/ );
QgsMSLayerCache::instance()->insertLayer( uri, layerName, ml );
}
else
{
@@ -75,15 +75,18 @@ void QgsMSLayerCache::insertLayer( const QString& url, const QString& layerName,
mEntries.insert( urlLayerPair, newEntry );

//update config file map
QHash< QString, int >::iterator configIt = mConfigFiles.find( configFile );
if ( configIt == mConfigFiles.end() )
if ( !configFile.isEmpty() )
{
mConfigFiles.insert( configFile, 1 );
mFileSystemWatcher.addPath( configFile );
}
else
{
mConfigFiles[configFile] = configIt.value() + 1; //increment reference counter
QHash< QString, int >::iterator configIt = mConfigFiles.find( configFile );
if ( configIt == mConfigFiles.end() )
{
mConfigFiles.insert( configFile, 1 );
mFileSystemWatcher.addPath( configFile );
}
else
{
mConfigFiles[configFile] = configIt.value() + 1; //increment reference counter
}
}
}

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

//counter
int configFileCount = mConfigFiles[entry.configFile];
if ( configFileCount < 2 )
if ( !entry.configFile.isEmpty() )
{
mConfigFiles.remove( entry.configFile );
mFileSystemWatcher.removePath( entry.configFile );
}
else
{
mConfigFiles[entry.configFile] = configFileCount - 1;
int configFileCount = mConfigFiles[entry.configFile];
if ( configFileCount < 2 )
{
mConfigFiles.remove( entry.configFile );
mFileSystemWatcher.removePath( entry.configFile );
}
else
{
mConfigFiles[entry.configFile] = configFileCount - 1;
}
}
}
@@ -48,8 +48,9 @@ class QgsMSLayerCache: public QObject
/**Inserts a new layer into the cash
@param url the layer datasource
@param layerName the layer name (to distinguish between different layers in a request using the same datasource
@param configFile path of the config file (to invalidate entries if file changes). Can be empty (e.g. layers from sld)
@param tempFiles some layers have temporary files. The cash makes sure they are removed when removing the layer from the cash*/
void insertLayer( const QString& url, const QString& layerName, QgsMapLayer* layer, const QString& configFile, const QList<QString>& tempFiles = QList<QString>() );
void insertLayer( const QString& url, const QString& layerName, QgsMapLayer* layer, const QString& configFile = QString(), const QList<QString>& tempFiles = QList<QString>() );
/**Searches for the layer with the given url.
@return a pointer to the layer or 0 if no such layer*/
QgsMapLayer* searchLayer( const QString& url, const QString& layerName );
@@ -115,7 +115,7 @@ QgsMapLayer* QgsRemoteOWSBuilder::createMapLayer(
{
if ( allowCaching )
{
QgsMSLayerCache::instance()->insertLayer( url, layerName, result, "" /*todo: add project file path*/ );
QgsMSLayerCache::instance()->insertLayer( url, layerName, result );
}
else
{
@@ -215,7 +215,7 @@ QgsRasterLayer* QgsRemoteOWSBuilder::wmsLayerFromUrl( const QString& url, const
//insert into cache
if ( allowCaching )
{
QgsMSLayerCache::instance()->insertLayer( url, layerName, result, "" /*todo: add project file path*/ );
QgsMSLayerCache::instance()->insertLayer( url, layerName, result );
}
else
{
@@ -414,7 +414,7 @@ QgsVectorLayer* QgsRemoteOWSBuilder::sosLayer( const QDomElement& remoteOWSElem,
{
if ( allowCaching )
{
QgsMSLayerCache::instance()->insertLayer( providerUrl, layerName, sosLayer, "" /*todo: add project file path*/ );
QgsMSLayerCache::instance()->insertLayer( providerUrl, layerName, sosLayer );
}
else
{

0 comments on commit fa8c9ba

Please sign in to comment.