Revert "Merge pull request #8177 from elpaso/bugfix-20094-field-calculator-slowness"

This reverts commit 096b4ce00426ee35a1eec5b54453b9ea2e22b903, reversing
changes made to 87e0f6961adcbf7039d2c0bef914cebd747afc67.
This commit is contained in:
Alessandro Pasotti 2018-10-15 15:38:41 +02:00
parent ee8e1ce9bc
commit 0e50b3ba70
11 changed files with 6 additions and 73 deletions

View File

@ -824,7 +824,6 @@ Emits the signal to collect all the strings of .qgs to be included in ts file
.. versionadded:: 3.4
%End
%If (ANDROID)
//dummy method to workaround sip generation issue
bool x11EventFilter( XEvent *event );
@ -853,7 +852,6 @@ In order to register translatable strings, connect to this signal and register t
.. versionadded:: 3.4
%End
};

View File

@ -2377,13 +2377,6 @@ Is emitted, before changes are committed to the data provider
void beforeRollBack();
%Docstring
Is emitted, before changes are rolled back
%End
void afterRollBack();
%Docstring
Is emitted, after changes are rolled back
.. versionadded:: 3.4
%End
void attributeAdded( int idx );

View File

@ -7091,14 +7091,13 @@ void QgisApp::fieldCalculator()
void QgisApp::attributeTable( QgsAttributeTableFilterModel::FilterMode filter )
{
QgsVectorLayer *vectorLayer = qobject_cast<QgsVectorLayer *>( activeLayer() );
if ( !vectorLayer )
QgsVectorLayer *myLayer = qobject_cast<QgsVectorLayer *>( activeLayer() );
if ( !myLayer )
{
return;
}
QgsAttributeTableDialog *mDialog = new QgsAttributeTableDialog( vectorLayer, filter );
QgsAttributeTableDialog *mDialog = new QgsAttributeTableDialog( myLayer, filter );
mDialog->show();
// the dialog will be deleted by itself on close
}
@ -9190,7 +9189,6 @@ bool QgisApp::toggleEditing( QgsMapLayer *layer, bool allowCancel )
return res;
}
void QgisApp::saveActiveLayerEdits()
{
saveEdits( activeLayer(), true, true );
@ -14148,8 +14146,3 @@ void QgisApp::triggerCrashHandler()
RaiseException( 0x12345678, 0, 0, nullptr );
#endif
}
void QgisApp::blockAttributeTableUpdates( const QgsVectorLayer *layer, const bool blocked )
{
emit attributeTableUpdateBlocked( layer, blocked );
}

View File

@ -1008,13 +1008,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
*/
void triggerCrashHandler();
/**
* 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, const bool blocked );
protected:
//! Handle state changes (WindowTitleChange)
@ -1743,13 +1736,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
*/
void activeLayerChanged( QgsMapLayer *layer );
/**
* Emitted when \a blocked status of attribute table updates for a particular \a layer must change
*
* \since QGIS 3.4
*/
void attributeTableUpdateBlocked( const QgsVectorLayer *layer, const bool blocked );
private:
void startProfile( const QString &name );
void endProfile();

View File

@ -113,16 +113,6 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr
connect( mActionExpressionSelect, &QAction::triggered, this, &QgsAttributeTableDialog::mActionExpressionSelect_triggered );
connect( mMainView, &QgsDualView::showContextMenuExternally, this, &QgsAttributeTableDialog::showContextMenu );
// Block/unblock table updates (feature cache signals)
connect( QgisApp::instance(), &QgisApp::attributeTableUpdateBlocked, this, [ = ]( const QgsVectorLayer * layer, const bool blocked )
{
if ( layer == mLayer )
this->blockCacheUpdateSignals( blocked );
} );
// Massive rollbacks can also freeze the GUI due to the feature cache signals
connect( mLayer, &QgsVectorLayer::beforeRollBack, this, [ = ] { this->blockCacheUpdateSignals( true ); } );
connect( mLayer, &QgsVectorLayer::afterRollBack, this, [ = ] { this->blockCacheUpdateSignals( false ); } );
const QgsFields fields = mLayer->fields();
for ( const QgsField &field : fields )
{
@ -743,6 +733,7 @@ void QgsAttributeTableDialog::mActionOpenFieldCalculator_triggered()
if ( calc.exec() == QDialog::Accepted )
{
int col = masterModel->fieldCol( calc.changedAttributeId() );
if ( col >= 0 )
{
masterModel->reload( masterModel->index( 0, col ), masterModel->index( masterModel->rowCount() - 1, col ) );
@ -1154,15 +1145,6 @@ void QgsAttributeTableDialog::setFilterExpression( const QString &filterString,
mMainView->setFilterMode( QgsAttributeTableFilterModel::ShowFilteredList );
}
void QgsAttributeTableDialog::blockCacheUpdateSignals( const bool block )
{
QgsAttributeTableModel *masterModel = mMainView->masterModel();
if ( ! masterModel )
return;
masterModel->layerCache()->blockSignals( block );
}
void QgsAttributeTableDialog::deleteFeature( const QgsFeatureId fid )
{

View File

@ -242,7 +242,6 @@ class APP_EXPORT QgsAttributeTableDialog : public QDialog, private Ui::QgsAttrib
void updateMultiEditButtonState();
void deleteFeature( QgsFeatureId fid );
void blockCacheUpdateSignals( const bool block );
friend class TestQgsAttributeTable;
};

View File

@ -159,10 +159,8 @@ void QgsFieldCalculator::accept()
{
builder->saveToRecent( QStringLiteral( "fieldcalc" ) );
if ( ! mVectorLayer )
{
if ( !mVectorLayer )
return;
}
// Set up QgsDistanceArea each time we (re-)calculate
QgsDistanceArea myDa;
@ -262,10 +260,6 @@ void QgsFieldCalculator::accept()
return;
}
// Begin feature modifications, block updates for attr tables
// connected to this layer
QgisApp::instance()->blockAttributeTableUpdates( mVectorLayer, true );
//go through all the features and change the new attribute
QgsFeature feature;
bool calculationSuccess = true;
@ -326,8 +320,6 @@ void QgsFieldCalculator::accept()
rownum++;
}
QgisApp::instance()->blockAttributeTableUpdates( mVectorLayer, false );
if ( !calculationSuccess )
{
cursorOverride.release();
@ -336,6 +328,7 @@ void QgsFieldCalculator::accept()
mVectorLayer->destroyEditCommand();
return;
}
mVectorLayer->endEditCommand();
}
QDialog::accept();

View File

@ -1528,7 +1528,6 @@ void QgsApplication::collectTranslatableObjects( QgsTranslationContext *translat
emit requestForTranslatableObjects( translationContext );
}
QString QgsApplication::nullRepresentation()
{
ApplicationMembers *appMembers = members();

View File

@ -757,7 +757,6 @@ class CORE_EXPORT QgsApplication : public QApplication
*/
void collectTranslatableObjects( QgsTranslationContext *translationContext );
#ifdef SIP_RUN
SIP_IF_FEATURE( ANDROID )
//dummy method to workaround sip generation issue
@ -789,7 +788,6 @@ class CORE_EXPORT QgsApplication : public QApplication
*/
void requestForTranslatableObjects( QgsTranslationContext *translationContext );
private:
static void copyPath( const QString &src, const QString &dst );

View File

@ -2983,8 +2983,6 @@ bool QgsVectorLayer::rollBack( bool deleteBuffer )
mEditBuffer->rollBack();
emit afterRollBack();
if ( isModified() )
{
// new undo stack roll back method

View File

@ -2173,12 +2173,6 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
//! Is emitted, before changes are rolled back
void beforeRollBack();
/**
* Is emitted, after changes are rolled back
* \since QGIS 3.4
*/
void afterRollBack();
/**
* Will be emitted, when a new attribute has been added to this vector layer.
* Applies only to types QgsFields::OriginEdit, QgsFields::OriginProvider and QgsFields::OriginExpression