qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.56k stars 3k forks source link

Copy/paste of more than 1000 entities between two layers doesn't work when attribute tables are visibles #55245

Open sigmoe opened 12 months ago

sigmoe commented 12 months ago

What is the bug or the crash?

I'm trying to copy 1069 entities from one layer to another big layer (180000 entities), and QGIS freezes. I've tried with 2 gpkg layers, and with 2 postgresql layers: same problem. The problem appears during pasting, before saving the modification. The problem seems to appear only when the layer where to paste is a big one (with more than several thousands of entities) and when the attribute tables are visibles.

Steps to reproduce the issue

Using the layers of the pb_copy_paste.gpkg attached: 1) show the attribute table of each layer 2) copy all the entities of the batiment_ems layer 3) paste into the batiment_sgm layer 4) QGIS freezes for a very long time ... pb_copy_paste.zip

Versions

Version de QGIS 3.28.11-Firenze Révision du code b02458a196 Version de Qt 5.15.3 Version de Python 3.9.5 Version de GDAL/OGR 3.7.2 Version de Proj 9.3.0 Version de la base de données du registre EPSG v10.094 (2023-08-08) Version de GEOS 3.12.0-CAPI-1.18.0 Version de SQLite 3.41.1 Version de PDAL 2.5.5 Version du client PostgreSQL unknown Version de SpatiaLite 5.1.0 Version de QWT 6.1.6 Version de QScintilla2 2.13.4 Version de l'OS Windows 10 Version 2009

Extensions Python actives db_manager 0.1.20 grassprovider 2.12.99 MetaSearch 0.3.6 processing 2.12.99 sagaprovider 2.12.99

Supported QGIS version

New profile

Additional context

Same problem with QGIS 3.34

alexbruy commented 11 months ago

Can't reproduce with the latest master (a2643b801c9b3a765ce5e0fabd235762f25aa7fe) on Linux.

alexbruy commented 11 months ago

Also works fine with the latest 3.28.12 on Windows

sigmoe commented 11 months ago

I've got the same problem with v3.28.12 on Windows. @alexbruy Have you tested with my gpkg layers and my example ? The problem appears only if the destination layer has a lot of entities. The problem doesn't appear if there are few entities in the destination layer.

alexbruy commented 11 months ago

I tested using steps and data from the issue description. Can't reproduce on Windows and Linux using master and latest 3.28.12.

sigmoe commented 11 months ago

Ok. More precise test: The problem appears when the attribute table of the 2 layers are visibles. When the copy/paste is done without the attribute tables visibles, it's ok.

kannes commented 11 months ago

It does work but is incredibly slow. You can see the feature count ticking upwards in the attribute table. For me it is about 1 per second.

The attribute table is known to be a complex and finicky beast of code so it is unlikely that there is an easy solution. It is probably refreshing itself wholly after each feature insertion or at least counting the features each time. Maybe the code that pastes features could be improved to insert them as a bunch at once but I have no idea.

For now you will have to make sure that the attribute table of the layer you are pasting many features to, is not opened.