Skip to content
Browse files
[BUGFIX] QgsMSLayerCache: remove layer from QgsMapLayerRegistry befor…
…e delete it

In QGIS Server, layers can be added to QgsMapLayerRegistry and delete by QgsMSLayerCache. This means that QgsMapLayerRegistry can have reference to deleted pointers.
  • Loading branch information
rldhont committed Jun 28, 2016
1 parent 0de1bfa commit 78569ab38f5dc5eb4816921bc3ddb72bf603e74c
Showing with 6 additions and 0 deletions.
  1. +6 −0 src/server/qgsmslayercache.cpp
@@ -17,6 +17,8 @@

#include "qgsmslayercache.h"
#include "qgsmessagelog.h"
#include "qgsmaplayerregistry.h"
#include "qgsmaplayer.h"
#include "qgsvectorlayer.h"
#include "qgslogger.h"
#include <QFile>
@@ -187,6 +189,10 @@ void QgsMSLayerCache::removeLeastUsedEntry()

void QgsMSLayerCache::freeEntryRessources( QgsMSLayerCacheEntry& entry )
// remove layer from QgsMapLayerRegistry before delete it
if ( QgsMapLayerRegistry::instance()->mapLayer( entry.layerPointer->id() ) )
QgsMapLayerRegistry::instance()->removeMapLayer( entry.layerPointer->id() );

delete entry.layerPointer;

//remove the temporary files of a layer

0 comments on commit 78569ab

Please sign in to comment.