Skip to content

Commit

Permalink
Use QgsTemporaryCursorOverride
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Oct 15, 2018
1 parent 1eba8ae commit 0db9f05
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
11 changes: 5 additions & 6 deletions src/app/qgsfieldcalculator.cpp
Expand Up @@ -26,6 +26,7 @@
#include "qgsgeometry.h"
#include "qgssettings.h"
#include "qgsgui.h"
#include "qgsguiutils.h"

#include <QMessageBox>

Expand Down Expand Up @@ -197,7 +198,7 @@ void QgsFieldCalculator::accept()
if ( !mVectorLayer->isEditable() )
mVectorLayer->startEditing();

QApplication::setOverrideCursor( Qt::WaitCursor );
QgsTemporaryCursorOverride cursorOverride( Qt::WaitCursor );

mVectorLayer->beginEditCommand( QStringLiteral( "Field calculator" ) );

Expand Down Expand Up @@ -226,7 +227,7 @@ void QgsFieldCalculator::accept()

if ( !mVectorLayer->addAttribute( newField ) )
{
QApplication::restoreOverrideCursor();
cursorOverride.release();
QMessageBox::critical( nullptr, tr( "Create New Field" ), tr( "Could not add the new field to the provider." ) );
mVectorLayer->destroyEditCommand();
return;
Expand All @@ -248,7 +249,7 @@ void QgsFieldCalculator::accept()
expContext.setFields( mVectorLayer->fields() );
if ( ! exp.prepare( &expContext ) )
{
QApplication::restoreOverrideCursor();
cursorOverride.release();
QMessageBox::critical( nullptr, tr( "Evaluation Error" ), exp.evalErrorString() );
return;
}
Expand All @@ -257,7 +258,6 @@ void QgsFieldCalculator::accept()
if ( mAttributeId == -1 && !updatingGeom )
{
mVectorLayer->destroyEditCommand();
QApplication::restoreOverrideCursor();
return;
}

Expand Down Expand Up @@ -317,10 +317,9 @@ void QgsFieldCalculator::accept()

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

QApplication::restoreOverrideCursor();

if ( !calculationSuccess )
{
cursorOverride.release();
QMessageBox::critical( nullptr, tr( "Evaluation Error" ), tr( "An error occurred while evaluating the calculation string:\n%1" ).arg( error ) );
mVectorLayer->destroyEditCommand();
return;
Expand Down
1 change: 0 additions & 1 deletion src/app/qgsfieldcalculator.h
Expand Up @@ -29,7 +29,6 @@ class APP_EXPORT QgsFieldCalculator: public QDialog, private Ui::QgsFieldCalcula
Q_OBJECT
public:
QgsFieldCalculator( QgsVectorLayer *vl, QWidget *parent = nullptr );
~QgsFieldCalculator() override;

int changedAttributeId() const { return mAttributeId; }

Expand Down

0 comments on commit 0db9f05

Please sign in to comment.