Skip to content

Commit

Permalink
Fix relation reference widget test crashes under debug builds
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] authored and nirvn committed Feb 28, 2020
1 parent b79cba2 commit 9287a0e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/src/gui/testqgsrelationreferencewidget.cpp
Expand Up @@ -58,17 +58,23 @@ 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()
{
QgsApplication::init();
QgsApplication::initQgis();
QgsGui::editorWidgetRegistry()->initEditors();
mMapCanvas = new QgsMapCanvas();
mCadWidget = new QgsAdvancedDigitizingDockWidget( mMapCanvas );
}

void TestQgsRelationReferenceWidget::cleanupTestCase()
{
delete mCadWidget;
delete mMapCanvas;
QgsApplication::exitQgis();
}

Expand Down Expand Up @@ -314,11 +320,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 );
}

Expand Down

0 comments on commit 9287a0e

Please sign in to comment.