Skip to content

Commit

Permalink
when manually loading layers defer loading default style until the la…
Browse files Browse the repository at this point in the history
…yers is

added to the registry so that the readCustomSymbology signal can be processed
by the edit widget registry (fixes #11516)
  • Loading branch information
jef-n committed Oct 30, 2014
1 parent 18db8c0 commit dfff717
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3145,7 +3145,7 @@ void QgisApp::loadOGRSublayers( QString layertype, QString uri, QStringList list
QgsDebugMsg( "Creating new vector layer using " + composedURI );
QString name = list.at( i );
name.replace( ":", " " );
QgsVectorLayer *layer = new QgsVectorLayer( composedURI, name, "ogr" );
QgsVectorLayer *layer = new QgsVectorLayer( composedURI, name, "ogr", false );
if ( layer && layer->isValid() )
{
myList << layer;
Expand All @@ -3163,6 +3163,11 @@ void QgisApp::loadOGRSublayers( QString layertype, QString uri, QStringList list
{
// Register layer(s) with the layers registry
QgsMapLayerRegistry::instance()->addMapLayers( myList );
foreach( QgsMapLayer *l, myList )
{
bool ok;
l->loadDefaultStyle(ok);
}
}
}

Expand Down Expand Up @@ -3212,7 +3217,7 @@ void QgisApp::addDatabaseLayers( QStringList const & layerPathList, QString cons
// create the layer
QgsDataSourceURI uri( layerPath );

QgsVectorLayer *layer = new QgsVectorLayer( uri.uri(), uri.table(), providerKey );
QgsVectorLayer *layer = new QgsVectorLayer( uri.uri(), uri.table(), providerKey, false );
Q_CHECK_PTR( layer );

if ( ! layer )
Expand Down Expand Up @@ -3245,6 +3250,13 @@ void QgisApp::addDatabaseLayers( QStringList const & layerPathList, QString cons

QgsMapLayerRegistry::instance()->addMapLayers( myList );

// load default style after adding to process readCustomSymbology signals
foreach ( QgsMapLayer *l, myList )
{
bool ok;
l->loadDefaultStyle( ok );
}

// draw the map
mMapCanvas->freeze( false );
mMapCanvas->refresh();
Expand Down Expand Up @@ -7760,7 +7772,7 @@ QgsVectorLayer* QgisApp::addVectorLayer( QString vectorLayerPath, QString baseNa
+ " and providerKey of " + providerKey );

// create the layer
QgsVectorLayer *layer = new QgsVectorLayer( vectorLayerPath, baseName, providerKey );
QgsVectorLayer *layer = new QgsVectorLayer( vectorLayerPath, baseName, providerKey, false );

if ( layer && layer->isValid() )
{
Expand All @@ -7784,6 +7796,8 @@ QgsVectorLayer* QgisApp::addVectorLayer( QString vectorLayerPath, QString baseNa
QList<QgsMapLayer *> myList;
myList << layer;
QgsMapLayerRegistry::instance()->addMapLayers( myList );
bool ok;
layer->loadDefaultStyle( ok );
}
}
else
Expand Down

0 comments on commit dfff717

Please sign in to comment.