Skip to content

Commit 16a2cf3

Browse files
author
wonder
committed
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/qgis@12041 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 564ca7b commit 16a2cf3

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/core/qgsvectorlayer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,6 +2232,11 @@ bool QgsVectorLayer::setDataProvider( QString const & provider )
22322232
// deal with unnecessary schema qualification to make v.in.ogr happy
22332233
mDataSource = mDataProvider->dataSourceUri();
22342234
}
2235+
else if ( mProviderKey == "osm" )
2236+
{
2237+
// make sure that the "observer" has been removed from URI to avoid crashes
2238+
mDataSource = mDataProvider->dataSourceUri();
2239+
}
22352240

22362241
// label
22372242
mLabel = new QgsLabel( mDataProvider->fields() );

src/providers/osm/osmprovider.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,25 @@ QgsOSMDataProvider::QgsOSMDataProvider( QString uri )
9393
}
9494
if ( propName == "observer" )
9595
{
96+
// remove observer from the URI
97+
// (because otherwise it would be saved into project file and would cause crashes)
98+
QString newProps;
99+
foreach ( QString p , props )
100+
{
101+
if (!p.startsWith("observer"))
102+
{
103+
if (!newProps.isEmpty())
104+
newProps += "&";
105+
newProps += p;
106+
}
107+
}
108+
QString newUri = uri.left( fileNameEnd + 1 ) + newProps;
109+
setDataSourceUri(newUri);
110+
96111
ulong observerAddr = propValue.toULong();
97112
mInitObserver = ( QObject* ) observerAddr;
98113
mInitObserver->setProperty( "osm_state", QVariant( 1 ) );
114+
99115
}
100116
if ( propName == "tag" )
101117
{

0 commit comments

Comments
 (0)