Skip to content

Commit 61d243e

Browse files
rldhontm-kuhn
authored andcommittedJun 9, 2016
QgsEditorWidgetRegistry disconnect signals when mapLayer will be removed (#3186)
Add a method to disconnect signals added when layerIsAdded to QgsMapLayerRegistry. This method is connect to layerWillBeRemoved. This method will probably fix an issue in QGIS Server about performance deterioration. Each time a layer is added to QgsMapLayerRegistry by QGIS Server, QgsEditorWidgetRegistry connects to appropriate signals from map layers to load and save style but NEVER disconnects its.
1 parent 015ee77 commit 61d243e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
 

‎src/gui/editorwidgets/core/qgseditorwidgetregistry.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ QgsEditorWidgetRegistry::QgsEditorWidgetRegistry()
7979
connect( QgsProject::instance(), SIGNAL( readMapLayer( QgsMapLayer*, const QDomElement& ) ), this, SLOT( readMapLayer( QgsMapLayer*, const QDomElement& ) ) );
8080
// connect( QgsProject::instance(), SIGNAL( writeMapLayer( QgsMapLayer*, QDomElement&, QDomDocument& ) ), this, SLOT( writeMapLayer( QgsMapLayer*, QDomElement&, QDomDocument& ) ) );
8181

82+
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWillBeRemoved( QgsMapLayer* ) ), this, SLOT( mapLayerWillBeRemoved( QgsMapLayer* ) ) );
8283
connect( QgsMapLayerRegistry::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( mapLayerAdded( QgsMapLayer* ) ) );
8384
}
8485

@@ -326,6 +327,17 @@ void QgsEditorWidgetRegistry::writeMapLayer( QgsMapLayer* mapLayer, QDomElement&
326327
layerElem.appendChild( editTypesNode );
327328
}
328329

330+
void QgsEditorWidgetRegistry::mapLayerWillBeRemoved( QgsMapLayer* mapLayer )
331+
{
332+
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( mapLayer );
333+
334+
if ( vl )
335+
{
336+
disconnect( vl, SIGNAL( readCustomSymbology( const QDomElement&, QString& ) ), this, SLOT( readSymbology( const QDomElement&, QString& ) ) );
337+
disconnect( vl, SIGNAL( writeCustomSymbology( QDomElement&, QDomDocument&, QString& ) ), this, SLOT( writeSymbology( QDomElement&, QDomDocument&, QString& ) ) );
338+
}
339+
}
340+
329341
void QgsEditorWidgetRegistry::mapLayerAdded( QgsMapLayer* mapLayer )
330342
{
331343
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( mapLayer );

‎src/gui/editorwidgets/core/qgseditorwidgetregistry.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ class GUI_EXPORT QgsEditorWidgetRegistry : public QObject
173173
*/
174174
void mapLayerAdded( QgsMapLayer* mapLayer );
175175

176+
/**
177+
* Will disconnect to appropriate signals from map layers to load and save style
178+
*
179+
* @param mapLayer The layer to disconnect
180+
*/
181+
void mapLayerWillBeRemoved( QgsMapLayer* mapLayer );
182+
176183
/**
177184
* Loads layer symbology for the layer that emitted the signal
178185
*

0 commit comments

Comments
 (0)
Please sign in to comment.