@@ -62,7 +62,7 @@ QgsComposerAttributeTableV2::QgsComposerAttributeTableV2( QgsComposition* compos
6262 , mFeatureFilter( QLatin1String( " " ) )
6363{
6464 // set first vector layer from layer registry as default one
65- QMap<QString, QgsMapLayer*> layerMap = QgsProject::instance ()->mapLayers ();
65+ QMap<QString, QgsMapLayer*> layerMap = mComposition -> project ()->mapLayers ();
6666 QMap<QString, QgsMapLayer*>::const_iterator mapIt = layerMap.constBegin ();
6767 for ( ; mapIt != layerMap.constEnd (); ++mapIt )
6868 {
@@ -79,10 +79,11 @@ QgsComposerAttributeTableV2::QgsComposerAttributeTableV2( QgsComposition* compos
7979 // listen for modifications to layer and refresh table when they occur
8080 connect ( mVectorLayer , SIGNAL ( layerModified () ), this , SLOT ( refreshAttributes () ) );
8181 }
82- connect ( QgsProject::instance (), SIGNAL ( layerWillBeRemoved ( QString ) ), this , SLOT ( removeLayer ( const QString& ) ) );
8382
8483 if ( mComposition )
8584 {
85+ connect ( mComposition ->project (), SIGNAL ( layerWillBeRemoved ( QString ) ), this , SLOT ( removeLayer ( const QString& ) ) );
86+
8687 // refresh table attributes when composition is refreshed
8788 connect ( mComposition , SIGNAL ( refreshItemsTriggered () ), this , SLOT ( refreshAttributes () ) );
8889
@@ -140,7 +141,7 @@ void QgsComposerAttributeTableV2::setRelationId( const QString& relationId )
140141
141142 QgsVectorLayer* prevLayer = sourceLayer ();
142143 mRelationId = relationId;
143- QgsRelation relation = QgsProject::instance ()->relationManager ()->relation ( mRelationId );
144+ QgsRelation relation = mComposition -> project ()->relationManager ()->relation ( mRelationId );
144145 QgsVectorLayer* newLayer = relation.referencingLayer ();
145146
146147 if ( mSource == QgsComposerAttributeTableV2::RelationChildren && newLayer != prevLayer )
@@ -438,7 +439,7 @@ bool QgsComposerAttributeTableV2::getTableContents( QgsComposerTableContents &co
438439
439440 if ( mSource == QgsComposerAttributeTableV2::RelationChildren )
440441 {
441- QgsRelation relation = QgsProject::instance ()->relationManager ()->relation ( mRelationId );
442+ QgsRelation relation = mComposition -> project ()->relationManager ()->relation ( mRelationId );
442443 QgsFeature atlasFeature = mComposition ->atlasComposition ().feature ();
443444 req = relation.getRelatedFeaturesRequest ( atlasFeature );
444445 }
@@ -564,7 +565,7 @@ QgsVectorLayer *QgsComposerAttributeTableV2::sourceLayer()
564565 return mVectorLayer ;
565566 case QgsComposerAttributeTableV2::RelationChildren:
566567 {
567- QgsRelation relation = QgsProject::instance ()->relationManager ()->relation ( mRelationId );
568+ QgsRelation relation = mComposition -> project ()->relationManager ()->relation ( mRelationId );
568569 return relation.referencingLayer ();
569570 }
570571 }
@@ -731,7 +732,7 @@ bool QgsComposerAttributeTableV2::readXml( const QDomElement& itemElem, const QD
731732 }
732733 else
733734 {
734- QgsMapLayer* ml = QgsProject::instance ()->mapLayer ( layerId );
735+ QgsMapLayer* ml = mComposition -> project ()->mapLayer ( layerId );
735736 if ( ml )
736737 {
737738 mVectorLayer = dynamic_cast <QgsVectorLayer*>( ml );
0 commit comments