Skip to content
Permalink
Browse files

Avoid detaching temporary containers

  • Loading branch information
nyalldawson committed May 10, 2016
1 parent e25ffc4 commit a3d6227e2e72993614b7eb72cf2ab547d21e4eb8
@@ -189,7 +189,7 @@ void QgsVectorFileWriter::init( QString vectorFileName,
OGRSFDriverH poDriver;
QgsApplication::registerOgrDrivers();

poDriver = OGRGetDriverByName( mOgrDriverName.toLocal8Bit().data() );
poDriver = OGRGetDriverByName( mOgrDriverName.toLocal8Bit().constData() );

if ( !poDriver )
{
@@ -284,7 +284,7 @@ void QgsVectorFileWriter::init( QString vectorFileName,
options = new char *[ datasourceOptions.size()+1 ];
for ( int i = 0; i < datasourceOptions.size(); i++ )
{
options[i] = CPLStrdup( datasourceOptions[i].toLocal8Bit().data() );
options[i] = CPLStrdup( datasourceOptions[i].toLocal8Bit().constData() );
}
options[ datasourceOptions.size()] = nullptr;
}
@@ -332,7 +332,7 @@ void QgsVectorFileWriter::init( QString vectorFileName,
{
QString srsWkt = srs->toWkt();
QgsDebugMsg( "WKT to save as is " + srsWkt );
mOgrRef = OSRNewSpatialReference( srsWkt.toLocal8Bit().data() );
mOgrRef = OSRNewSpatialReference( srsWkt.toLocal8Bit().constData() );
}

// datasource created, now create the output layer
@@ -351,7 +351,7 @@ void QgsVectorFileWriter::init( QString vectorFileName,
options = new char *[ layerOptions.size()+1 ];
for ( int i = 0; i < layerOptions.size(); i++ )
{
options[i] = CPLStrdup( layerOptions[i].toLocal8Bit().data() );
options[i] = CPLStrdup( layerOptions[i].toLocal8Bit().constData() );
}
options[ layerOptions.size()] = nullptr;
}
@@ -384,7 +384,7 @@ void QgsVectorFileWriter::init( QString vectorFileName,
if ( prjFile.open( QIODevice::WriteOnly ) )
{
QTextStream prjStream( &prjFile );
prjStream << srs->toWkt().toLocal8Bit().data() << endl;
prjStream << srs->toWkt().toLocal8Bit().constData() << endl;
prjFile.close();
}
else
@@ -1827,15 +1827,15 @@ bool QgsVectorFileWriter::addFeature( QgsFeature& feature, QgsFeatureRendererV2*
}
else if ( mSymbologyExport == SymbolLayerSymbology )
{
OGR_F_SetStyleString( poFeature, currentStyle.toLocal8Bit().data() );
OGR_F_SetStyleString( poFeature, currentStyle.toLocal8Bit().constData() );
if ( !writeFeature( mLayer, poFeature ) )
{
return false;
}
}
}
}
OGR_F_SetStyleString( poFeature, styleString.toLocal8Bit().data() );
OGR_F_SetStyleString( poFeature, styleString.toLocal8Bit().constData() );
}

if ( mSymbologyExport == NoSymbology || mSymbologyExport == FeatureSymbology )
@@ -1899,7 +1899,7 @@ OGRFeatureH QgsVectorFileWriter::createFeature( QgsFeature& feature )
OGR_F_SetFieldInteger64( poFeature, ogrField, attrValue.toLongLong() );
break;
case QVariant::String:
OGR_F_SetFieldString( poFeature, ogrField, mCodec->fromUnicode( attrValue.toString() ).data() );
OGR_F_SetFieldString( poFeature, ogrField, mCodec->fromUnicode( attrValue.toString() ).constData() );
break;
#else
case QVariant::Int:
@@ -1909,7 +1909,7 @@ OGRFeatureH QgsVectorFileWriter::createFeature( QgsFeature& feature )
case QVariant::LongLong:
case QVariant::UInt:
case QVariant::ULongLong:
OGR_F_SetFieldString( poFeature, ogrField, mCodec->fromUnicode( attrValue.toString() ).data() );
OGR_F_SetFieldString( poFeature, ogrField, mCodec->fromUnicode( attrValue.toString() ).constData() );
break;
#endif
case QVariant::Double:
@@ -1925,7 +1925,7 @@ OGRFeatureH QgsVectorFileWriter::createFeature( QgsFeature& feature )
case QVariant::DateTime:
if ( mOgrDriverName == "ESRI Shapefile" )
{
OGR_F_SetFieldString( poFeature, ogrField, mCodec->fromUnicode( attrValue.toDateTime().toString( "yyyy/MM/dd hh:mm:ss.zzz" ) ).data() );
OGR_F_SetFieldString( poFeature, ogrField, mCodec->fromUnicode( attrValue.toDateTime().toString( "yyyy/MM/dd hh:mm:ss.zzz" ) ).constData() );
}
else
{
@@ -1942,7 +1942,7 @@ OGRFeatureH QgsVectorFileWriter::createFeature( QgsFeature& feature )
case QVariant::Time:
if ( mOgrDriverName == "ESRI Shapefile" )
{
OGR_F_SetFieldString( poFeature, ogrField, mCodec->fromUnicode( attrValue.toString() ).data() );
OGR_F_SetFieldString( poFeature, ogrField, mCodec->fromUnicode( attrValue.toString() ).constData() );
}
else
{
@@ -2517,11 +2517,11 @@ QMap<QString, QString> QgsVectorFileWriter::ogrDriverList()
// -> test if creation failes
QString option = "SPATIALITE=YES";
char **options = new char *[2];
options[0] = CPLStrdup( option.toLocal8Bit().data() );
options[0] = CPLStrdup( option.toLocal8Bit().constData() );
options[1] = nullptr;
OGRSFDriverH poDriver;
QgsApplication::registerOgrDrivers();
poDriver = OGRGetDriverByName( drvName.toLocal8Bit().data() );
poDriver = OGRGetDriverByName( drvName.toLocal8Bit().constData() );
if ( poDriver )
{
OGRDataSourceH ds = OGR_Dr_CreateDataSource( poDriver, TO8F( QString( "/vsimem/spatialitetest.sqlite" ) ), options );
@@ -2972,7 +2972,7 @@ QgsVectorFileWriter::WriterError QgsVectorFileWriter::exportFeaturesSymbolLevels
QString styleString = levelIt.key()->symbolLayer( llayer )->ogrFeatureStyle( mmsf, musf );
if ( !styleString.isEmpty() )
{
OGR_F_SetStyleString( ogrFeature, styleString.toLocal8Bit().data() );
OGR_F_SetStyleString( ogrFeature, styleString.toLocal8Bit().constData() );
if ( !writeFeature( mLayer, ogrFeature ) )
{
++nErrors;
@@ -484,7 +484,7 @@ QPolygonF curvedArrow( QPointF po, QPointF pm, QPointF pd, qreal startWidth, qre
path.lineTo( circlePoint( circleCenter, circleRadius + direction * width / 2, angle_o + headAngle ) );
}

return path.toSubpathPolygons()[0];
return path.toSubpathPolygons().at( 0 );
}

void QgsArrowSymbolLayer::_resolveDataDefined( QgsSymbolV2RenderContext& context )
@@ -192,7 +192,7 @@ QWidget* QgsAttributeTableView::createActionWidget( QgsFeatureId fid )
}

if ( toolButton && !toolButton->actions().isEmpty() && actions->defaultAction() == -1 )
toolButton->setDefaultAction( toolButton->actions().first() );
toolButton->setDefaultAction( toolButton->actions().at( 0 ) );

return container;
}
@@ -150,7 +150,7 @@ void checkDock::deleteErrors()

void checkDock::parseErrorListByLayer( const QString& layerId )
{
QgsVectorLayer *layer = qobject_cast<QgsVectorLayer*>( mLayerRegistry->mapLayers()[layerId] );
QgsVectorLayer *layer = qobject_cast<QgsVectorLayer*>( mLayerRegistry->mapLayer( layerId ) );
QList<TopolError*>::Iterator it = mErrorList.begin();

while ( it != mErrorList.end() )
@@ -334,11 +334,11 @@ void checkDock::runTests( ValidateType type )
return;
}

QgsVectorLayer* layer1 = ( QgsVectorLayer* )mLayerRegistry->mapLayers()[layer1Str];
QgsVectorLayer* layer1 = ( QgsVectorLayer* )mLayerRegistry->mapLayer( layer1Str );
QgsVectorLayer* layer2 = nullptr;

if (( QgsVectorLayer* )mLayerRegistry->mapLayers().contains( layer2Str ) )
layer2 = ( QgsVectorLayer* )mLayerRegistry->mapLayers()[layer2Str];
layer2 = ( QgsVectorLayer* )mLayerRegistry->mapLayer( layer2Str );

QProgressDialog progress( testName, tr( "Abort" ), 0, layer1->featureCount(), this );
progress.setWindowModality( Qt::WindowModal );
@@ -94,7 +94,7 @@ void rulesDialog::readTest( int index, QgsMapLayerRegistry* layerRegistry )
if ( !( QgsVectorLayer* )layerRegistry->mapLayers().contains( layer1Id ) )
return;

l1 = ( QgsVectorLayer* )layerRegistry->mapLayers()[layer1Id];
l1 = ( QgsVectorLayer* )layerRegistry->mapLayer( layer1Id );
if ( !l1 )
return;

@@ -108,7 +108,7 @@ void rulesDialog::readTest( int index, QgsMapLayerRegistry* layerRegistry )
return;
else
{
l2 = ( QgsVectorLayer* )layerRegistry->mapLayers()[layer2Id];
l2 = ( QgsVectorLayer* )layerRegistry->mapLayer( layer2Id );
layer2Name = l2->name();
}
}
@@ -175,7 +175,7 @@ void rulesDialog::showControls( const QString& testName )
mLayer2Box->setVisible( true );
for ( int i = 0; i < layerList.count(); ++i )
{
QgsVectorLayer* v1 = ( QgsVectorLayer* )layerRegistry->mapLayers()[layerList[i]];
QgsVectorLayer* v1 = ( QgsVectorLayer* )layerRegistry->mapLayer( layerList[i] );

if ( !v1 )
{
@@ -319,7 +319,7 @@ void rulesDialog::updateRuleItems( const QString &layerName )
QString layerId = mLayer1Box->itemData( mLayer1Box->currentIndex() ).toString();

QgsMapLayerRegistry* layerRegistry = QgsMapLayerRegistry::instance();
QgsVectorLayer* vlayer = ( QgsVectorLayer* )layerRegistry->mapLayers()[layerId];
QgsVectorLayer* vlayer = ( QgsVectorLayer* )layerRegistry->mapLayer( layerId );

if ( !vlayer )
{
@@ -353,7 +353,7 @@ void rulesDialog::initGui()
mLayer1Box->blockSignals( true );
for ( int i = 0; i < layerList.size(); ++i )
{
QgsVectorLayer* v1 = ( QgsVectorLayer* )layerRegistry->mapLayers()[layerList[i]];
QgsVectorLayer* v1 = ( QgsVectorLayer* )layerRegistry->mapLayer( layerList[i] );
qDebug() << "layerid = " + layerList[i];

// add layer name to the layer combo boxes
@@ -90,7 +90,8 @@ bool TopolError::fixSnap()
const QgsGeometry* ge = f1.constGeometry();

QgsPolyline line = ge->asPolyline();
line.last() = mConflict->asPolyline().last();
QgsPolyline conflictLine = mConflict->asPolyline();
line.last() = conflictLine.last();

QgsGeometry* newG = QgsGeometry::fromPolyline( line );
bool ret = fl.layer->changeGeometry( f1.id(), newG );
@@ -1256,8 +1256,9 @@ ErrorList topolTest::checkPointCoveredByLineEnds( double tolerance, QgsVectorLay
QgsMessageLog::logMessage( tr( "Second geometry missing or GEOS import failed." ), tr( "Topology plugin" ) );
continue;
}
QgsGeometry* startPoint = QgsGeometry::fromPoint( g2->asPolyline().at( 0 ) );
QgsGeometry* endPoint = QgsGeometry::fromPoint( g2->asPolyline().last() );
QgsPolyline g2Line = g2->asPolyline();
QgsGeometry* startPoint = QgsGeometry::fromPoint( g2Line.at( 0 ) );
QgsGeometry* endPoint = QgsGeometry::fromPoint( g2Line.last() );
touched = g1->intersects( startPoint ) || g1->intersects( endPoint );
delete startPoint;
delete endPoint;
@@ -1322,8 +1323,9 @@ ErrorList topolTest::checkyLineEndsCoveredByPoints( double tolerance, QgsVectorL
break;
QgsGeometry* g1 = it->feature.geometry();

QgsGeometry* startPoint = QgsGeometry::fromPoint( g1->asPolyline().at( 0 ) );
QgsGeometry* endPoint = QgsGeometry::fromPoint( g1->asPolyline().last() );
QgsPolyline g1Polyline = g1->asPolyline();
QgsGeometry* startPoint = QgsGeometry::fromPoint( g1Polyline.at( 0 ) );
QgsGeometry* endPoint = QgsGeometry::fromPoint( g1Polyline.last() );

QgsRectangle bb = g1->boundingBox();
QList<QgsFeatureId> crossingIds;
@@ -1680,7 +1682,6 @@ ErrorList topolTest::runTest( const QString& testName, QgsVectorLayer* layer1, Q
return errors;
}

QString secondLayerId;
mFeatureList1.clear();
mFeatureMap2.clear();

@@ -1705,8 +1706,6 @@ ErrorList topolTest::runTest( const QString& testName, QgsVectorLayer* layer1, Q
fillFeatureList( layer1, extent );
//fillFeatureMap( layer1, extent );

QString secondLayerId = layer2->id();

if ( !mLayerIndexes.contains( layer2->id() ) )
{
mLayerIndexes[layer2->id()] = createIndex( layer2, extent );
@@ -118,11 +118,13 @@ void TestQgsGML::testFromByteArray()
QgsGml gmlParser( "mytypename", "mygeom", fields );
QGis::WkbType wkbType;
QCOMPARE( gmlParser.getFeatures( data1.toAscii(), &wkbType ), 0 );
QCOMPARE( gmlParser.featuresMap().size(), 1 );
QVERIFY( gmlParser.featuresMap().find( 0 ) != gmlParser.featuresMap().end() );
QCOMPARE( gmlParser.featuresMap()[0]->attributes().size(), 1 );
QVERIFY( gmlParser.idsMap().find( 0 ) != gmlParser.idsMap().end() );
QCOMPARE( gmlParser.idsMap()[0], QString( "mytypename.1" ) );
QMap<QgsFeatureId, QgsFeature* > featureMaps = gmlParser.featuresMap();
QCOMPARE( featureMaps.size(), 1 );
QVERIFY( featureMaps.constFind( 0 ) != featureMaps.constEnd() );
QCOMPARE( featureMaps[ 0 ]->attributes().size(), 1 );
QMap<QgsFeatureId, QString > idsMap = gmlParser.idsMap();
QVERIFY( idsMap.constFind( 0 ) != idsMap.constEnd() );
QCOMPARE( idsMap[ 0 ], QString( "mytypename.1" ) );
}

void TestQgsGML::testStreamingParser()

0 comments on commit a3d6227

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