Skip to content

Commit

Permalink
Merge pull request #5552 from elpaso/vector_layer_safe_cast
Browse files Browse the repository at this point in the history
[bugfix] Prevent a bad crash when provider is wrong
  • Loading branch information
elpaso authored Nov 7, 2017
2 parents bb36fa7 + 2523d73 commit a22e565
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down

0 comments on commit a22e565

Please sign in to comment.