@@ -304,39 +304,33 @@ void QgsSpatiaLiteSourceSelect::addNewConnection()
304
304
// Retrieve last used project dir from persistent settings
305
305
sqlite3 *handle;
306
306
QSettings settings;
307
- QString fullPath;
308
307
QString lastUsedDir = settings.value ( " /UI/lastSpatiaLiteDir" , " ." ).toString ();
309
308
310
309
QString myFile = QFileDialog::getOpenFileName ( this ,
311
- tr ( " Choose a SpatiaLite/SQLite DB to open" ),
312
- lastUsedDir, QObject::tr ( " SQLite DB (*.sqlite);;All files (*.*)" ) );
310
+ tr ( " Choose a SpatiaLite/SQLite DB to open" ),
311
+ lastUsedDir, QObject::tr ( " SQLite DB (*.sqlite);;All files (*.*)" ) );
313
312
314
313
if ( myFile.isEmpty () )
315
- {
316
- QFileInfo myFI ( myFile );
317
- QString myPath = myFI.path ();
318
- QString myName = myFI.fileName ();
314
+ return ;
319
315
320
- handle = openSpatiaLiteDb ( myFI.canonicalFilePath () );
321
- if ( handle )
322
- {
323
- // OK, this one is a valid SpatiaLite DB
324
- closeSpatiaLiteDb ( handle );
325
-
326
- // Persist last used SpatiaLite dir
327
- settings.setValue ( " /UI/lastSpatiaLiteDir" , myPath );
328
- // inserting this SQLite DB path
329
- QString baseKey = " /SpatiaLite/connections/" ;
330
- settings.setValue ( baseKey + " selected" , myName );
331
- baseKey += myName;
332
- settings.setValue ( baseKey + " /sqlitepath" , fullPath );
333
- }
334
- }
335
- else
336
- {
337
- // if they didn't select anything, just return
316
+ QFileInfo myFI ( myFile );
317
+ QString myPath = myFI.path ();
318
+ QString myName = myFI.fileName ();
319
+
320
+ handle = openSpatiaLiteDb ( myFI.canonicalFilePath () );
321
+ if ( !handle )
338
322
return ;
339
- }
323
+
324
+ // OK, this one is a valid SpatiaLite DB
325
+ closeSpatiaLiteDb ( handle );
326
+
327
+ // Persist last used SpatiaLite dir
328
+ settings.setValue ( " /UI/lastSpatiaLiteDir" , myPath );
329
+ // inserting this SQLite DB path
330
+ QString baseKey = " /SpatiaLite/connections/" ;
331
+ settings.setValue ( baseKey + " selected" , myName );
332
+ baseKey += myName;
333
+ settings.setValue ( baseKey + " /sqlitepath" , myFI.canonicalFilePath () );
340
334
341
335
populateConnectionList ();
342
336
}
0 commit comments