Skip to content

Commit

Permalink
use null value when pasting as temporary layer and attributes cannot …
Browse files Browse the repository at this point in the history
…be converted
  • Loading branch information
uclaros committed Jul 4, 2024
1 parent 47f7b3a commit 1a0d81d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10662,10 +10662,10 @@ std::unique_ptr<QgsVectorLayer> QgisApp::pasteToNewMemoryVector()
for ( int idx = 0; idx < layer->fields().count() && idx < it->attributeCount(); ++idx )
{
QVariant attr = it->attribute( idx );
if ( layer->fields().at( idx ).convertCompatible( attr ) )
{
it->setAttribute( idx, attr );
}
//if convertCompatible fails, it will replace attr with an appropriate null QVariant
//so we're calling setAttribute regardless, covering cases like 'Autogenerate' or 'nextVal()' on int fields.
layer->fields().at( idx ).convertCompatible( attr );
it->setAttribute( idx, attr );
}
}

Expand Down

0 comments on commit 1a0d81d

Please sign in to comment.