YoannQDQ / qgis-memory-layer-saver

Makes data in memory provider layers persistent between QGIS sessions. Data saved in .mldata file alongside project file.
Other
7 stars 4 forks source link

Losing memory layers #15

Open mikedufty opened 1 year ago

mikedufty commented 1 year ago

One of my colleagues has had an issue with losing data saved in memory layers. Unfortunately I can't reproduce it. I thought it might be the issue I mentioned previously with conflicting plugin versions, but the latest occurrence has happened with a file that has only been edited with the new plugin ie there is no external mldata file, only the one in the .qgz archive.

Thought I'd post here in case others have had similar issues or hints. Screenshot of the MLS data below, the last 13 entries have 0 features. Does anyone know what determines the order of the layer listing in the Display memory layer data dialogue? Are there ways to read or examine the mldata file other than via the plugin?

image

YoannQDQ commented 1 year ago

Unfortunately no, there's no way to inspect the binary file, other than recoding the reading function, using QDataStream. You can have a look at the reader.py file, which contains the Readerclass, that handles reading the file.

I'd be very interested if you manage to reliably reproduce this issue, as I have no clue what might be causing it at the moment.

Regarding the layer order in the dialog, we use the following function

    def memory_layers(self):
        """Return a list of all memory layers in the project"""
        return [layer for layer in QgsProject.instance().mapLayers().values() if Settings.is_saved_layer(layer)]

This returns the list of the memory layers (whose data provider is memory), in the same order they were added in the project (older first).

mikedufty commented 1 year ago

Thanks, I thought the order was oldest to newest too, as when I tested with a new layer it was appended to the end, but when I experimented with a couple more new ones they appeared in the middle of the list.

I'm hoping it doesn't happen again, or if it does that I can pin down the cause. I've come to trust the memory layers very well over the years, so quite a hassle if they are not dependable. Quite a tricky environment with files on a network potentially opened with different versions of qgis. I should make more effort to get everyone up to date. Could very well be an issue that has nothing to do with the plugin.

romanadew commented 10 months ago

I work with Mike and our team are still having sporadic issues with memory layers, where frequently temporary scratch layers are disappearing on reboot even with the same user, computer and QGIS version.