Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Fix rollback on large tables when attr table is opened
- Loading branch information
|
@@ -821,20 +821,6 @@ Set translation |
|
|
%Docstring |
|
|
Emits the signal to collect all the strings of .qgs to be included in ts file |
|
|
|
|
|
.. versionadded:: 3.4 |
|
|
%End |
|
|
|
|
|
void blockAttributeTableUpdates( const QgsVectorLayer *layer ); |
|
|
%Docstring |
|
|
Emits the signal to block updates for attribute tables connected a particular ``layer`` |
|
|
|
|
|
.. versionadded:: 3.4 |
|
|
%End |
|
|
|
|
|
void unblockAttributeTableUpdates( const QgsVectorLayer *layer ); |
|
|
%Docstring |
|
|
Emits the signal to unblock updates for attribute tables connected a particular ``layer`` |
|
|
|
|
|
.. versionadded:: 3.4 |
|
|
%End |
|
|
|
|
@@ -864,20 +850,6 @@ Emitted whenever a custom global variable changes. |
|
|
Emitted when project strings which require translation are being collected for inclusion in a .ts file. |
|
|
In order to register translatable strings, connect to this signal and register the strings within the specified ``translationContext``. |
|
|
|
|
|
.. versionadded:: 3.4 |
|
|
%End |
|
|
|
|
|
void attributeTableUpdateBlocked( const QgsVectorLayer *layer ); |
|
|
%Docstring |
|
|
Emitted when attribute table updates for a particular ``layer`` must be blocked |
|
|
|
|
|
.. versionadded:: 3.4 |
|
|
%End |
|
|
|
|
|
void attributeTableUpdateUnblocked( const QgsVectorLayer *layer ); |
|
|
%Docstring |
|
|
Emitted when all attribute table updates for a particular ``layer`` must be unblocked |
|
|
|
|
|
.. versionadded:: 3.4 |
|
|
%End |
|
|
|
|
|
|
@@ -2371,6 +2371,13 @@ 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 ); |
|
|
|
@@ -9189,6 +9189,17 @@ bool QgisApp::toggleEditing( QgsMapLayer *layer, bool allowCancel ) |
|
|
return res; |
|
|
} |
|
|
|
|
|
|
|
|
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 ); |
|
|
|
@@ -1008,6 +1008,20 @@ 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 |
|
|
* |
|
|
* \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 ); |
|
|
|
|
|
protected: |
|
|
|
|
|
//! Handle state changes (WindowTitleChange) |
|
@@ -1741,6 +1755,20 @@ 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 |
|
|
* |
|
|
* \since QGIS 3.4 |
|
|
*/ |
|
|
void attributeTableUpdateUnblocked( const QgsVectorLayer *layer ); |
|
|
|
|
|
private: |
|
|
void startProfile( const QString &name ); |
|
|
void endProfile(); |
|
|
|
@@ -112,16 +112,19 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *layer, QgsAttr |
|
|
connect( mMainView, &QgsDualView::showContextMenuExternally, this, &QgsAttributeTableDialog::showContextMenu ); |
|
|
|
|
|
// Block/unblock table updates (feature cache signals) |
|
|
connect( QgsApplication::instance(), &QgsApplication::attributeTableUpdateBlocked, [ = ]( const QgsVectorLayer * layer ) |
|
|
connect( QgisApp::instance(), &QgisApp::attributeTableUpdateBlocked, [ = ]( const QgsVectorLayer * layer ) |
|
|
{ |
|
|
if ( layer == mLayer ) |
|
|
this->blockCacheUpdateSignals( true ); |
|
|
} ); |
|
|
connect( QgsApplication::instance(), &QgsApplication::attributeTableUpdateUnblocked, [ = ]( const QgsVectorLayer * layer ) |
|
|
connect( QgisApp::instance(), &QgisApp::attributeTableUpdateUnblocked, [ = ]( const QgsVectorLayer * layer ) |
|
|
{ |
|
|
if ( layer == mLayer ) |
|
|
this->blockCacheUpdateSignals( false ); |
|
|
} ); |
|
|
// Massive rollbacks can also freeze the GUI due to the feature cache signals |
|
|
connect( mLayer, &QgsVectorLayer::beforeRollBack, [ = ] { this->blockCacheUpdateSignals( true ); } ); |
|
|
connect( mLayer, &QgsVectorLayer::afterRollBack, [ = ] { this->blockCacheUpdateSignals( false ); } ); |
|
|
|
|
|
const QgsFields fields = mLayer->fields(); |
|
|
for ( const QgsField &field : fields ) |
|
|
|
@@ -269,7 +269,7 @@ void QgsFieldCalculator::accept() |
|
|
|
|
|
// Begin feature modifications, block updates for attr tables |
|
|
// connected to this layer |
|
|
QgsApplication::instance()->blockAttributeTableUpdates( mVectorLayer ); |
|
|
QgisApp::instance()->blockAttributeTableUpdates( mVectorLayer ); |
|
|
|
|
|
//go through all the features and change the new attribute |
|
|
QgsFeature feature; |
|
@@ -321,7 +321,7 @@ void QgsFieldCalculator::accept() |
|
|
rownum++; |
|
|
} |
|
|
|
|
|
QgsApplication::instance()->unblockAttributeTableUpdates( mVectorLayer ); |
|
|
QgisApp::instance()->unblockAttributeTableUpdates( mVectorLayer ); |
|
|
|
|
|
QApplication::restoreOverrideCursor(); |
|
|
|
|
|
|
@@ -1535,15 +1535,6 @@ void QgsApplication::collectTranslatableObjects( QgsTranslationContext *translat |
|
|
emit requestForTranslatableObjects( translationContext ); |
|
|
} |
|
|
|
|
|
void QgsApplication::unblockAttributeTableUpdates( const QgsVectorLayer *layer ) |
|
|
{ |
|
|
emit attributeTableUpdateUnblocked( layer ); |
|
|
} |
|
|
|
|
|
void QgsApplication::blockAttributeTableUpdates( const QgsVectorLayer *layer ) |
|
|
{ |
|
|
emit attributeTableUpdateBlocked( layer ); |
|
|
} |
|
|
|
|
|
QString QgsApplication::nullRepresentation() |
|
|
{ |
|
|
|
@@ -758,20 +758,6 @@ class CORE_EXPORT QgsApplication : public QApplication |
|
|
*/ |
|
|
void collectTranslatableObjects( QgsTranslationContext *translationContext ); |
|
|
|
|
|
/** |
|
|
* Emits the signal to block updates for 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 ); |
|
|
|
|
|
|
|
|
#ifdef SIP_RUN |
|
|
SIP_IF_FEATURE( ANDROID ) |
|
@@ -804,20 +790,6 @@ class CORE_EXPORT QgsApplication : public QApplication |
|
|
*/ |
|
|
void requestForTranslatableObjects( QgsTranslationContext *translationContext ); |
|
|
|
|
|
/** |
|
|
* 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 |
|
|
* |
|
|
* \since QGIS 3.4 |
|
|
*/ |
|
|
void attributeTableUpdateUnblocked( const QgsVectorLayer *layer ); |
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
@@ -2973,6 +2973,8 @@ bool QgsVectorLayer::rollBack( bool deleteBuffer ) |
|
|
|
|
|
mEditBuffer->rollBack(); |
|
|
|
|
|
emit afterRollBack(); |
|
|
|
|
|
if ( isModified() ) |
|
|
{ |
|
|
// new undo stack roll back method |
|
|
|
@@ -2167,6 +2167,12 @@ 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 |
|
|