Bug report #7072

regression : can't create a feature

Added by Philippe Dorelon almost 10 years ago. Updated over 9 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:-
Category:Vectors
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:16156

Description

In master revision (94491b8),
it seems impossible to create a feature with geometry: the new object disappears after its creation.

Thanks all

test.zip (259 KB) Philippe Dorelon, 2013-01-29 06:36 AM

Associated revisions

Revision aca3dfaf
Added by Nathan Woodrow over 9 years ago

Merge pull request #546 from PhilippeDorelon/addfeatureJoin

Fix #7072 : can't create a feature when a layer has a join

History

#1 Updated by Nathan Woodrow almost 10 years ago

We are going to need some more information then that in order to track down the issue. What type of layer are you using?

#2 Updated by Philippe Dorelon almost 10 years ago

In fact, the bug appears when there is a join on the edited layer. I tested it with shape files, spatialite files on points and lines.

#3 Updated by Philippe Dorelon over 9 years ago

I think the problem is in qgsvectorlayereditbuffer.cpp : QgsVectorLayerEditBuffer::addFeature
This lines :

int layerFieldCount = L->dataProvider()->fields().count() + mAddedAttributes.count() - mDeletedAttributeIds.count();
  if ( layerFieldCount != f.attributes().count() )
    return false;

f.attributes().count() includes joinfields, layerFieldCount doesn't.

With something like that, it works:

int layerFieldJoinCount=0;
  for ( int i = 0; i < L->mUpdatedFields.count(); ++i )
  {
      if ( L->mUpdatedFields.fieldOrigin(i)==QgsFields::OriginJoin )
    {
        layerFieldJoinCount++;
    }
  }
  int layerFieldCount = L->dataProvider()->fields().count() + layerFieldJoinCount + mAddedAttributes.count() - mDeletedAttributeIds.count();

#4 Updated by Denis Rouzaud over 9 years ago

Does it make sense to have all joined fields in the edit form as they won't be used?

#5 Updated by Denis Rouzaud over 9 years ago

Should be fixed by these two requests:
https://github.com/qgis/Quantum-GIS/pull/576
https://github.com/qgis/Quantum-GIS/pull/546

Reply from Minoru:
I think it's right. In 1.8, joined fields are editable. Input values
are displayed in the attribute table, but their values are not saved
when I save the layer as a new file.
My patch1 does not hide joined fields in new feature form, but it
makes joined fields uneditable. As soon as we create a new feature on
join layer, fields in the joined table are bind to the new feature
corresponding to the value of the target field. I believe that editing
join layer should work well with two patches1[2].

#6 Updated by Nathan Woodrow over 9 years ago

What is the status of this?

#7 Updated by Nathan Woodrow over 9 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF