Fix relation reference widget test crashes under debug builds

Because of the new assert in QgsMapToolAdvancedDigitizing requiring
the cad widget

Not the cleanest fix -- the widget should gracefully handle having
no cad widget available by disabling the digiting tool instead, but
we urgently need the CI infrastructure to stop flagging everything because
of this change.
This commit is contained in:
Nyall Dawson 2020-02-28 10:49:36 +10:00
parent 12ff1b373b
commit eed9173c2b

View File

@ -60,6 +60,8 @@ class TestQgsRelationReferenceWidget : public QObject
std::unique_ptr<QgsVectorLayer> mLayer1;
std::unique_ptr<QgsVectorLayer> mLayer2;
std::unique_ptr<QgsRelation> mRelation;
QgsMapCanvas *mMapCanvas = nullptr;
QgsAdvancedDigitizingDockWidget *mCadWidget = nullptr;
};
void TestQgsRelationReferenceWidget::initTestCase()
@ -67,10 +69,14 @@ void TestQgsRelationReferenceWidget::initTestCase()
QgsApplication::init();
QgsApplication::initQgis();
QgsGui::editorWidgetRegistry()->initEditors();
mMapCanvas = new QgsMapCanvas();
mCadWidget = new QgsAdvancedDigitizingDockWidget( mMapCanvas );
}
void TestQgsRelationReferenceWidget::cleanupTestCase()
{
delete mCadWidget;
delete mMapCanvas;
QgsApplication::exitQgis();
}
@ -342,11 +348,16 @@ void TestQgsRelationReferenceWidget::testChainFilterDeleteForeignKey()
void TestQgsRelationReferenceWidget::testInvalidRelation()
{
QgsVectorLayer vl( QStringLiteral( "LineString?crs=epsg:3111&field=pk:int&field=fk:int" ), QStringLiteral( "vl1" ), QStringLiteral( "memory" ) );
QgsMapCanvas canvas;
QgsRelationReferenceWidget editor( new QWidget() );
// initWidget with an invalid relation
QgsRelationReferenceWidgetWrapper ww( &vl, 10, &editor, &canvas, nullptr, nullptr );
QgsRelationReferenceWidgetWrapper ww( &vl, 10, &editor, mMapCanvas, nullptr, nullptr );
QgsAttributeEditorContext context = ww.context();
context.setCadDockWidget( mCadWidget );
ww.setContext( context );
ww.initWidget( nullptr );
}