Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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 78569ab
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/server/qgsmslayercache.cpp
Expand Up @@ -17,6 +17,8 @@

#include "qgsmslayercache.h"
#include "qgsmessagelog.h"
#include "qgsmaplayerregistry.h"
#include "qgsmaplayer.h"
#include "qgsvectorlayer.h"
#include "qgslogger.h"
#include <QFile>
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 78569ab

Please sign in to comment.