@@ -83,18 +83,12 @@ QgsTransaction::~QgsTransaction()
83
83
84
84
bool QgsTransaction::addLayer ( const QString& layerId )
85
85
{
86
- if ( mTransactionActive )
87
- return false ;
88
-
89
86
QgsVectorLayer* layer = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance ()->mapLayer ( layerId ) );
90
87
return addLayer ( layer );
91
88
}
92
89
93
90
bool QgsTransaction::addLayer ( QgsVectorLayer* layer )
94
91
{
95
- if ( mTransactionActive )
96
- return false ;
97
-
98
92
if ( !layer )
99
93
return false ;
100
94
@@ -119,6 +113,10 @@ bool QgsTransaction::addLayer( QgsVectorLayer* layer )
119
113
connect ( this , SIGNAL ( afterRollback () ), layer->dataProvider (), SIGNAL ( dataChanged () ) );
120
114
connect ( QgsMapLayerRegistry::instance (), SIGNAL ( layersWillBeRemoved ( QStringList ) ), this , SLOT ( onLayersDeleted ( QStringList ) ) );
121
115
mLayers .insert ( layer );
116
+
117
+ if ( mTransactionActive )
118
+ layer->dataProvider ()->setTransaction ( this );
119
+
122
120
return true ;
123
121
}
124
122
@@ -141,14 +139,6 @@ bool QgsTransaction::commit( QString& errorMsg )
141
139
if ( !mTransactionActive )
142
140
return false ;
143
141
144
- Q_FOREACH ( QgsVectorLayer* l, mLayers )
145
- {
146
- if ( !l || l->isEditable () )
147
- {
148
- return false ;
149
- }
150
- }
151
-
152
142
if ( !commitTransaction ( errorMsg ) )
153
143
return false ;
154
144
@@ -162,14 +152,6 @@ bool QgsTransaction::rollback( QString& errorMsg )
162
152
if ( !mTransactionActive )
163
153
return false ;
164
154
165
- Q_FOREACH ( QgsVectorLayer* l, mLayers )
166
- {
167
- if ( l->isEditable () )
168
- {
169
- return false ;
170
- }
171
- }
172
-
173
155
if ( !rollbackTransaction ( errorMsg ) )
174
156
return false ;
175
157
0 commit comments