Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bb4650d

Browse files
committedMar 13, 2019
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...
1 parent 1f95ab6 commit bb4650d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,18 @@ static QgsMessageOutput *messageOutputViewer_()
540540

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

546557
void QgisApp::emitCustomCrsValidation( QgsCoordinateReferenceSystem &srs )

0 commit comments

Comments
 (0)
Please sign in to comment.