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.37k stars 2.98k forks source link

copy/paste feature tool sets integer/decimal fields of destination feature to 0 if the source feature fields are NULL #57710

Open faridcher opened 3 months ago

faridcher commented 3 months ago

What is the bug or the crash?

copy/paste feature tool sets numeric fields of destination feature to 0 if the source feature fields are NULL. It preserves NULL values of string fields. In the following image, a pasted feature is located northeast of the source feature and is selected. The integer and decimal fields are set to zero arbitrarily!

image

Steps to reproduce the issue

use the sample data. start editing the point layer and copy/paste the single point and check its attributes.

test.zip

Versions

3.34.6

Supported QGIS version

New profile

Additional context

No response

Djedouas commented 3 months ago

Hello,

I can't reproduce the issue on QGIS master nor on QGIS 3.34.7 (Ubuntu 22.04).

I tried with

What is the exact tools you used?

Are you on Windows version?

Thanks

faridcher commented 3 months ago

@Djedouas thank you for testing.

OS: Debian 12 (testing)

Djedouas commented 3 months ago

Tested on fedora with QGIS 3.34.6, unable to reproduce.

Every time I have correct fields values of NULL for all 3 fields:

image


Could you maybe have configured widgets in the attributes form layer parameters? With default values or something?

faridcher commented 3 months ago

@Djedouas I just stared with a new blank project, and added the layer, without any widget configuration (default values). You may verify in the sample project/data files. I can record a video if warranted?

Djedouas commented 3 months ago

Yes please it can help.

Thanks!

faridcher commented 3 months ago

Screencast 06_21_2024-10:27:18_AM.webm

Djedouas commented 3 months ago

Screencast is perfect, thank you!

Unfortunately, I can't reproduce the issue.

It could be a default setting in QGIS parameters I don't know about. Could you try with a completely new profile?

image

Thanks

faridcher commented 3 months ago

Sure, unfortunately with the new profile, the same problems occur.

Djedouas commented 3 months ago

Can you test the following please:

  1. Create a feature with an empty string in string field (not a NULL value, an empty value)
  2. Copy this feature
  3. Paste it
  4. Check if the string value of the pasted feature is NULL or empty
Djedouas commented 3 months ago

OS: Debian 12 (testing)

Do you use QGIS package https://ubuntugis.qgis.org/ubuntugis-ltr/ to have QGIS dependencies on Debian testing?

At some point QGIS relies on OGR to read the clipboard content and determine field values.

What GDAL/OGR version are you using (see in QGIS about menu)?

Djedouas commented 3 months ago

Also, can you copy this

wkt_geom    fid string  integer1    decimal1
Point (51.37065479056155937 35.65868137095111479)   1           

and directly paste it in the editable attribute table (or editable layer in the map canvas) please?

(note the tabulations at the end of the line)

Djedouas commented 3 months ago

I created a VM with Debian 12 testing and was able to reproduce the issue!

Djedouas commented 3 months ago

What is strange is that I have the issue when on Debian 12 testing KDE plasma Wayland, but I don't have the issue on Debian 12 testing KDE plasma X11.

It might come from the clipboard integration.

What do you use?

faridcher commented 3 months ago

I am on Debian 12 with Gnome and Wayland pasting the feature with WKT, creates it as expected. with NULL for all 3 attribute fields. Since I am on Debian, I use its repository to install qgis and not ubuntugis! Gdal 3.9.0

Djedouas commented 3 months ago

If I copy the feature to xclipboard and paste it with keyboard, the bug shows up again. So it''s clearly from GDAL and Wayland and not QGIS

Can you provide a screencast of this please?


I've found a problem in QGIS clipboard with NULL values for which I will post a fix in a PR next week, but I'm not entirely sure that it's related to your issue.

In fact, a feature copy action in QGIS

The paste action in QGIS shoud paste internal copied features object, even if there is text in the clipboard.

The problem I found is that inside the clipboard text, NULL values are transformed to 0 (for int and double).

In every QGIS version I can reproduce this :

  1. copy the feature
  2. paste the text somewhere
  3. copy the text
  4. paste in QGIS
  5. --> we get the 0s

So it seems that your paste action is always taking the text from the clipboard... if it is the case my PR will fix this.


I'm not sure that I am being very clear here, but we can continue to investigate later on after the PR is merged.

Thanks!

faridcher commented 3 months ago

I take back:

If I copy the feature to xclipboard and paste it with keyboard, the bug shows up again. So it''s clearly from GDAL and Wayland and not QGIS

Sure. We will test with your commit later; you may back reference this issue in your PR. Please remove the feedback label so this issue remains open.

thanks for your time on this

github-actions[bot] commented 2 months ago

The QGIS project highly values your report and would love to see it addressed. However, this issue has been left in feedback mode for the last 14 days and is being automatically marked as "stale". If you would like to continue with this issue, please provide any missing information or answer any open questions. If you could resolve the issue yourself meanwhile, please leave a note for future readers with the same problem and close the issue. In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this issue. If there is no further activity on this issue, it will be closed in a week.