Skip to content

Commit

Permalink
blockAttributeTableUpdates: single signal with bool
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Oct 14, 2018
1 parent 20e8592 commit c8ea3a7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 37 deletions.
15 changes: 5 additions & 10 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9190,16 +9190,6 @@ bool QgisApp::toggleEditing( QgsMapLayer *layer, bool allowCancel )
}


void QgisApp::unblockAttributeTableUpdates( const QgsVectorLayer *layer )
{
emit attributeTableUpdateUnblocked( layer );
}

void QgisApp::blockAttributeTableUpdates( const QgsVectorLayer *layer )
{
emit attributeTableUpdateBlocked( layer );
}

void QgisApp::saveActiveLayerEdits()
{
saveEdits( activeLayer(), true, true );
Expand Down Expand Up @@ -14162,3 +14152,8 @@ void QgisApp::triggerCrashHandler()
RaiseException( 0x12345678, 0, 0, nullptr );
#endif
}

void QgisApp::blockAttributeTableUpdates( const QgsVectorLayer *layer, const bool blocked )
{
emit attributeTableUpdateBlocked( layer, blocked );
}
22 changes: 4 additions & 18 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1009,18 +1009,11 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
void triggerCrashHandler();

/**
* Emits the signal to block updates for attribute tables connected a particular \a layer
* Emits the signal to set the \a blocked state of attribute tables connected a particular \a layer
*
* \since QGIS 3.4
*/
void blockAttributeTableUpdates( const QgsVectorLayer *layer );

/**
* Emits the signal to unblock updates for attribute tables connected a particular \a layer
*
* \since QGIS 3.4
*/
void unblockAttributeTableUpdates( const QgsVectorLayer *layer );
void blockAttributeTableUpdates( const QgsVectorLayer *layer, const bool blocked );

protected:

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

/**
* Emitted when attribute table updates for a particular \a layer must be blocked
*
* \since QGIS 3.4
*/
void attributeTableUpdateBlocked( const QgsVectorLayer *layer );

/**
* Emitted when all attribute table updates for a particular \a layer must be unblocked
* Emitted when \a blocked status of attribute table updates for a particular \a layer must change
*
* \since QGIS 3.4
*/
void attributeTableUpdateUnblocked( const QgsVectorLayer *layer );
void attributeTableUpdateBlocked( const QgsVectorLayer *layer, const bool blocked );

private:
void startProfile( const QString &name );
Expand Down
9 changes: 2 additions & 7 deletions src/app/qgsattributetabledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,10 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr
connect( mMainView, &QgsDualView::showContextMenuExternally, this, &QgsAttributeTableDialog::showContextMenu );

// Block/unblock table updates (feature cache signals)
connect( QgisApp::instance(), &QgisApp::attributeTableUpdateBlocked, [ = ]( const QgsVectorLayer * layer )
connect( QgisApp::instance(), &QgisApp::attributeTableUpdateBlocked, [ = ]( const QgsVectorLayer * layer, const bool blocked )
{
if ( layer == mLayer )
this->blockCacheUpdateSignals( true );
} );
connect( QgisApp::instance(), &QgisApp::attributeTableUpdateUnblocked, [ = ]( const QgsVectorLayer * layer )
{
if ( layer == mLayer )
this->blockCacheUpdateSignals( false );
this->blockCacheUpdateSignals( blocked );
} );
// Massive rollbacks can also freeze the GUI due to the feature cache signals
connect( mLayer, &QgsVectorLayer::beforeRollBack, [ = ] { this->blockCacheUpdateSignals( true ); } );
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsfieldcalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ void QgsFieldCalculator::accept()

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

//go through all the features and change the new attribute
QgsFeature feature;
Expand Down Expand Up @@ -321,7 +321,7 @@ void QgsFieldCalculator::accept()
rownum++;
}

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

QApplication::restoreOverrideCursor();

Expand Down

0 comments on commit c8ea3a7

Please sign in to comment.