Skip to content

Commit 83da570

Browse files
mhugentnyalldawson
authored andcommittedAug 10, 2018
Fix QgsClipboard::retrieveFields and adapt unit test (because features without geometries are now allowed in QgsClipboard)
1 parent 036000f commit 83da570

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed
 

‎src/app/qgsclipboard.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,22 @@ QgsFields QgsClipboard::retrieveFields() const
255255
QgsFields f = QgsOgrUtils::stringToFields( string, QTextCodec::codecForName( "System" ) );
256256
if ( f.size() < 1 )
257257
{
258+
if ( string.isEmpty() )
259+
{
260+
return f;
261+
}
262+
258263
//wkt?
259264
QStringList lines = string.split( "\n" );
260265
if ( lines.size() > 0 )
261266
{
262267
QStringList fieldNames = lines.at( 0 ).split( "\t" );
268+
//wkt / text always has wkt_geom as first attribute (however values can be NULL)
269+
if ( fieldNames.at( 0 ) != "wkt_geom" )
270+
{
271+
return f;
272+
}
273+
263274
for ( int i = 0; i < fieldNames.size(); ++i )
264275
{
265276
QString fieldName = fieldNames.at( i );

‎tests/src/app/testqgisappclipboard.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,10 @@ void TestQgisAppClipboard::pasteWkt()
241241
QCOMPARE( point->x(), 125.0 );
242242
QCOMPARE( point->y(), 10.0 );
243243

244-
// only fields => no geom so no feature list is returned
244+
//clipboard now supports features without geometry
245245
mQgisApp->clipboard()->setText( QStringLiteral( "MNL 11 282 km \nMNL 11 347.80000000000001 km " ) );
246246
features = mQgisApp->clipboard()->copyOf();
247-
QCOMPARE( features.length(), 0 );
247+
QCOMPARE( features.length(), 2 );
248248
}
249249

250250
void TestQgisAppClipboard::pasteGeoJson()

0 commit comments

Comments
 (0)
Please sign in to comment.