Skip to content

Commit c96c426

Browse files
author
mhugent
committed
Appied patch in ticket #811 from aaronr
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7416 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent b29435a commit c96c426

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

src/app/legend/qgslegendlayerfile.cpp

+11-6
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,17 @@ QgsLegendLayerFile::QgsLegendLayerFile(QTreeWidgetItem * theLegendItem, QString
6262
setCheckState(0, Qt::Checked);
6363
setText(0, theString);
6464

65-
// get notifications of changed selection - used to update attribute table
66-
connect(mLyr.layer(), SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
67-
68-
// get notifications of modified layer - used to close table as it's out of sync
69-
connect(mLyr.layer(), SIGNAL(wasModified(bool)), this, SLOT(closeTable(bool)));
70-
65+
// Add check if vector layer when connecting to selectionChanged slot
66+
// Ticket #811 - racicot
67+
QgsMapLayer *currentLayer = mLyr.layer();
68+
QgsVectorLayer *isVectLyr = dynamic_cast < QgsVectorLayer * >(currentLayer);
69+
if (isVectLyr)
70+
{
71+
// get notifications of changed selection - used to update attribute table
72+
connect(mLyr.layer(), SIGNAL(selectionChanged()), this, SLOT(selectionChanged()));
73+
// get notifications of modified layer - used to close table as it's out of sync
74+
connect(mLyr.layer(), SIGNAL(wasModified(bool)), this, SLOT(closeTable(bool)));
75+
}
7176
connect(mLyr.layer(), SIGNAL(layerNameChanged()), this, SLOT(layerNameChanged()));
7277
}
7378

src/gui/qgsmapcanvas.cpp

+18-4
Original file line numberDiff line numberDiff line change
@@ -247,16 +247,30 @@ void QgsMapCanvas::setLayerSet(QList<QgsMapCanvasLayer>& layers)
247247
{
248248
for (i = 0; i < layerCount(); i++)
249249
{
250-
disconnect(getZpos(i), SIGNAL(repaintRequested()), this, SLOT(refresh()));
251-
disconnect(getZpos(i), SIGNAL(selectionChanged()), this, SLOT(refresh()));
250+
// Add check if vector layer when disconnecting from selectionChanged slot
251+
// Ticket #811 - racicot
252+
QgsMapLayer *currentLayer = getZpos(i);
253+
disconnect(currentLayer, SIGNAL(repaintRequested()), this, SLOT(refresh()));
254+
QgsVectorLayer *isVectLyr = dynamic_cast < QgsVectorLayer * >(currentLayer);
255+
if (isVectLyr)
256+
{
257+
disconnect(currentLayer, SIGNAL(selectionChanged()), this, SLOT(refresh()));
258+
}
252259
}
253260

254261
mMapRender->setLayerSet(layerSet);
255262

256263
for (i = 0; i < layerCount(); i++)
257264
{
258-
connect(getZpos(i), SIGNAL(repaintRequested()), this, SLOT(refresh()));
259-
connect(getZpos(i), SIGNAL(selectionChanged()), this, SLOT(refresh()));
265+
// Add check if vector layer when connecting to selectionChanged slot
266+
// Ticket #811 - racicot
267+
QgsMapLayer *currentLayer = getZpos(i);
268+
connect(currentLayer, SIGNAL(repaintRequested()), this, SLOT(refresh()));
269+
QgsVectorLayer *isVectLyr = dynamic_cast < QgsVectorLayer * >(currentLayer);
270+
if (isVectLyr)
271+
{
272+
connect(currentLayer, SIGNAL(selectionChanged()), this, SLOT(refresh()));
273+
}
260274
}
261275
}
262276

0 commit comments

Comments
 (0)