Skip to content

Commit 68fd061

Browse files
committedJun 14, 2014
vectorlayer: better matching of supported types (fixes #10564)
1 parent d8b54c4 commit 68fd061

File tree

2 files changed

+44
-16
lines changed

2 files changed

+44
-16
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6138,17 +6138,6 @@ void QgisApp::pasteStyle( QgsMapLayer * destinationLayer )
61386138
}
61396139
}
61406140

6141-
#if 0
6142-
void QgisApp::pasteTransformations()
6143-
{
6144-
QgsPasteTransformations *pt = new QgsPasteTransformations();
6145-
6146-
mMapCanvas->freeze();
6147-
6148-
pt->exec();
6149-
}
6150-
#endif
6151-
61526141
void QgisApp::copyFeatures( QgsFeatureStore & featureStore )
61536142
{
61546143
clipboard()->replaceWithCopyOf( featureStore );

‎src/core/qgsvectordataprovider.cpp

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,13 +264,52 @@ bool QgsVectorDataProvider::supportedType( const QgsField &field ) const
264264
.arg( mNativeTypes[i].mMaxLen )
265265
.arg( mNativeTypes[i].mMinPrec )
266266
.arg( mNativeTypes[i].mMaxPrec ), 2 );
267-
if ( field.type() == mNativeTypes[i].mType &&
268-
field.length() >= mNativeTypes[i].mMinLen && field.length() <= mNativeTypes[i].mMaxLen &&
269-
field.precision() >= mNativeTypes[i].mMinPrec && field.precision() <= mNativeTypes[i].mMaxPrec )
267+
268+
if ( field.type() != mNativeTypes[i].mType )
269+
continue;
270+
271+
if ( field.length() == -1 )
272+
{
273+
// source length unlimited
274+
if ( mNativeTypes[i].mMinLen > -1 || mNativeTypes[i].mMaxLen > -1 )
275+
{
276+
// destination limited
277+
continue;
278+
}
279+
}
280+
else
281+
{
282+
// source length limited
283+
if ( mNativeTypes[i].mMinLen > -1 && mNativeTypes[i].mMaxLen > -1 &&
284+
( field.length() < mNativeTypes[i].mMinLen || field.length() < mNativeTypes[i].mMaxLen ) )
285+
{
286+
// source length exceeds destination limits
287+
continue;
288+
}
289+
}
290+
291+
if ( field.precision() == -1 )
292+
{
293+
// source precision unlimited / n/a
294+
if ( mNativeTypes[i].mMinPrec > -1 || mNativeTypes[i].mMaxPrec > -1 )
295+
{
296+
// destination limited
297+
continue;
298+
}
299+
}
300+
else
270301
{
271-
QgsDebugMsg( "native type matches" );
272-
return true;
302+
// source precision unlimited / n/a
303+
if ( mNativeTypes[i].mMinPrec > -1 && mNativeTypes[i].mMaxPrec > -1 &&
304+
( field.precision() < mNativeTypes[i].mMinPrec || field.precision() < mNativeTypes[i].mMaxPrec ) )
305+
{
306+
// source precision exceeds destination limits
307+
continue;
308+
}
273309
}
310+
311+
QgsDebugMsg( "native type matches" );
312+
return true;
274313
}
275314

276315
QgsDebugMsg( "no sufficient native type found" );

0 commit comments

Comments
 (0)
Please sign in to comment.