Skip to content
Permalink
Browse files

Merge pull request #5552 from elpaso/vector_layer_safe_cast

[bugfix] Prevent a bad crash when provider is wrong
  • Loading branch information
elpaso committed Nov 7, 2017
2 parents bb36fa7 + 2523d73 commit a22e565dc2238205a3cd1a0b704ce654c36cffee
Showing with 1 addition and 5 deletions.
  1. +1 −5 src/core/qgsvectorlayer.cpp
@@ -1530,12 +1530,8 @@ bool QgsVectorLayer::setDataProvider( QString const &provider )
dataSource = uri.uri( false );
}

// XXX when execution gets here.

//XXX - This was a dynamic cast but that kills the Windows
// version big-time with an abnormal termination error
delete mDataProvider;
mDataProvider = ( QgsVectorDataProvider * )( QgsProviderRegistry::instance()->createProvider( provider, dataSource ) );
mDataProvider = qobject_cast<QgsVectorDataProvider *>( QgsProviderRegistry::instance()->createProvider( provider, dataSource ) );
if ( !mDataProvider )
{
QgsDebugMsg( " unable to get data provider" );

0 comments on commit a22e565

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