[Qgis-developer] Issue with QgsVectorLayerUndoCommand class (QGIS crashes)

Germán Carrillo carrillo.german at gmail.com
Fri Jul 15 10:26:51 PDT 2016


Hi All,

I've discovered an issue with QgsVectorLayerUndoCommand class
(QgsVectorLayerUndoCommandChangeAttribute.undo() method) when updating an
attribute value after featureAdded SIGNAL is emitted.

Steps to reproduce:

1. Open QGIS, load a sample vector layer like this (
http://downloads.tuxfamily.org/tuxgis/tmp/test_point.zip ) and select it in
the Layer List Widget (ToC).
2. Run the following code snippet into the QGIS Python Console to connect
featureAdded SIGNAL  to a custom SLOT that changes an attribute value:

##################
myLayer = iface.activeLayer()
field = 0   # Please use the test Shapefile provided, if not, adjust the
field index

def updateFeatureAttrs( fId ):
    f = myLayer.getFeatures( QgsFeatureRequest( fId ) ).next()
    geom = f.geometry()
    myLayer.changeAttributeValue( fId, field, geom.asPoint().x() )

myLayer.featureAdded.connect( updateFeatureAttrs )
##################

3. Start editing. Add a new point. (If a form opens click on OK). Don't
save anything.
4. Stop editing and choose "Close without saving."
5. QGIS crashes and prints the following error message:

%%%%%%%%%%%%%%%%%%%
Fatal: ASSERT: "it != mBuffer->mAddedFeatures.end()" in file
/tmp/buildd/qgis-2.14.2+20trusty/src/core/qgsvectorlayerundocommand.cpp,
line 255
Stacktrace (piped through c++filt):
/usr/bin/qgis.bin[0x40a440]
/usr/bin/qgis.bin[0x40a548]
/usr/lib/x86_64-linux-gnu/libQtCore.so.4(qt_message_output(QtMsgType, char
const*)+0x21)[0x7fd508939bb1]
/usr/lib/x86_64-linux-gnu/libQtCore.so.4(+0x70ff9)[0x7fd508939ff9]
/usr/lib/x86_64-linux-gnu/libQtCore.so.4(qFatal(char const*,
...)+0x94)[0x7fd50893a804]
/usr/lib/libqgis_core.so.2.14.2(QgsVectorLayerUndoCommandChangeAttribute::undo()+0x659)[0x7fd5092e2c09]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QUndoCommand::undo()+0x50)[0x7fd5084144e0]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QUndoStack::setIndex(int)+0xc8)[0x7fd508414e58]
/usr/lib/libqgis_core.so.2.14.2(QgsVectorLayerEditBuffer::rollBack()+0x23)[0x7fd5092c4d43]
/usr/lib/libqgis_core.so.2.14.2(QgsVectorLayer::rollBack(bool)+0x46)[0x7fd5092b81e6]
/usr/lib/libqgis_app.so.2.14.2(QgisApp::toggleEditing(QgsMapLayer*,
bool)+0xb4b)[0x7fd50a1b677b]
/usr/lib/libqgis_app.so.2.14.2(+0x478d41)[0x7fd50a4edd41]
/usr/lib/x86_64-linux-gnu/libQtCore.so.4(QMetaObject::activate(QObject*,
QMetaObject const*, int, void**)+0x2da)[0x7fd508a5a87a]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QAction::triggered(bool)+0x32)[0x7fd507dd9a62]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QAction::activate(QAction::ActionEvent)+0x63)[0x7fd507ddb433]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x57cb02)[0x7fd508192b02]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QAbstractButton::mouseReleaseEvent(QMouseEvent*)+0x6c)[0x7fd508192c2c]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QToolButton::mouseReleaseEvent(QMouseEvent*)+0xa)[0x7fd508249a4a]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QWidget::event(QEvent*)+0xaca)[0x7fd507e2f50a]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QApplicationPrivate::notify_helper(QObject*,
QEvent*)+0x8c)[0x7fd507ddfe2c]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QApplication::notify(QObject*,
QEvent*)+0x3ad)[0x7fd507de65dd]
/usr/lib/libqgis_core.so.2.14.2(QgsApplication::notify(QObject*,
QEvent*)+0x5b)[0x7fd509049c8b]
/usr/lib/x86_64-linux-gnu/libQtCore.so.4(QCoreApplication::notifyInternal(QObject*,
QEvent*)+0x6d)[0x7fd508a464dd]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QApplicationPrivate::sendMouseEvent(QWidget*,
QMouseEvent*, QWidget*, QWidget*, QWidget**, QPointer<QWidget>&,
bool)+0x153)[0x7fd507de5d93]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x2449cb)[0x7fd507e5a9cb]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(QApplication::x11ProcessEvent(_XEvent*)+0x1559)[0x7fd507e5a269]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x26bb02)[0x7fd507e81b02]
/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x254)[0x7fd500ceee04]
/lib/x86_64-linux-gnu/libglib-2.0.so.0(+0x49048)[0x7fd500cef048]
/lib/x86_64-linux-gnu/libglib-2.0.so.0(g_main_context_iteration+0x2c)[0x7fd500cef0ec]
/usr/lib/x86_64-linux-gnu/libQtCore.so.4(QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)+0x71)[0x7fd508a737a1]
/usr/lib/x86_64-linux-gnu/libQtGui.so.4(+0x26bbb6)[0x7fd507e81bb6]
/usr/lib/x86_64-linux-gnu/libQtCore.so.4(QEventLoop::processEvents(QFlags<QEventLoop::ProcessEventsFlag>)+0x2f)[0x7fd508a450af]
/usr/lib/x86_64-linux-gnu/libQtCore.so.4(QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)+0x175)[0x7fd508a453a5]
/usr/lib/x86_64-linux-gnu/libQtCore.so.4(QCoreApplication::exec()+0x89)[0x7fd508a4ab79]
/usr/bin/qgis.bin[0x406fd7]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5)[0x7fd507358ec5]
/usr/bin/qgis.bin[0x409d48]
Aborted
%%%%%%%%%%%%%%%%%%%


I've tested both Shapefiles and SpatiaLite layers, getting the same error.


Do you have an idea of what could be happening?

I'm using QGIS v.2.14.2 on a Linux Mint machine.


Regards,

Germán

-- 
-----------
   |\__
(:>__)(
   |/
Soluciones Geoinformáticas Libres
http://geotux.tuxfamily.org/
http://twitter.com/GeoTux2
http://about.me/germancarrillo

<http://gis.stackexchange.com/users/4972/germ%c3%a1n-carrillo>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20160715/539f77b0/attachment-0001.html>


More information about the Qgis-developer mailing list