Bug report #17312

Attribute Table refresh issue using the Quick Field Calculation Bar

Added by Geo Dev over 6 years ago. Updated over 6 years ago.

Status:Closed
Priority:High
Assignee:Luigi Pirelli
Category:Attribute table
Affected QGIS version:master Regression?:Yes
Operating System:Windows Easy fix?:No
Pull Request or Patch supplied:No Resolution:fixed/implemented
Crashes QGIS or corrupts data:No Copied to github as #:25210

Description

The Attribute Table doesn't immediately update when fields are set with the Quick Field Calculation Bar.

Steps to replicate the issue:
- Open the Attribute Table of any vector layer
- Start editing
- Select an existing field in the drop-down list of the Quick Field Calculation Bar
- Fill the textbox of the Bar with a value or an expression
- Click on Update All button: the table doesn't update
- Change the focus (e.g. filling the texbox with another value or selecting another field in the drop-down list): the table doesn't update
- Force the refresh of the table (e.g. clicking on cells, resizing/sorting the columns, scrolling the table, resizing the table window): the table updates

Same behavior with Update Selected and Update Filtered buttons.
The user has the perception that the Update buttons do not work (priority: High).
The issue also occurs in QGIS 2.18-dev.

test.qgs (8.8 KB) Luigi Pirelli, 2017-10-23 12:41 PM

test.gpkg (116 KB) Luigi Pirelli, 2017-10-23 12:41 PM


Related issues

Related to QGIS Application - Bug report #17187: Attribute Table refresh issue Closed 2017-09-24

Associated revisions

Revision d6a39e90
Added by Luigi Pirelli over 6 years ago

Update Attr Table after field calculation: fixes #17312

Revision 192d6f93
Added by Luigi Pirelli over 6 years ago

Update Attr Table after field calculation: fixes #17312

History

#1 Updated by sand thorn over 6 years ago

I confirm this on

OS: Windows 10 64-bit
QGIS: 2.18.13-20 64-bit (via OSGeo4W pre-compiled) (Thanks to Giovanni Manghi to give me how to try this)

A click on "Update All", "Update Filtered", "Update Selected" should also raise an update event on all shown cells, but it doesn't. You have to click once more in the table area to get the shown cells updated.

I don't know this behaviour is on purpose or a been-forever bug or a regression. However I guess it would be nice if we don't have to have another click, would you agree?

#2 Updated by Jürgen Fischer over 6 years ago

#3 Updated by Giovanni Manghi over 6 years ago

  • Operating System set to Windows

It seems to affect Windows, as on Linux with the same patch the table is auto-refreshed.

#4 Updated by Luigi Pirelli over 6 years ago

trying to replicate

#5 Updated by Luigi Pirelli over 6 years ago

replicated on 2.18.13-21 on win and linux

#6 Updated by Giovanni Manghi over 6 years ago

Luigi Pirelli wrote:

replicated on 2.18.13-21 on win and linux

that's weird, work as expected for me on Linux.

#7 Updated by Luigi Pirelli over 6 years ago

hmmm... probably having a different feature show option? I was able to replicate with "Show All feature"

#8 Updated by Luigi Pirelli over 6 years ago

  • Assignee set to Luigi Pirelli

#9 Updated by Giovanni Manghi over 6 years ago

Luigi Pirelli wrote:

hmmm... probably having a different feature show option? I was able to replicate with "Show All feature"

here too.

can you attach here the dataset you tested?

#10 Updated by Luigi Pirelli over 6 years ago

this is a side effect of avoid reloading of data during editing
https://issues.qgis.org/projects/qgis/repository/revisions/6c84b6ea45e02ba71506fdbc6f5a24800c56b1dc/diff/src/gui/attributetable/qgsattributetablemodel.cpp
The reload was triggered by endEditCommand triggered here:
https://github.com/qgis/QGIS/blob/release-2_18/src/app/qgsattributetabledialog.cpp#L514

Adding a explicit column reload after calculation fix the issue.
e.g. adding the following code after the above lines

  // refresh table with updated values
  // fixes http://issues.qgis.org/issues/17312
  QgsAttributeTableModel* masterModel = mMainView->masterModel();
  int modelColumn = masterModel->fieldIdx( fieldindex );
  masterModel->reload( masterModel->index( 0, modelColumn ), masterModel->index( masterModel->rowCount() - 1, modelColumn ) );

Checking if it's necessary to add more explicit reloads in other parts of QgsAttributeTableDialog
Attached test file and project used to replicate.

#11 Updated by Luigi Pirelli over 6 years ago

no, no more reload is necessary. Explicitely reload is present every time endEditCommand is triggered

#12 Updated by Luigi Pirelli over 6 years ago

checking if this patch is affecting tests:
116/261 Test #116: qgis_dualviewtest .......................***Exception: Other 2.02 sec
145/261 Test #145: qgis_attributetabletest .................***Exception: Other 1.63 sec

#13 Updated by Luigi Pirelli over 6 years ago

this tests fails locally also without my patch! on travis the build is successfull :/

#14 Updated by Luigi Pirelli over 6 years ago

a simplified patch:
QgsAttributeTableModel* masterModel = mMainView->masterModel();
masterModel->reload( masterModel->index( 0, 0 ), masterModel->index( masterModel->rowCount() - 1, masterModel->columnCount() - 1 )

works for 2.18 and master... the patch does not fail current master tests.
Now creating a failing test to avoid the issue again.

#15 Updated by Luigi Pirelli over 6 years ago

for 2.18 added PR https://github.com/qgis/QGIS/pull/5433

next steps will be PR for 3.0 and add a test to avoid regressions

#16 Updated by Luigi Pirelli over 6 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

#17 Updated by Luigi Pirelli over 6 years ago

  • Status changed from Closed to Open

still have to be fixed on master where I want to add unit test

#18 Updated by Luigi Pirelli over 6 years ago

  • Status changed from Open to Closed

#19 Updated by Giovanni Manghi over 6 years ago

  • Resolution set to fixed/implemented

#20 Updated by Steve Lowman over 6 years ago

Please re-open this. I have a calculation failing to display until 'Save' is clicked'. This is in QGIS 2.18.15 LTR, working with a shapefile in W10.

#21 Updated by Luigi Pirelli over 6 years ago

Steve Lowman wrote:

Please re-open this. I have a calculation failing to display until 'Save' is clicked'. This is in QGIS 2.18.15 LTR, working with a shapefile in W10.

I'll try to replicate tomorrow (first on linux)... tnx for the report

#22 Updated by Luigi Pirelli over 6 years ago

can't replicate on Linux with latest 2.18 build (2ef6a82)

doing a verification on Win, btw do you a specific procedure that replicate the issue? Steve, if I follow that explained in this issue I can't replicate.

Luigi Pirelli wrote:

Steve Lowman wrote:

Please re-open this. I have a calculation failing to display until 'Save' is clicked'. This is in QGIS 2.18.15 LTR, working with a shapefile in W10.

I'll try to replicate tomorrow (first on linux)... tnx for the report

#23 Updated by Giovanni Manghi over 6 years ago

Steve Lowman wrote:

Please re-open this. I have a calculation failing to display until 'Save' is clicked'. This is in QGIS 2.18.15 LTR, working with a shapefile in W10.

just tested on 2.18.15 on Windows and works ok for me.

#24 Updated by Luigi Pirelli over 6 years ago

Giovanni Manghi wrote:

Steve Lowman wrote:

Please re-open this. I have a calculation failing to display until 'Save' is clicked'. This is in QGIS 2.18.15 LTR, working with a shapefile in W10.

just tested on 2.18.15 on Windows and works ok for me.

please Steve:
1) check for an updated QGIS
2) if the error persist, give us a procedure to replicate... until this the tiket will remain closed

tnx

Also available in: Atom PDF