fix crash from #2067. anyway loading of osm layers with custom renderers doesn't work (and won't work because of technical limitations)

git-svn-id: http://svn.osgeo.org/qgis/trunk@12041 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
wonder 2009-11-08 23:12:34 +00:00
parent c1b360bd93
commit 61d45be928
2 changed files with 21 additions and 0 deletions

View File

@ -2232,6 +2232,11 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )
// deal with unnecessary schema qualification to make v.in.ogr happy // deal with unnecessary schema qualification to make v.in.ogr happy
mDataSource = mDataProvider->dataSourceUri(); mDataSource = mDataProvider->dataSourceUri();
} }
else if ( mProviderKey == "osm" )
{
// make sure that the "observer" has been removed from URI to avoid crashes
mDataSource = mDataProvider->dataSourceUri();
}
// label // label
mLabel = new QgsLabel( mDataProvider->fields() ); mLabel = new QgsLabel( mDataProvider->fields() );

View File

@ -93,9 +93,25 @@ QgsOSMDataProvider::QgsOSMDataProvider( QString uri )
} }
if ( propName == "observer" ) if ( propName == "observer" )
{ {
// remove observer from the URI
// (because otherwise it would be saved into project file and would cause crashes)
QString newProps;
foreach ( QString p , props )
{
if (!p.startsWith("observer"))
{
if (!newProps.isEmpty())
newProps += "&";
newProps += p;
}
}
QString newUri = uri.left( fileNameEnd + 1 ) + newProps;
setDataSourceUri(newUri);
ulong observerAddr = propValue.toULong(); ulong observerAddr = propValue.toULong();
mInitObserver = ( QObject* ) observerAddr; mInitObserver = ( QObject* ) observerAddr;
mInitObserver->setProperty( "osm_state", QVariant( 1 ) ); mInitObserver->setProperty( "osm_state", QVariant( 1 ) );
} }
if ( propName == "tag" ) if ( propName == "tag" )
{ {