Skip to content
Permalink
Browse files

Layer CRS validation is NOT thread safe, and can cause crashes

when a layer with unknown CRS is loaded in a background thread

We can't queue the connection to prompt for CRS (or warn via
messagebar), because the slot uses a modifiable reference which
may be deleted before the queued slot is called.

We also can't do ANY gui related stuff when this occurs. Best
we can do is log a warning and move on...
  • Loading branch information
nyalldawson committed Mar 13, 2019
1 parent 50c9a5e commit 5ca428d277e1e6f8d753662f86233b172316be53
Showing with 12 additions and 1 deletion.
  1. +12 −1 src/app/qgisapp.cpp
@@ -540,7 +540,18 @@ static QgsMessageOutput *messageOutputViewer_()

static void customSrsValidation_( QgsCoordinateReferenceSystem &srs )
{
QgisApp::instance()->emitCustomCrsValidation( srs );
if ( QThread::currentThread() != QApplication::instance()->thread() )
{
// Running in a background thread -- we can't queue this connection, because
// srs is a reference and may be deleted before the queued slot is called.
// We also can't do ANY gui related stuff here. Best we can do is log
// a warning and move on...
QgsMessageLog::logMessage( QObject::tr( "Layer has unknown CRS" ) );
}
else
{
QgisApp::instance()->emitCustomCrsValidation( srs );
}
}

void QgisApp::emitCustomCrsValidation( QgsCoordinateReferenceSystem &srs )

0 comments on commit 5ca428d

Please sign in to comment.
You can’t perform that action at this time.