Skip to content
Permalink
Browse files

Make it possible to skip memory layer check on project close

In QGIS 3.4 there is the new feature that warns users about a potential data loss
when closing a project that contains memory layers. It displays the warning:

> This project includes one or more temporary scratch layers.
> These layers are not saved to disk and their contents will be
> permanently lost. Are you sure you want to proceed?"

While this is useful in general, there are various cases when this warning
is unwanted. For example, when a plugin creates memory layers by extracting data
from some custom data format (and possibly also writes changes from temporary
layers back to the data storage). In such situations the warning is very confusing
for the users who are unaware of the internals.

This commit adds a custom property "skipMemoryLayersCheck" to map layers,
so if all temporary layers have this property set to non-zero value the warning
will not show up.

layer.setCustomProperty("skipMemoryLayersCheck", 1)
  • Loading branch information
wonder-sk committed Oct 18, 2018
1 parent 4010e79 commit 56bf486239f86a484c3d3190e778b66ff67d5e82
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/app/qgisapp.cpp
@@ -11134,7 +11134,7 @@ bool QgisApp::checkMemoryLayers()
if ( it.value() && it.value()->dataProvider()->name() == QLatin1String( "memory" ) )
{
QgsVectorLayer *vl = qobject_cast< QgsVectorLayer * >( it.value() );
if ( vl && vl->featureCount() != 0 )
if ( vl && vl->featureCount() != 0 && !vl->customProperty( QStringLiteral( "skipMemoryLayersCheck" ) ).toInt() )
{
hasMemoryLayers = true;
break;

0 comments on commit 56bf486

Please sign in to comment.
You can’t perform that action at this time.