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.61k stars 3.01k forks source link

Lock on Layers that are not in Editing Mode #41676

Open ar-siddiqui opened 3 years ago

ar-siddiqui commented 3 years ago

Describe the bug QGIS creates locks on shapefiles that are brought into a project even if they are not in editing mode. This behavior is problematic for engineers who are using QGIS only to display layers and using other non-GIS programs to edit them like PCSWMM for example. ArcGIS products do not create locks on layers unless they are in editing mode.

How to Reproduce

  1. Load any shapefile in QGIS
  2. While the shapefile still loaded try to edit the shapefile through third-party programs like SWMM for example.
  3. There will be a permission denied error and the shapefile will go corrupt sometimes as well. This will not happen if you do the same with ArcMap (while not in editing mode)
  4. See error --> image

QGIS and OS versions

QGIS version 3.16.1-Hannover QGIS code revision b381a90dca Compiled against Qt 5.11.2 Running against Qt 5.11.2 Compiled against GDAL/OGR 3.1.4 Running against GDAL/OGR 3.1.4 Compiled against GEOS 3.8.1-CAPI-1.13.3 Running against GEOS 3.8.1-CAPI-1.13.3 Compiled against SQLite 3.29.0 Running against SQLite 3.29.0 PostgreSQL Client Version 11.5 SpatiaLite Version 4.3.0 QWT Version 6.1.3 QScintilla2 Version 2.10.8 Compiled against PROJ 6.3.2 Running against PROJ Rel. 6.3.2, May 1st, 2020 OS Version Windows 10 (10.0) Active python plugins curve_number_generator; MemoryLayerSaver; slyr_community; StreetView; db_manager; MetaSearch; processing; changeDataSource

gioman commented 3 years ago

@ar-siddiqui your shape seems stored on a network drive, does it happens also on local drives?

rduivenvoorde commented 3 years ago

I know from a client who is having the same issue with Windows machine and network drives with csv files. (I thought to have a way to let people edit csv's on a network, so others could 'reload' data and see added points....) Linux desktops did not have that issue (on the same network) if I recall correctly... My guess is it is smb/windowsnetwork playing up. @ar-siddiqui Eager to know if this is also when you load (not edit) a shp file on you local machine (in QGIS), and then try to edit it with one of the tools you mention ALSO running on the local machine...

ar-siddiqui commented 3 years ago

Just tried with files on the local machine. Had the same issue. What is odd is that there is no lock file in the folder. Also an important thing to note here is that it is failing on .dbf file. image

gioman commented 3 years ago

Also an important thing to note here is that it is failing on .dbf file.

@ar-siddiqui yes confirmed, anyway I'm in doubt if this a bug or a feature. But maybe is a bug or at least an inconsistency if it does not work the same on other OSes like Linux.

gioman commented 3 years ago

@ar-siddiqui yes confirmed, anyway I'm in doubt if this a bug or a feature. But maybe is a bug or at least an inconsistency if it does not work the same on other OSes like Linux.

@ar-siddiqui I'm sorry I have to correct myself, I see no lock if the layer is NOT in edit mode.

rduivenvoorde commented 3 years ago

I just tested with the combination of QGIS and Libreoffice:

But maybe Libreoffice is not picky enough? Or can it be the editing program that is 'seeing' that the file it is trying to save is also opened by another program, and then tells you 'it is locked'?

gioman commented 3 years ago

@rduivenvoorde yeah, I also used LibreOffice to test... and no lock.

ar-siddiqui commented 3 years ago

ArcMap also didn't have any issues editing files open in QGIS (a slight pan in QGIS immediately shows the edited features). But I can confirm two software [PCSWMM, RFD(private software)] that I have used many times and have never worked if the file is open in QGIS. They do work fine with ArcMap. To @rduivenvoorde point that the editing program is seeing that file is opened and then not progressing: It is possible but then why the program would not do the same for ArcMap?

gioman commented 3 years ago

They do work fine with ArcMap

@ar-siddiqui I don't do Arc*, can you try edit the DBF in LibreOffice?

ar-siddiqui commented 3 years ago

Just tried editing .dbf with MSAccess and it worked without any issue .... exactly how it worked for rduivenvoorde. I also tried running my software while keeping .dbf file open in MSAccess and there were no issues. Not sure now if it is an issue with QGIS or other software.

roya0045 commented 3 years ago

Do they all use the same drivers to read shapefiles?

ar-siddiqui commented 3 years ago

At this moment I don't know what drivers they are using to read the shapefile but I will try to find it out and will post here if I find out.

github-actions[bot] commented 3 years 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.

enzedrailmaps commented 3 years ago

Multi-user support on any local file architecture especially if not designed for it is problematic. The support is often just not there and you should not expect it to be. If you want solid multi-user support use a client server database. Even if you were using SQLite based layers, this problem could still be an issue, especially over a network share.

ar-siddiqui commented 3 years ago

I reached out to PCSWMM people and this is what they replied:

The current version of PCSWMM uses a toolkit from TatukGIS to process shapefiles. I believe this manipulates the shape files directly, without any driver.

ar-siddiqui commented 3 years ago

Multi-user support on any local file architecture especially if not designed for it is problematic. The support is often just not there and you should not expect it to be. If you want solid multi-user support use a client server database. Even if you were using SQLite based layers, this problem could still be an issue, especially over a network share.

I did a test to see if I can delete shapefile files in Windows when it is loaded in QGIS and I could not delete the .dbf file ( got the same error) but I was able to delete it when it was open in ArcMap. So I kind of think what QGIS is doing might be more standard and correct. A file shouldn't be allowed to be deleted if it is loaded in another program, but having the functionality of other programs manipulating shapefiles while they are still loaded in QGIS would be nice.

I think this should be a feature request, not a bug.

roya0045 commented 3 years ago

@ar-siddiqui Thanks for the follow-up!

jratike80 commented 3 years ago

I would like to emphasize that even trying to edit the .dbf part of a shapefile with LibreOffice etc. may be a good test for checking if the file is locked or not, that should never be done in practice. If you add or delete a row from .dbf the attributes after that row will be connected into wrong geometries. Shapefile has no keys but first shape is connected to first row in .dbf and so on.

For my mind "having the functionality of other programs manipulating shapefiles while they are still loaded in QGIS" would not be nice. It could lead to catastrophe. But that can happen as well if people edit the .dbf part while shapefile is not loaded to QGIS. I do know that sometimes it is convenient to edit .dbf directly but it must be done carefully and with backups. Rows must never be deleted, added, or sorted.