@@ -245,7 +245,7 @@ QStringList QgsDelimitedTextProvider::readCsvtFieldTypes( QString filename, QStr
245
245
// not allowed in OGR CSVT files. Also doesn't care if int and string fields have
246
246
247
247
strTypeList = strTypeList.toLower ();
248
- QRegExp reTypeList ( " ^(?:\\ s*(\\\" ?)(?:integer|real|string|date|datetime|time)(?:\\ (\\ d+(?:\\ .\\ d+)?\\ ))?\\ 1\\ s*(?:,|$))+" );
248
+ QRegExp reTypeList ( " ^(?:\\ s*(\\\" ?)(?:integer|real|long|longlong| string|date|datetime|time)(?:\\ (\\ d+(?:\\ .\\ d+)?\\ ))?\\ 1\\ s*(?:,|$))+" );
249
249
if ( ! reTypeList.exactMatch ( strTypeList ) )
250
250
{
251
251
// Looks like this was supposed to be a CSVT file, so report bad formatted string
@@ -407,6 +407,7 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes )
407
407
408
408
QList<bool > isEmpty;
409
409
QList<bool > couldBeInt;
410
+ QList<bool > couldBeLongLong;
410
411
QList<bool > couldBeDouble;
411
412
412
413
while ( true )
@@ -561,27 +562,28 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes )
561
562
{
562
563
563
564
QString &value = parts[i];
564
- if ( value.isEmpty () )
565
- continue ;
566
-
567
- // try to convert attribute values to integer and double
568
-
569
- while ( couldBeInt.size () <= i )
570
- {
565
+ if ( value.isEmpty () ) {
571
566
isEmpty.append ( true );
572
567
couldBeInt.append ( false );
568
+ couldBeLongLong.append ( false );
573
569
couldBeDouble.append ( false );
570
+ continue ;
574
571
}
575
- if ( isEmpty[i] )
576
- {
577
- isEmpty[i] = false ;
578
- couldBeInt[i] = true ;
579
- couldBeDouble[i] = true ;
580
- }
572
+ // try to convert attribute values to integer, long and double
573
+ isEmpty. append ( false );
574
+ // try all possible formats
575
+ couldBeInt. append ( true ) ;
576
+ couldBeLongLong. append ( true ) ;
577
+ couldBeDouble. append ( true );
581
578
if ( couldBeInt[i] )
582
579
{
583
580
value.toInt ( &couldBeInt[i] );
584
581
}
582
+
583
+ if ( couldBeLongLong[i] )
584
+ {
585
+ value.toLongLong ( &couldBeLongLong[i] );
586
+ }
585
587
if ( couldBeDouble[i] )
586
588
{
587
589
if ( ! mDecimalPoint .isEmpty () )
@@ -620,6 +622,11 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes )
620
622
fieldType = QVariant::Int;
621
623
typeName = " integer" ;
622
624
}
625
+ else if ( csvtTypes[i] == " long" || csvtTypes[i]== " longlong" )
626
+ {
627
+ fieldType = QVariant::LongLong; // QVariant doesn't support long
628
+ typeName = " longlong" ;
629
+ }
623
630
else if ( csvtTypes[i] == " real" )
624
631
{
625
632
fieldType = QVariant::Double;
@@ -633,6 +640,11 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes )
633
640
fieldType = QVariant::Int;
634
641
typeName = " integer" ;
635
642
}
643
+ else if ( couldBeLongLong[i] )
644
+ {
645
+ fieldType = QVariant::LongLong;
646
+ typeName = " longlong" ;
647
+ }
636
648
else if ( couldBeDouble[i] )
637
649
{
638
650
fieldType = QVariant::Double;
@@ -997,12 +1009,14 @@ bool QgsDelimitedTextProvider::setSubsetString( QString subset, bool updateFeatu
997
1009
998
1010
if ( valid )
999
1011
{
1000
-
1001
- if ( mSubsetExpression ) delete mSubsetExpression ;
1012
+ QgsExpression * tmpSubsetExpression = mSubsetExpression ;
1013
+ // using a tmp pointer to avoid the pointer being dereferenced by
1014
+ // a friend class after it has been freed but before it has been
1015
+ // reassigned
1002
1016
QString previousSubset = mSubsetString ;
1003
1017
mSubsetString = subset;
1004
1018
mSubsetExpression = expression;
1005
-
1019
+ if ( tmpSubsetExpression ) delete tmpSubsetExpression;
1006
1020
// Update the feature count and extents if requested
1007
1021
1008
1022
// Usage of updateFeatureCount is a bit painful, basically expect that it
0 commit comments