Skip to content

Commit c8ea3a7

Browse files
committed
blockAttributeTableUpdates: single signal with bool
1 parent 20e8592 commit c8ea3a7

File tree

4 files changed

+13
-37
lines changed

4 files changed

+13
-37
lines changed

src/app/qgisapp.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9190,16 +9190,6 @@ bool QgisApp::toggleEditing( QgsMapLayer *layer, bool allowCancel )
91909190
}
91919191

91929192

9193-
void QgisApp::unblockAttributeTableUpdates( const QgsVectorLayer *layer )
9194-
{
9195-
emit attributeTableUpdateUnblocked( layer );
9196-
}
9197-
9198-
void QgisApp::blockAttributeTableUpdates( const QgsVectorLayer *layer )
9199-
{
9200-
emit attributeTableUpdateBlocked( layer );
9201-
}
9202-
92039193
void QgisApp::saveActiveLayerEdits()
92049194
{
92059195
saveEdits( activeLayer(), true, true );
@@ -14162,3 +14152,8 @@ void QgisApp::triggerCrashHandler()
1416214152
RaiseException( 0x12345678, 0, 0, nullptr );
1416314153
#endif
1416414154
}
14155+
14156+
void QgisApp::blockAttributeTableUpdates( const QgsVectorLayer *layer, const bool blocked )
14157+
{
14158+
emit attributeTableUpdateBlocked( layer, blocked );
14159+
}

src/app/qgisapp.h

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,18 +1009,11 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
10091009
void triggerCrashHandler();
10101010

10111011
/**
1012-
* Emits the signal to block updates for attribute tables connected a particular \a layer
1012+
* Emits the signal to set the \a blocked state of attribute tables connected a particular \a layer
10131013
*
10141014
* \since QGIS 3.4
10151015
*/
1016-
void blockAttributeTableUpdates( const QgsVectorLayer *layer );
1017-
1018-
/**
1019-
* Emits the signal to unblock updates for attribute tables connected a particular \a layer
1020-
*
1021-
* \since QGIS 3.4
1022-
*/
1023-
void unblockAttributeTableUpdates( const QgsVectorLayer *layer );
1016+
void blockAttributeTableUpdates( const QgsVectorLayer *layer, const bool blocked );
10241017

10251018
protected:
10261019

@@ -1756,18 +1749,11 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
17561749
void activeLayerChanged( QgsMapLayer *layer );
17571750

17581751
/**
1759-
* Emitted when attribute table updates for a particular \a layer must be blocked
1760-
*
1761-
* \since QGIS 3.4
1762-
*/
1763-
void attributeTableUpdateBlocked( const QgsVectorLayer *layer );
1764-
1765-
/**
1766-
* Emitted when all attribute table updates for a particular \a layer must be unblocked
1752+
* Emitted when \a blocked status of attribute table updates for a particular \a layer must change
17671753
*
17681754
* \since QGIS 3.4
17691755
*/
1770-
void attributeTableUpdateUnblocked( const QgsVectorLayer *layer );
1756+
void attributeTableUpdateBlocked( const QgsVectorLayer *layer, const bool blocked );
17711757

17721758
private:
17731759
void startProfile( const QString &name );

src/app/qgsattributetabledialog.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,10 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr
112112
connect( mMainView, &QgsDualView::showContextMenuExternally, this, &QgsAttributeTableDialog::showContextMenu );
113113

114114
// Block/unblock table updates (feature cache signals)
115-
connect( QgisApp::instance(), &QgisApp::attributeTableUpdateBlocked, [ = ]( const QgsVectorLayer * layer )
115+
connect( QgisApp::instance(), &QgisApp::attributeTableUpdateBlocked, [ = ]( const QgsVectorLayer * layer, const bool blocked )
116116
{
117117
if ( layer == mLayer )
118-
this->blockCacheUpdateSignals( true );
119-
} );
120-
connect( QgisApp::instance(), &QgisApp::attributeTableUpdateUnblocked, [ = ]( const QgsVectorLayer * layer )
121-
{
122-
if ( layer == mLayer )
123-
this->blockCacheUpdateSignals( false );
118+
this->blockCacheUpdateSignals( blocked );
124119
} );
125120
// Massive rollbacks can also freeze the GUI due to the feature cache signals
126121
connect( mLayer, &QgsVectorLayer::beforeRollBack, [ = ] { this->blockCacheUpdateSignals( true ); } );

src/app/qgsfieldcalculator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ void QgsFieldCalculator::accept()
269269

270270
// Begin feature modifications, block updates for attr tables
271271
// connected to this layer
272-
QgisApp::instance()->blockAttributeTableUpdates( mVectorLayer );
272+
QgisApp::instance()->blockAttributeTableUpdates( mVectorLayer, true );
273273

274274
//go through all the features and change the new attribute
275275
QgsFeature feature;
@@ -321,7 +321,7 @@ void QgsFieldCalculator::accept()
321321
rownum++;
322322
}
323323

324-
QgisApp::instance()->unblockAttributeTableUpdates( mVectorLayer );
324+
QgisApp::instance()->blockAttributeTableUpdates( mVectorLayer, false );
325325

326326
QApplication::restoreOverrideCursor();
327327

0 commit comments

Comments
 (0)