Package: qgis / 2.4.0-1

0001-Fix-10744-crashes-with-CSV-files-with-parallel-rende.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
From e937b628f4a4dcd0be2cf021a64d868daf430c2e Mon Sep 17 00:00:00 2001
From: Martin Dobias <wonder.sk@gmail.com>
Date: Wed, 16 Jul 2014 19:44:23 +0200
Subject: Fix #10744 (crashes with CSV files with parallel rendering)
Origin: https://github.com/qgis/QGIS/commit/e937b628f4a4dcd0be2cf021a64d868daf430c2e
Bug: http://hub.qgis.org/issues/10744

I can't replicate the crash, but the static QRegExp instances will not work
with multiple threads.

--- a/src/providers/delimitedtext/qgsdelimitedtextfile.cpp
+++ b/src/providers/delimitedtext/qgsdelimitedtextfile.cpp
@@ -28,10 +28,6 @@
 #include <QRegExp>
 #include <QUrl>
 
-static QString DefaultFieldName( "field_%1" );
-static QRegExp InvalidFieldRegexp( "^\\d*(\\.\\d*)?$" );
-// field_ is optional in following regexp to simplify QgsDelimitedTextFile::fieldNumber()
-static QRegExp DefaultFieldRegexp( "^(?:field_)?(\\d+)$", Qt::CaseInsensitive );
 
 QgsDelimitedTextFile::QgsDelimitedTextFile( QString url ) :
     mFileName( QString() ),
@@ -52,7 +48,11 @@ QgsDelimitedTextFile::QgsDelimitedTextFi
     mRecordNumber( -1 ),
     mHoldCurrentRecord( false ),
     mMaxRecordNumber( -1 ),
-    mMaxFieldCount( 0 )
+    mMaxFieldCount( 0 ),
+    mDefaultFieldName( "field_%1" ),
+    mInvalidFieldRegexp( "^\\d*(\\.\\d*)?$" ),
+    // field_ is optional in following regexp to simplify QgsDelimitedTextFile::fieldNumber()
+    mDefaultFieldRegexp( "^(?:field_)?(\\d+)$", Qt::CaseInsensitive )
 {
   // The default type is CSV
   setTypeCSV();
@@ -428,15 +428,15 @@ void QgsDelimitedTextFile::setFieldNames
     if ( name.length() > mMaxNameLength ) name = name.mid( 0, mMaxNameLength );
 
     // If the name is invalid then reset it to default name
-    if ( InvalidFieldRegexp.exactMatch( name ) )
+    if ( mInvalidFieldRegexp.exactMatch( name ) )
     {
-      name = DefaultFieldName.arg( fieldNo );
+      name = mDefaultFieldName.arg( fieldNo );
     }
     // If the name looks like a default field name (field_##), then it is
     // valid if the number matches its column number..
-    else if ( DefaultFieldRegexp.indexIn( name ) == 0 )
+    else if ( mDefaultFieldRegexp.indexIn( name ) == 0 )
     {
-      int col = DefaultFieldRegexp.capturedTexts()[1].toInt();
+      int col = mDefaultFieldRegexp.capturedTexts()[1].toInt();
       nameOk = col == fieldNo;
     }
     // Otherwise it is valid if isn't the name of an existing field...
@@ -477,7 +477,7 @@ QStringList &QgsDelimitedTextFile::field
   {
     for ( int i = mFieldNames.size() + 1; i <= mMaxFieldCount; i++ )
     {
-      mFieldNames.append( DefaultFieldName.arg( i ) );
+      mFieldNames.append( mDefaultFieldName.arg( i ) );
     }
   }
   return mFieldNames;
@@ -490,9 +490,9 @@ int QgsDelimitedTextFile::fieldIndex( QS
   if ( mUseHeader && ! mFile ) reset();
   // Try to determine the field based on a default field name, includes
   // Field_### and simple integer fields.
-  if ( DefaultFieldRegexp.indexIn( name ) == 0 )
+  if ( mDefaultFieldRegexp.indexIn( name ) == 0 )
   {
-    return DefaultFieldRegexp.capturedTexts()[1].toInt() - 1;
+    return mDefaultFieldRegexp.capturedTexts()[1].toInt() - 1;
   }
   for ( int i = 0; i < mFieldNames.size(); i++ )
   {
--- a/src/providers/delimitedtext/qgsdelimitedtextfile.h
+++ b/src/providers/delimitedtext/qgsdelimitedtextfile.h
@@ -379,6 +379,10 @@ class QgsDelimitedTextFile : public QObj
     // Maximum number of record (ie maximum record number visited)
     long mMaxRecordNumber;
     int mMaxFieldCount;
+
+    QString mDefaultFieldName;
+    QRegExp mInvalidFieldRegexp;
+    QRegExp mDefaultFieldRegexp;
 };
 
 #endif