> > - go back to read-only mode when the user exists the edition mode (this > > would need a new method in the QgsVectorDataProvider API to warn about > > that, since the provider has currently no way of knowing that) > > I think the postgres provider already has a similar concept for > connection pooling. For read-only operations, a shared r/o connection > from the connection pool is obtained. When writing is required, a new > "transaction" connection with write capabilities is opened for the > duration of the r/w session. Maybe this concept can be mirrored by the > ogr provider?
Hum, I've just looked at QgsTransaction / QgsPostgresTransaction and it is really meant at providers that can implement a real SQL transaction mechanism with BEGIN / COMMIT / ROLLBACK which most OGR datasources don't support, and in particular the MapInfo driver does not. In QgsVectorLayer::startEditing(), if there's a transaction returned by the provider, it goes through "pass- through" mode instead of the edition buffer that gets "committed" only when the user saves its edition session. So I don't think the postgres way can be used in the OGR provider. > > > There would be of course a cost to pay due to this open / close > > operations, so I think I would limit it to shapefiles and mapinfo for > > now, since the opening of such datasets doesn't involve a lot of I/O ( > > the most costly is for shapefiles where the whole .shx is ingested into > > memory ). > > > > Another related fix would be to implement reloadData() in the OGR > > provider so that the user can resynchronize its QGIS session for a > > dataset modified by another software. > > Concerning the reloadData() method, there is already a forceReload() > method which reloads a changed dataset (on request) in QGIS. Hum, there's indeed a forceReload() method, only implemented by the OGR provider AFAICS and only used by qgsattributetabledialog (when you hit the Refresh button in the attribute dialog), that refreshes the read-only connections, but not the main connection maintained by the provider. There's also the reloadData() method implemented by the WFS/WCS/WMS providers, and called by QgsVectorLayer/QgsRasterLayer::reload(), for example when you refresh the view with F5. By implementing that one, I'd also close and re- open the OGRDataSourceH ogrDataSource member of the OGR provider. The existence of both API is a bit confusing. I guess the implementations should do the same thing. Hum. > Is your > plan to implement a "change detection" and trigger this action > automatically? I've considered this, but this is not in my immediate plans. With GDAL 2.0, GDALDatasetGetFileList() could be potentially used for that (since GDAL 2.0, a OGRDataSourceH can be cast as a GDALDatasetH). -- Spatialys - Geospatial professional services http://www.spatialys.com _______________________________________________ Qgis-developer mailing list [email protected] List info: http://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: http://lists.osgeo.org/mailman/listinfo/qgis-developer
