Skip to content
Permalink
Browse files

Use QgsTemporaryCursorOverride

  • Loading branch information
nyalldawson committed Oct 14, 2018
1 parent 1eba8ae commit 0db9f057890e4e614f03a611ff7b41fded9683fa
Showing with 5 additions and 7 deletions.
  1. +5 −6 src/app/qgsfieldcalculator.cpp
  2. +0 −1 src/app/qgsfieldcalculator.h
@@ -26,6 +26,7 @@
#include "qgsgeometry.h"
#include "qgssettings.h"
#include "qgsgui.h"
#include "qgsguiutils.h"

#include <QMessageBox>

@@ -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" ) );

@@ -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;
@@ -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;
}
@@ -257,7 +258,6 @@ void QgsFieldCalculator::accept()
if ( mAttributeId == -1 && !updatingGeom )
{
mVectorLayer->destroyEditCommand();
QApplication::restoreOverrideCursor();
return;
}

@@ -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;
@@ -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; }

0 comments on commit 0db9f05

Please sign in to comment.
You can’t perform that action at this time.