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 4db84a0

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 48068c2 commit 4db84a0

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
@@ -527,7 +527,18 @@ static QgsMessageOutput *messageOutputViewer_()
527527

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

533544
void QgisApp::emitCustomCrsValidation( QgsCoordinateReferenceSystem &srs )

0 commit comments

Comments
 (0)
Please sign in to comment.