<div dir="ltr">Hi All, <div><br></div><div style="">I've discovered an issue with QgsVectorLayerUndoCommand class (QgsVectorLayerUndoCommandChangeAttribute.undo() method) when updating an attribute value after featureAdded SIGNAL is emitted. </div><div style=""><br></div><div style="">Steps to reproduce: </div><div style=""><br></div><div style="">1. Open QGIS, load a sample vector layer like this ( <a href="http://downloads.tuxfamily.org/tuxgis/tmp/test_point.zip">http://downloads.tuxfamily.org/tuxgis/tmp/test_point.zip</a> ) and select it in the Layer List Widget (ToC).</div><div style="">2. Run the following code snippet into the QGIS Python Console to connect featureAdded SIGNAL  to a custom SLOT that changes an attribute value:</div><div style=""><br></div><div style="">##################</div><div style=""><div>myLayer = iface.activeLayer()</div><div>field = 0   # Please use the test Shapefile provided, if not, adjust the field index</div><div><br></div><div>def updateFeatureAttrs( fId ):</div><div>    f = myLayer.getFeatures( QgsFeatureRequest( fId ) ).next()    </div><div>    geom = f.geometry() </div><div>    myLayer.changeAttributeValue( fId, field, geom.asPoint().x() )</div><div><br></div><div>myLayer.featureAdded.connect( updateFeatureAttrs )</div></div><div style="">##################</div><div style=""><br></div><div style="">3. Start editing. Add a new point. (If a form opens click on OK). Don't save anything.</div><div style="">4. Stop editing and choose "Close without saving."</div><div style="">5. QGIS crashes and prints the following error message:</div><div style=""><br></div><div style="">%%%%%%%%%%%%%%%%%%%</div><div style=""><div>Fatal: ASSERT: "it != mBuffer->mAddedFeatures.end()" in file /tmp/buildd/qgis-2.14.2+20trusty/src/core/qgsvectorlayerundocommand.cpp, line 255</div><div>Stacktrace (piped through c++filt):</div><div>/usr/bin/qgis.bin[0x40a440]</div><div>/usr/bin/qgis.bin[0x40a548]</div><div>/usr/lib/x86_64-linux-gnu/libQtCore.so.4(qt_message_output(QtMsgType, char const*)+0x21)[0x7fd508939bb1]</div><div>/usr/lib/x86_64-linux-gnu/libQtCore.so.4(+0x70ff9)[0x7fd508939ff9]</div><div>/usr/lib/x86_64-linux-gnu/libQtCore.so.4(qFatal(char const*, ...)+0x94)[0x7fd50893a804]</div><div>/usr/lib/libqgis_core.so.2.14.2(QgsVectorLayerUndoCommandChangeAttribute::undo()+0x659)[0x7fd5092e2c09]</div><div>/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QUndoCommand::undo()+0x50)[0x7fd5084144e0]</div><div>/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QUndoStack::setIndex(int)+0xc8)[0x7fd508414e58]</div><div>/usr/lib/libqgis_core.so.2.14.2(QgsVectorLayerEditBuffer::rollBack()+0x23)[0x7fd5092c4d43]</div><div>/usr/lib/libqgis_core.so.2.14.2(QgsVectorLayer::rollBack(bool)+0x46)[0x7fd5092b81e6]</div><div>/usr/lib/libqgis_app.so.2.14.2(QgisApp::toggleEditing(QgsMapLayer*, bool)+0xb4b)[0x7fd50a1b677b]</div><div>/usr/lib/libqgis_app.so.2.14.2(+0x478d41)[0x7fd50a4edd41]</div><div>/usr/lib/x86_64-linux-gnu/libQtCore.so.4(QMetaObject::activate(QObject*, QMetaObject const*, int, void**)+0x2da)[0x7fd508a5a87a]</div><div>/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QAction::triggered(bool)+0x32)[0x7fd507dd9a62]</div><div>/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QAction::activate(QAction::ActionEvent)+0x63)[0x7fd507ddb433]</div><div>/usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x57cb02)[0x7fd508192b02]</div><div>/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QAbstractButton::mouseReleaseEvent(QMouseEvent*)+0x6c)[0x7fd508192c2c]</div><div>/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QToolButton::mouseReleaseEvent(QMouseEvent*)+0xa)[0x7fd508249a4a]</div><div>/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QWidget::event(QEvent*)+0xaca)[0x7fd507e2f50a]</div><div>/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QApplicationPrivate::notify_helper(QObject*, QEvent*)+0x8c)[0x7fd507ddfe2c]</div><div>/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QApplication::notify(QObject*, QEvent*)+0x3ad)[0x7fd507de65dd]</div><div>/usr/lib/libqgis_core.so.2.14.2(QgsApplication::notify(QObject*, QEvent*)+0x5b)[0x7fd509049c8b]</div><div>/usr/lib/x86_64-linux-gnu/libQtCore.so.4(QCoreApplication::notifyInternal(QObject*, QEvent*)+0x6d)[0x7fd508a464dd]</div><div>/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QApplicationPrivate::sendMouseEvent(QWidget*, QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&, bool)+0x153)[0x7fd507de5d93]</div><div>/usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x2449cb)[0x7fd507e5a9cb]</div><div>/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QApplication::x11ProcessEvent(_XEvent*)+0x1559)[0x7fd507e5a269]</div><div>/usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x26bb02)[0x7fd507e81b02]</div><div>/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x254)[0x7fd500ceee04]</div><div>/lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x49048)[0x7fd500cef048]</div><div>/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_iteration+0x2c)[0x7fd500cef0ec]</div><div>/usr/lib/x86_64-linux-gnu/libQtCore.so.4(QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)+0x71)[0x7fd508a737a1]</div><div>/usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x26bbb6)[0x7fd507e81bb6]</div><div>/usr/lib/x86_64-linux-gnu/libQtCore.so.4(QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)+0x2f)[0x7fd508a450af]</div><div>/usr/lib/x86_64-linux-gnu/libQtCore.so.4(QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)+0x175)[0x7fd508a453a5]</div><div>/usr/lib/x86_64-linux-gnu/libQtCore.so.4(QCoreApplication::exec()+0x89)[0x7fd508a4ab79]</div><div>/usr/bin/qgis.bin[0x406fd7]</div><div>/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7fd507358ec5]</div><div>/usr/bin/qgis.bin[0x409d48]</div><div>Aborted</div></div><div style="">%%%%%%%%%%%%%%%%%%%</div><div style=""><br></div><div style=""><br></div><div style="">I've tested both Shapefiles and SpatiaLite layers, getting the same error.</div><div style=""><br></div><div style=""><br></div><div style="">Do you have an idea of what could be happening?</div><div style=""><br></div><div style="">I'm using QGIS v.2.14.2 on a Linux Mint machine.</div><div><br></div><div><br></div><div>Regards, </div><div><br></div><div>Germán<br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div>-----------<br></div><div>   |\__  <br>(:>__)(<br>   |/    <br>Soluciones Geoinformáticas Libres                            <br><a href="http://geotux.tuxfamily.org/" target="_blank">http://geotux.tuxfamily.org/</a><br><a href="http://twitter.com/GeoTux2" target="_blank">http://twitter.com/GeoTux2</a></div><div><a href="http://about.me/germancarrillo" target="_blank">http://about.me/germancarrillo</a><br></div><div><div><br></div><div><a href="http://gis.stackexchange.com/users/4972/germ%c3%a1n-carrillo" target="_blank"><img src="http://gis.stackexchange.com/users/flair/4972.png"></a></div></div></div></div></div></div></div>
</div></div>