Skip to content

Commit

Permalink
Make it possible to skip memory layer check on project close
Browse files Browse the repository at this point in the history
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 56bf486
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit 56bf486

Please sign in to comment.