Skip to content

Commit 0db9f05

Browse files
committed
Use QgsTemporaryCursorOverride
1 parent 1eba8ae commit 0db9f05

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/app/qgsfieldcalculator.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "qgsgeometry.h"
2727
#include "qgssettings.h"
2828
#include "qgsgui.h"
29+
#include "qgsguiutils.h"
2930

3031
#include <QMessageBox>
3132

@@ -197,7 +198,7 @@ void QgsFieldCalculator::accept()
197198
if ( !mVectorLayer->isEditable() )
198199
mVectorLayer->startEditing();
199200

200-
QApplication::setOverrideCursor( Qt::WaitCursor );
201+
QgsTemporaryCursorOverride cursorOverride( Qt::WaitCursor );
201202

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

@@ -226,7 +227,7 @@ void QgsFieldCalculator::accept()
226227

227228
if ( !mVectorLayer->addAttribute( newField ) )
228229
{
229-
QApplication::restoreOverrideCursor();
230+
cursorOverride.release();
230231
QMessageBox::critical( nullptr, tr( "Create New Field" ), tr( "Could not add the new field to the provider." ) );
231232
mVectorLayer->destroyEditCommand();
232233
return;
@@ -248,7 +249,7 @@ void QgsFieldCalculator::accept()
248249
expContext.setFields( mVectorLayer->fields() );
249250
if ( ! exp.prepare( &expContext ) )
250251
{
251-
QApplication::restoreOverrideCursor();
252+
cursorOverride.release();
252253
QMessageBox::critical( nullptr, tr( "Evaluation Error" ), exp.evalErrorString() );
253254
return;
254255
}
@@ -257,7 +258,6 @@ void QgsFieldCalculator::accept()
257258
if ( mAttributeId == -1 && !updatingGeom )
258259
{
259260
mVectorLayer->destroyEditCommand();
260-
QApplication::restoreOverrideCursor();
261261
return;
262262
}
263263

@@ -317,10 +317,9 @@ void QgsFieldCalculator::accept()
317317

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

320-
QApplication::restoreOverrideCursor();
321-
322320
if ( !calculationSuccess )
323321
{
322+
cursorOverride.release();
324323
QMessageBox::critical( nullptr, tr( "Evaluation Error" ), tr( "An error occurred while evaluating the calculation string:\n%1" ).arg( error ) );
325324
mVectorLayer->destroyEditCommand();
326325
return;

src/app/qgsfieldcalculator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class APP_EXPORT QgsFieldCalculator: public QDialog, private Ui::QgsFieldCalcula
2929
Q_OBJECT
3030
public:
3131
QgsFieldCalculator( QgsVectorLayer *vl, QWidget *parent = nullptr );
32-
~QgsFieldCalculator() override;
3332

3433
int changedAttributeId() const { return mAttributeId; }
3534

0 commit comments

Comments
 (0)