Skip to content

Commit b982fdc

Browse files
committedMay 23, 2012
Merge branch 'master' of github.com:qgis/Quantum-GIS
2 parents 4d3cf1a + c367a35 commit b982fdc

21 files changed

+776
-400
lines changed
 

‎doc/index.dox

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/*! \mainpage Quantum GIS
66

77
\section index_intro Introduction
8-
\htmlonly<img src="http://download.qgis.org/qgis-icon-60x60.png" alt="QGIS"
8+
\htmlonly<img src="http://hub.qgis.org/projects/quantum-gis/repository/revisions/master/entry/images/icons/qgis-icon-60x60.png" alt="QGIS"
99
align="left"><a href="http://qgis.org">Quantum GIS</a>\endhtmlonly\latexonly
1010
Quantum GIS \endlatexonly (QGIS) is a user friendly Open Source Geographic
1111
Information System (GIS) that runs on Linux, Unix, Mac OSX, and Windows. QGIS

‎python/plugins/db_manager/db_manager.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def registerAction(self, action, menuName, callback=None):
223223
# get the placeholder's position to insert before it
224224
pos = 0
225225
for pos in range(len(menuActions)):
226-
if menuActions[pos].isSeparator() and menuActions[pos].text() == "placeholder":
226+
if menuActions[pos].isSeparator() and menuActions[pos].objectName().endsWith("_placeholder"):
227227
menuActions[pos].setVisible(True)
228228
break
229229

@@ -301,7 +301,7 @@ def unregisterAction(self, action, menuName):
301301
# hide the placeholder if there're no other registered actions
302302
if len(self._registeredDbActions[menuName]) <= 0:
303303
for i in range(len(menuActions)):
304-
if menuActions[i].isSeparator() and menuActions[i].text() == "placeholder":
304+
if menuActions[i].isSeparator() and menuActions[i].objectName().endsWith("_placeholder"):
305305
menuActions[i].setVisible(False)
306306
break
307307

@@ -369,18 +369,18 @@ def setupUi(self):
369369
# create menus' actions
370370

371371
# menu DATABASE
372-
sep = self.menuDb.addAction("placeholder"); sep.setSeparator(True); sep.setVisible(False)
372+
sep = self.menuDb.addSeparator(); sep.setObjectName("DB_Manager_DbMenu_placeholder"); sep.setVisible(False)
373373
self.actionRefresh = self.menuDb.addAction( QIcon(":/db_manager/actions/refresh"), "&Refresh", self.refreshActionSlot, QKeySequence("F5") )
374374
self.actionSqlWindow = self.menuDb.addAction( QIcon(":/db_manager/actions/sql_window"), "&SQL window", self.runSqlWindow, QKeySequence("F2") )
375375
self.menuDb.addSeparator()
376376
self.actionClose = self.menuDb.addAction( QIcon(), "&Exit", self.close, QKeySequence("CTRL+Q") )
377377

378378
# menu SCHEMA
379-
sep = self.menuSchema.addAction("placeholder"); sep.setSeparator(True); sep.setVisible(False)
379+
sep = self.menuSchema.addSeparator(); sep.setObjectName("DB_Manager_SchemaMenu_placeholder"); sep.setVisible(False)
380380
actionMenuSchema.setVisible(False)
381381

382382
# menu TABLE
383-
sep = self.menuTable.addAction("placeholder"); sep.setSeparator(True); sep.setVisible(False)
383+
sep = self.menuTable.addSeparator(); sep.setObjectName("DB_Manager_TableMenu_placeholder"); sep.setVisible(False)
384384
actionMenuTable.setVisible(False)
385385
self.actionShowSystemTables = self.menuTable.addAction("Show system tables/views", self.showSystemTables)
386386
self.actionShowSystemTables.setCheckable(True)

‎python/plugins/db_manager/db_plugins/connector.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ def hasTableColumnEditingSupport(self):
6060
return False
6161

6262

63-
def execution_error_types():
63+
def execution_error_types(self):
6464
raise Exception("DBConnector.execution_error_types() is an abstract method")
6565

66-
def connection_error_types():
66+
def connection_error_types(self):
6767
raise Exception("DBConnector.connection_error_types() is an abstract method")
6868

69-
def error_types():
69+
def error_types(self):
7070
return self.connection_error_types() + self.execution_error_types()
7171

7272
def _execute(self, cursor, sql):

‎python/plugins/db_manager/table_viewer.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,12 @@ def setDirty(self, val=True):
6767

6868
def _clear(self):
6969
if self.item is not None:
70-
self.disconnect(self.item, SIGNAL('aboutToChange'), self.setDirty)
70+
try:
71+
self.disconnect(self.item, SIGNAL('aboutToChange'), self.setDirty)
72+
except:
73+
# do not raise any error if self.item was deleted
74+
pass
75+
7176
self.item = None
7277
self.dirty = False
7378

@@ -83,11 +88,13 @@ def _loadTableData(self, table):
8388
self.setModel( table.tableDataModel(self) )
8489

8590
except DbError, e:
86-
QApplication.restoreOverrideCursor()
8791
DlgDbError.showError(e, self)
92+
return
8893

8994
else:
9095
self.update()
96+
97+
finally:
9198
QApplication.restoreOverrideCursor()
9299

93100

‎python/plugins/fTools/tools/doGeoprocessing.py

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -944,7 +944,7 @@ def intersect( self ):
944944
if geom.intersects( tmpGeom ):
945945
atMapB = inFeatB.attributeMap()
946946
int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
947-
if int_geom.wkbType() == 7:
947+
if int_geom.wkbType() == 0:
948948
int_com = geom.combine( tmpGeom )
949949
int_sym = geom.symDifference( tmpGeom )
950950
int_geom = QgsGeometry( int_com.difference( int_sym ) )
@@ -973,7 +973,7 @@ def intersect( self ):
973973
if geom.intersects( tmpGeom ):
974974
atMapB = inFeatB.attributeMap()
975975
int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
976-
if int_geom.wkbType() == 7:
976+
if int_geom.wkbType() == 0:
977977
int_com = geom.combine( tmpGeom )
978978
int_sym = geom.symDifference( tmpGeom )
979979
int_geom = QgsGeometry( int_com.difference( int_sym ) )
@@ -1010,7 +1010,7 @@ def intersect( self ):
10101010
if geom.intersects( tmpGeom ):
10111011
atMapB = inFeatB.attributeMap()
10121012
int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
1013-
if int_geom.wkbType() == 7:
1013+
if int_geom.wkbType() == 0:
10141014
int_com = geom.combine( tmpGeom )
10151015
int_sym = geom.symDifference( tmpGeom )
10161016
int_geom = QgsGeometry( int_com.difference( int_sym ) )
@@ -1039,7 +1039,7 @@ def intersect( self ):
10391039
if geom.intersects( tmpGeom ):
10401040
atMapB = inFeatB.attributeMap()
10411041
int_geom = QgsGeometry( geom.intersection( tmpGeom ) )
1042-
if int_geom.wkbType() == 7:
1042+
if int_geom.wkbType() == 0:
10431043
int_com = geom.combine( tmpGeom )
10441044
int_sym = geom.symDifference( tmpGeom )
10451045
int_geom = QgsGeometry( int_com.difference( int_sym ) )
@@ -1143,17 +1143,24 @@ def union( self ):
11431143
diff_geom = QgsGeometry(diff_geom)
11441144

11451145
if int_geom.wkbType() == 0:
1146-
# intersection produced different geomety types
1146+
# intersection produced different geometry types
11471147
temp_list = int_geom.asGeometryCollection()
11481148
for i in temp_list:
11491149
if i.type() == geom.type():
1150-
int_geom = QgsGeometry( i )
1151-
try:
1152-
outFeat.setGeometry( int_geom )
1153-
outFeat.setAttributeMap( ftools_utils.combineVectorAttributes( atMapA, atMapB ) )
1154-
writer.addFeature( outFeat )
1155-
except Exception, err:
1156-
FEATURE_EXCEPT = False
1150+
int_geom = QgsGeometry( i )
1151+
try:
1152+
outFeat.setGeometry( int_geom )
1153+
outFeat.setAttributeMap( ftools_utils.combineVectorAttributes( atMapA, atMapB ) )
1154+
writer.addFeature( outFeat )
1155+
except Exception, err:
1156+
FEATURE_EXCEPT = False
1157+
else:
1158+
try:
1159+
outFeat.setGeometry( int_geom )
1160+
outFeat.setAttributeMap( ftools_utils.combineVectorAttributes( atMapA, atMapB ) )
1161+
writer.addFeature( outFeat )
1162+
except Exception, err:
1163+
FEATURE_EXCEPT = False
11571164
else:
11581165
# this only happends if the bounding box
11591166
# intersects, but the geometry doesn't
@@ -1390,7 +1397,7 @@ def clip( self ):
13901397
try:
13911398
cur_geom = QgsGeometry( outFeat.geometry() )
13921399
new_geom = QgsGeometry( geom.intersection( cur_geom ) )
1393-
if new_geom.wkbType() == 7:
1400+
if new_geom.wkbType() == 0:
13941401
int_com = QgsGeometry( geom.combine( cur_geom ) )
13951402
int_sym = QgsGeometry( geom.symDifference( cur_geom ) )
13961403
new_geom = QgsGeometry( int_com.difference( int_sym ) )
@@ -1434,7 +1441,7 @@ def clip( self ):
14341441
try:
14351442
cur_geom = QgsGeometry( outFeat.geometry() )
14361443
new_geom = QgsGeometry( geom.intersection( cur_geom ) )
1437-
if new_geom.wkbType() == 7:
1444+
if new_geom.wkbType() == 0:
14381445
int_com = QgsGeometry( geom.combine( cur_geom ) )
14391446
int_sym = QgsGeometry( geom.symDifference( cur_geom ) )
14401447
new_geom = QgsGeometry( int_com.difference( int_sym ) )
@@ -1485,7 +1492,7 @@ def clip( self ):
14851492
try:
14861493
cur_geom = QgsGeometry( outFeat.geometry() )
14871494
new_geom = QgsGeometry( geom.intersection( cur_geom ) )
1488-
if new_geom.wkbType() == 7:
1495+
if new_geom.wkbType() == 0:
14891496
int_com = QgsGeometry( geom.combine( cur_geom ) )
14901497
int_sym = QgsGeometry( geom.symDifference( cur_geom ) )
14911498
new_geom = QgsGeometry( int_com.difference( int_sym ) )
@@ -1530,7 +1537,7 @@ def clip( self ):
15301537
try:
15311538
cur_geom = QgsGeometry( outFeat.geometry() )
15321539
new_geom = QgsGeometry( geom.intersection( cur_geom ) )
1533-
if new_geom.wkbType() == 7:
1540+
if new_geom.wkbType() == 0:
15341541
int_com = QgsGeometry( geom.combine( cur_geom ) )
15351542
int_sym = QgsGeometry( geom.symDifference( cur_geom ) )
15361543
new_geom = QgsGeometry( int_com.difference( int_sym ) )

‎python/plugins/fTools/tools/doRandPoints.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ def __init__(self, iface):
5050

5151
def populateLayers( self ):
5252
layers = ftools_utils.getLayerNames([QGis.Polygon, "Raster"])
53-
QObject.disconnect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
53+
self.inShape.blockSignals(True)
5454
self.inShape.clear()
55+
self.inShape.blockSignals(False)
5556
self.inShape.addItems(layers)
56-
QObject.connect(self.inShape, SIGNAL("currentIndexChanged(QString)"), self.update)
5757

58-
# If input layer is changed, update field list
58+
# If input layer is changed, update field list
5959
def update(self, inputLayer):
6060
self.cmbField.clear()
6161
changedLayer = ftools_utils.getMapLayerByName(unicode(inputLayer))
@@ -67,6 +67,7 @@ def update(self, inputLayer):
6767
changedLayer = ftools_utils.getVectorLayerByName(inputLayer)
6868
changedFields = ftools_utils.getFieldList(changedLayer)
6969
for i in changedFields:
70+
if changedFields[i].typeName() == "Integer":
7071
self.cmbField.addItem(unicode(changedFields[i].name()))
7172
else:
7273
self.rdoUnstratified.setChecked(True)
@@ -78,7 +79,7 @@ def update(self, inputLayer):
7879
self.cmbField.setEnabled(False)
7980
self.label_4.setEnabled(False)
8081

81-
# when 'OK' button is pressed, gather required inputs, and initiate random points generation
82+
# when 'OK' button is pressed, gather required inputs, and initiate random points generation
8283
def accept(self):
8384
self.buttonOk.setEnabled( False )
8485
if self.inShape.currentText() == "":
@@ -99,7 +100,7 @@ def accept(self):
99100
self.progressBar.setValue(5)
100101
mLayer = ftools_utils.getMapLayerByName(unicode(inName))
101102
if mLayer.type() == mLayer.VectorLayer:
102-
inLayer = QgsVectorLayer(unicode(mLayer.source()), unicode(mLayer.name()), unicode(mLayer.dataProvider().name()))
103+
inLayer = ftools_utils.getVectorLayerByName(unicode(inName))
103104
if self.rdoUnstratified.isChecked():
104105
design = self.tr("unstratified")
105106
value = self.spnUnstratified.value()
@@ -113,7 +114,7 @@ def accept(self):
113114
design = self.tr("field")
114115
value = unicode(self.cmbField.currentText())
115116
elif mLayer.type() == mLayer.RasterLayer:
116-
inLayer = QgsRasterLayer(unicode(mLayer.source()), unicode(mLayer.name()))
117+
inLayer = ftools_utils.getRasterLayerByName(unicode(inName))
117118
design = self.tr("unstratified")
118119
value = self.spnUnstratified.value()
119120
else:

‎python/plugins/fTools/tools/doVectorGrid.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def accept(self):
153153
self.buttonOk.setEnabled( True )
154154

155155
def compute( self, bound, xOffset, yOffset, polygon ):
156-
crs = self.iface.mapCanvas().mapRenderer().destinationSrs()
156+
crs = ftools_utils.getMapLayerByName(unicode(self.inShape.currentText())).crs()
157157
if not crs.isValid(): crs = None
158158
if polygon:
159159
fields = {0:QgsField("ID", QVariant.Int), 1:QgsField("XMIN", QVariant.Double), 2:QgsField("XMAX", QVariant.Double),
@@ -163,15 +163,13 @@ def compute( self, bound, xOffset, yOffset, polygon ):
163163
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
164164
return
165165
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fields, QGis.WKBPolygon, crs)
166-
#writer = QgsVectorFileWriter(outPath, "CP1250", fields, QGis.WKBPolygon, None)
167166
else:
168167
fields = {0:QgsField("ID", QVariant.Int), 1:QgsField("COORD", QVariant.Double)}
169168
check = QFile(self.shapefileName)
170169
if check.exists():
171170
if not QgsVectorFileWriter.deleteShapeFile(self.shapefileName):
172171
return
173172
writer = QgsVectorFileWriter(self.shapefileName, self.encoding, fields, QGis.WKBLineString, crs)
174-
#writer = QgsVectorFileWriter(unicode(outPath), "CP1250", fields, QGis.WKBLineString, None)
175173
outFeat = QgsFeature()
176174
outGeom = QgsGeometry()
177175
idVar = 0
@@ -279,16 +277,16 @@ def getClosestPixel(self, startVal, targetVal, step, isMin ):
279277
while foundVal is None:
280278
if tmpVal <= targetVal:
281279
if backOneStep:
282-
tmpVal -= step
280+
tmpVal -= step
283281
foundVal = tmpVal
284282
tmpVal += step
285283
else:
286284
backOneStep = isMin
287285
while foundVal is None:
288286
if tmpVal >= targetVal:
289287
if backOneStep:
290-
tmpVal -= step
288+
tmpVal -= step
291289
foundVal = tmpVal
292290
tmpVal += step
293-
return foundVal
291+
return foundVal
294292

‎python/plugins/fTools/tools/ftools_utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,16 @@ def getVectorLayerByName( myName ):
206206
else:
207207
return None
208208

209+
# Return QgsRasterLayer from a layer name ( as string )
210+
def getRasterLayerByName( myName ):
211+
layermap = QgsMapLayerRegistry.instance().mapLayers()
212+
for name, layer in layermap.iteritems():
213+
if layer.type() == QgsMapLayer.RasterLayer and layer.name() == myName:
214+
if layer.isValid():
215+
return layer
216+
else:
217+
return None
218+
209219
# Return QgsMapLayer from a layer name ( as string )
210220
def getMapLayerByName( myName ):
211221
layermap = QgsMapLayerRegistry.instance().mapLayers()

‎resources/customization.xml

Lines changed: 634 additions & 327 deletions
Large diffs are not rendered by default.

‎src/app/qgscustomprojectiondialog.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ long QgsCustomProjectionDialog::getRecordCount()
163163
int myResult;
164164
long myRecordCount = 0;
165165
//check the db is available
166-
myResult = sqlite3_open( QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase );
166+
myResult = sqlite3_open_v2( QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
167167
if ( myResult != SQLITE_OK )
168168
{
169169
QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );
@@ -198,7 +198,7 @@ QString QgsCustomProjectionDialog::getProjectionFamilyName( QString theProjectio
198198
int myResult;
199199
QString myName;
200200
//check the db is available
201-
myResult = sqlite3_open( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase );
201+
myResult = sqlite3_open_v2( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
202202
if ( myResult != SQLITE_OK )
203203
{
204204
QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );
@@ -229,7 +229,7 @@ QString QgsCustomProjectionDialog::getEllipsoidName( QString theEllipsoidAcronym
229229
int myResult;
230230
QString myName;
231231
//check the db is available
232-
myResult = sqlite3_open( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase );
232+
myResult = sqlite3_open_v2( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
233233
if ( myResult != SQLITE_OK )
234234
{
235235
QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );
@@ -260,7 +260,7 @@ QString QgsCustomProjectionDialog::getProjectionFamilyAcronym( QString theProjec
260260
int myResult;
261261
QString myName;
262262
//check the db is available
263-
myResult = sqlite3_open( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase );
263+
myResult = sqlite3_open_v2( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
264264
if ( myResult != SQLITE_OK )
265265
{
266266
QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );
@@ -291,7 +291,7 @@ QString QgsCustomProjectionDialog::getEllipsoidAcronym( QString theEllipsoidName
291291
int myResult;
292292
QString myName;
293293
//check the db is available
294-
myResult = sqlite3_open( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase );
294+
myResult = sqlite3_open_v2( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
295295
if ( myResult != SQLITE_OK )
296296
{
297297
QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );
@@ -323,7 +323,7 @@ void QgsCustomProjectionDialog::on_pbnFirst_clicked()
323323
sqlite3_stmt *myPreparedStatement;
324324
int myResult;
325325
//check the db is available
326-
myResult = sqlite3_open( QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase );
326+
myResult = sqlite3_open_v2( QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
327327
if ( myResult != SQLITE_OK )
328328
{
329329
QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );
@@ -395,7 +395,7 @@ void QgsCustomProjectionDialog::on_pbnPrevious_clicked()
395395
sqlite3_stmt *myPreparedStatement;
396396
int myResult;
397397
//check the db is available
398-
myResult = sqlite3_open( QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase );
398+
myResult = sqlite3_open_v2( QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
399399
if ( myResult != SQLITE_OK )
400400
{
401401
QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );
@@ -468,7 +468,7 @@ void QgsCustomProjectionDialog::on_pbnNext_clicked()
468468
sqlite3_stmt *myPreparedStatement;
469469
int myResult;
470470
//check the db is available
471-
myResult = sqlite3_open( QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase );
471+
myResult = sqlite3_open_v2( QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
472472
if ( myResult != SQLITE_OK )
473473
{
474474
QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );
@@ -537,7 +537,7 @@ void QgsCustomProjectionDialog::on_pbnLast_clicked()
537537
sqlite3_stmt *myPreparedStatement;
538538
int myResult;
539539
//check the db is available
540-
myResult = sqlite3_open( QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase );
540+
myResult = sqlite3_open_v2( QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
541541
if ( myResult != SQLITE_OK )
542542
{
543543
QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );

‎src/app/qgsoptions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ void QgsOptions::getEllipsoidList()
982982

983983
cmbEllipsoid->addItem( ELLIPS_FLAT_DESC );
984984
//check the db is available
985-
myResult = sqlite3_open( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase );
985+
myResult = sqlite3_open_v2( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
986986
if ( myResult )
987987
{
988988
QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );
@@ -1015,7 +1015,7 @@ QString QgsOptions::getEllipsoidAcronym( QString theEllipsoidName )
10151015
int myResult;
10161016
QString myName( ELLIPS_FLAT );
10171017
//check the db is available
1018-
myResult = sqlite3_open( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase );
1018+
myResult = sqlite3_open_v2( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
10191019
if ( myResult )
10201020
{
10211021
QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );
@@ -1047,7 +1047,7 @@ QString QgsOptions::getEllipsoidName( QString theEllipsoidAcronym )
10471047
int myResult;
10481048
QString myName( ELLIPS_FLAT_DESC );
10491049
//check the db is available
1050-
myResult = sqlite3_open( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase );
1050+
myResult = sqlite3_open_v2( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
10511051
if ( myResult )
10521052
{
10531053
QgsDebugMsg( QString( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );

‎src/core/qgsdataitem.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -775,10 +775,12 @@ QgsZipItem::~QgsZipItem()
775775

776776
// internal function to scan a vsidir (zip or tar file) recursively
777777
// GDAL trunk has this since r24423 (05/16/12) - VSIReadDirRecursive()
778-
// use a copy of the function internally for now
778+
// use a copy of the function internally for now,
779+
// but use char ** and CSLAddString, because CPLStringList was added in gdal-1.9
779780
char **VSIReadDirRecursive1( const char *pszPath )
780781
{
781-
CPLStringList oFiles = NULL;
782+
// CPLStringList oFiles = NULL;
783+
char **papszOFiles = NULL;
782784
char **papszFiles1 = NULL;
783785
char **papszFiles2 = NULL;
784786
VSIStatBufL psStatBuf;
@@ -805,7 +807,8 @@ char **VSIReadDirRecursive1( const char *pszPath )
805807
if ( VSIStatL( osTemp1.c_str(), &psStatBuf ) == 0 &&
806808
VSI_ISREG( psStatBuf.st_mode ) )
807809
{
808-
oFiles.AddString( papszFiles1[i] );
810+
// oFiles.AddString( papszFiles1[i] );
811+
papszOFiles = CSLAddString( papszOFiles, papszFiles1[i] );
809812
}
810813
else if ( VSIStatL( osTemp1.c_str(), &psStatBuf ) == 0 &&
811814
VSI_ISDIR( psStatBuf.st_mode ) )
@@ -814,7 +817,8 @@ char **VSIReadDirRecursive1( const char *pszPath )
814817
osTemp2.clear();
815818
osTemp2.append( papszFiles1[i] );
816819
osTemp2.append( "/" );
817-
oFiles.AddString( osTemp2.c_str() );
820+
// oFiles.AddString( osTemp2.c_str() );
821+
papszOFiles = CSLAddString( papszOFiles, osTemp2.c_str() );
818822

819823
// recursively add files inside directory
820824
papszFiles2 = VSIReadDirRecursive1( osTemp1.c_str() );
@@ -827,15 +831,17 @@ char **VSIReadDirRecursive1( const char *pszPath )
827831
osTemp2.append( papszFiles1[i] );
828832
osTemp2.append( "/" );
829833
osTemp2.append( papszFiles2[j] );
830-
oFiles.AddString( osTemp2.c_str() );
834+
// oFiles.AddString( osTemp2.c_str() );
835+
papszOFiles = CSLAddString( papszOFiles, osTemp2.c_str() );
831836
}
832837
CSLDestroy( papszFiles2 );
833838
}
834839
}
835840
}
836841
CSLDestroy( papszFiles1 );
837842

838-
return oFiles.StealList();
843+
// return oFiles.StealList();
844+
return papszOFiles;
839845
}
840846

841847
QVector<QgsDataItem*> QgsZipItem::createChildren( )

‎src/core/qgsdistancearea.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ bool QgsDistanceArea::setEllipsoid( const QString& ellipsoid )
9999
}
100100

101101
//check the db is available
102-
myResult = sqlite3_open( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase );
102+
myResult = sqlite3_open_v2( QgsApplication::srsDbFilePath().toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
103103
if ( myResult )
104104
{
105105
QgsMessageLog::logMessage( QObject::tr( "Can't open database: %1" ).arg( sqlite3_errmsg( myDatabase ) ) );

‎src/core/qgsmaplayer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ bool QgsMapLayer::loadNamedStyleFromDb( const QString db, const QString theURI,
614614
if ( !QFile( db ).exists() )
615615
return false;
616616

617-
myResult = sqlite3_open( db.toUtf8().data(), &myDatabase );
617+
myResult = sqlite3_open_v2( db.toUtf8().data(), &myDatabase, SQLITE_OPEN_READONLY, NULL );
618618
if ( myResult != SQLITE_OK )
619619
{
620620
return false;

‎src/core/qgsvectorlayer.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2403,7 +2403,23 @@ int QgsVectorLayer::splitFeatures( const QList<QgsPoint>& splitLine, bool topolo
24032403
newGeometry = newGeometries.at( i );
24042404
QgsFeature newFeature;
24052405
newFeature.setGeometry( newGeometry );
2406-
newFeature.setAttributeMap( select_it->attributeMap() );
2406+
2407+
//use default value where possible (primary key issue), otherwise the value from the original (splitted) feature
2408+
QgsAttributeMap newAttributes = select_it->attributeMap();
2409+
QVariant defaultValue;
2410+
for ( int j = 0; j < newAttributes.size(); ++j )
2411+
{
2412+
if ( mDataProvider )
2413+
{
2414+
defaultValue = mDataProvider->defaultValue( j );
2415+
if ( !defaultValue.isNull() )
2416+
{
2417+
newAttributes.insert( j, defaultValue );
2418+
}
2419+
}
2420+
}
2421+
2422+
newFeature.setAttributeMap( newAttributes );
24072423
newFeatures.append( newFeature );
24082424
}
24092425

‎src/gui/qgsprojectionselector.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ QString QgsProjectionSelector::selectedProj4String()
332332
QgsDebugMsg( "db = " + databaseFileName );
333333

334334
sqlite3 *database;
335-
int rc = sqlite3_open( databaseFileName.toUtf8().data(), &database );
335+
int rc = sqlite3_open_v2( databaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, NULL );
336336
if ( rc )
337337
{
338338
showDBMissingWarning( databaseFileName );
@@ -401,7 +401,7 @@ QString QgsProjectionSelector::getSelectedExpression( QString expression )
401401
// assuming that it will never be used anywhere else. Given the low overhead,
402402
// opening it each time seems to be a reasonable approach at this time.
403403
sqlite3 *database;
404-
int rc = sqlite3_open( databaseFileName.toUtf8().data(), &database );
404+
int rc = sqlite3_open_v2( databaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, NULL );
405405
if ( rc )
406406
{
407407
showDBMissingWarning( databaseFileName );
@@ -520,7 +520,7 @@ void QgsProjectionSelector::loadUserCrsList( QSet<QString> *crsFilter )
520520
const char *tail;
521521
sqlite3_stmt *stmt;
522522
//check the db is available
523-
int result = sqlite3_open( databaseFileName.toUtf8().constData(), &database );
523+
int result = sqlite3_open_v2( databaseFileName.toUtf8().constData(), &database, SQLITE_OPEN_READONLY, NULL );
524524
if ( result )
525525
{
526526
// XXX This will likely never happen since on open, sqlite creates the
@@ -599,7 +599,7 @@ void QgsProjectionSelector::loadCrsList( QSet<QString> *crsFilter )
599599

600600
// open the database containing the spatial reference data
601601
sqlite3 *database;
602-
int rc = sqlite3_open( mSrsDatabaseFileName.toUtf8().data(), &database );
602+
int rc = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, NULL );
603603
if ( rc )
604604
{
605605
// XXX This will likely never happen since on open, sqlite creates the
@@ -873,7 +873,7 @@ long QgsProjectionSelector::getLargestCRSIDMatch( QString theSql )
873873
QString databaseFileName = QgsApplication::qgisUserDbFilePath();
874874
if ( QFileInfo( databaseFileName ).exists() ) //only bother trying to open if the file exists
875875
{
876-
result = sqlite3_open( databaseFileName.toUtf8().data(), &database );
876+
result = sqlite3_open_v2( databaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, NULL );
877877
if ( result )
878878
{
879879
// XXX This will likely never happen since on open, sqlite creates the
@@ -899,7 +899,7 @@ long QgsProjectionSelector::getLargestCRSIDMatch( QString theSql )
899899
else
900900
{
901901
//only bother looking in srs.db if it wasnt found above
902-
result = sqlite3_open( mSrsDatabaseFileName.toUtf8().data(), &database );
902+
result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, NULL );
903903
if ( result )
904904
{
905905
QgsDebugMsg( QString( "Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );
@@ -929,7 +929,7 @@ QStringList QgsProjectionSelector::authorities()
929929
const char *tail;
930930
sqlite3_stmt *stmt;
931931

932-
int result = sqlite3_open( mSrsDatabaseFileName.toUtf8().data(), &database );
932+
int result = sqlite3_open_v2( mSrsDatabaseFileName.toUtf8().data(), &database, SQLITE_OPEN_READONLY, NULL );
933933
if ( result )
934934
{
935935
QgsDebugMsg( QString( "Can't open * user * database: %1" ).arg( sqlite3_errmsg( database ) ) );

‎src/gui/symbology-ng/qgssymbollevelsv2dialog.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,18 @@ QgsSymbolLevelsV2Dialog::QgsSymbolLevelsV2Dialog( QgsLegendSymbolList list, bool
7373

7474
connect( chkEnable, SIGNAL( clicked() ), this, SLOT( updateUi() ) );
7575

76+
if ( mList.count() > 0 && !mList[0].second )
77+
{
78+
// remove symbolless entry (probably classifier of categorized renderer)
79+
mList.removeFirst();
80+
}
81+
7682
int maxLayers = 0;
77-
tableLevels->setRowCount( list.count() );
78-
for ( int i = 0; i < list.count(); i++ )
83+
tableLevels->setRowCount( mList.count() );
84+
for ( int i = 0; i < mList.count(); i++ )
7985
{
80-
QgsSymbolV2* sym = list[i].second;
81-
QString label = list[i].first;
86+
QgsSymbolV2* sym = mList[i].second;
87+
QString label = mList[i].first;
8288

8389
// set icons for the rows
8490
QIcon icon = QgsSymbolLayerV2Utils::symbolPreviewIcon( sym, QSize( 16, 16 ) );

‎src/helpviewer/qgshelpviewer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ int QgsHelpViewer::connectDb( const QString &helpDbPath )
219219
if ( QFileInfo( helpDbPath ).exists() )
220220
{
221221
int rc;
222-
rc = sqlite3_open( helpDbPath.toUtf8().data(), &db );
222+
rc = sqlite3_open_v2( helpDbPath.toUtf8().data(), &db, SQLITE_OPEN_READONLY, NULL );
223223
result = rc;
224224
}
225225
else

‎src/providers/mssql/qgsmssqlprovider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1315,7 +1315,7 @@ QString QgsMssqlProvider::name() const
13151315
return TEXT_PROVIDER_KEY;
13161316
} // ::name()
13171317

1318-
bool QgsMssqlProvider::setSubsetString( QString theSQL, bool updateFeatureCount )
1318+
bool QgsMssqlProvider::setSubsetString( QString theSQL, bool )
13191319
{
13201320
Q_UNUSED(updateFeatureCount);
13211321
QString prevWhere = mSqlWhereClause;

‎tests/src/core/testziplayer.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ class TestZipLayer: public QObject
7777
void testGZipItemVectorTransparency();
7878
void testZipItemRasterTransparency();
7979
void testGZipItemRasterTransparency();
80+
//make sure items inside subfolders can be read
81+
void testZipItemSubfolder();
8082
};
8183

8284

@@ -215,6 +217,12 @@ void TestZipLayer::initTestCase()
215217
{
216218
QgsApplication::init();
217219
QgsApplication::initQgis();
220+
221+
// output test environment
222+
QgsApplication::showSettings();
223+
qDebug() << "GDAL version (build): " << GDAL_RELEASE_NAME;
224+
qDebug() << "GDAL version (runtime): " << GDALVersionInfo( "RELEASE_NAME" );
225+
218226
// save data dir
219227
mDataDir = QString( TEST_DATA_DIR ) + QDir::separator();
220228
// Set up the QSettings environment
@@ -370,5 +378,15 @@ void TestZipLayer::testGZipItemRasterTransparency()
370378
QVERIFY2(( myTransparency == myTarget ), QString( "Transparency is %1, should be %2" ).arg( myTransparency ).arg( myTarget ).toLocal8Bit().data() );
371379
}
372380

381+
void TestZipLayer::testZipItemSubfolder()
382+
{
383+
QSettings settings;
384+
for ( int i = 2 ; i <= mMaxScanZipSetting ; i++ )
385+
{
386+
settings.setValue( "/qgis/scanZipInBrowser", i );
387+
QVERIFY( i == settings.value( "/qgis/scanZipInBrowser" ).toInt() );
388+
QVERIFY( testZipItem( mDataDir + "testzip.zip", "folder/folder2/landsat_b2.tif" ) );
389+
}
390+
}
373391
QTEST_MAIN( TestZipLayer )
374392
#include "moc_testziplayer.cxx"

‎tests/testdata/testzip.zip

1.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.