Skip to content

Commit 0cd50ae

Browse files
author
telwertowski
committedJan 16, 2006
Add QgsApplication::qgisUserDbFilePath() accessor. Use it to resume accessing the user db and avoid a crash caused by a switch to the srs db.
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@4699 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed
 

‎src/core/qgsapplication.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
#include "qgsapplication.h"
1818

19+
#include <QDir>
20+
1921
QString QgsApplication::mPrefixPath;
2022
QString QgsApplication::mPluginPath;
2123
QString QgsApplication::mPkgDataPath;
@@ -105,6 +107,14 @@ const QString QgsApplication::qgisMasterDbFilePath()
105107
return mPkgDataPath + QString("/resources/qgis.db");
106108
}
107109

110+
/*!
111+
Returns the path to the user qgis.db file.
112+
*/
113+
const QString QgsApplication::qgisUserDbFilePath()
114+
{
115+
return QDir::homeDirPath() + QString("/.qgis/qgis.db");
116+
}
117+
108118
/*!
109119
Returns the path to the splash screen image directory.
110120
*/

‎src/core/qgsapplication.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ class QgsApplication: public QApplication
4242
//! Returns the path to the master qgis.db file.
4343
static const QString qgisMasterDbFilePath();
4444

45+
//! Returns the path to the user qgis.db file.
46+
static const QString qgisUserDbFilePath();
47+
4548
//! Returns the path to the splash screen image directory.
4649
static const QString splashPath();
4750

‎src/gui/qgsoptions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ void QgsOptions::getEllipsoidList()
264264
sqlite3_stmt *myPreparedStatement;
265265
int myResult;
266266
//check the db is available
267-
myResult = sqlite3_open(QString(QgsApplication::srsDbFilePath()+"qgis.db").latin1(), &myDatabase);
267+
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath(), &myDatabase);
268268
if(myResult)
269269
{
270270
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
@@ -297,7 +297,7 @@ QString QgsOptions::getEllipsoidAcronym(QString theEllipsoidName)
297297
int myResult;
298298
QString myName;
299299
//check the db is available
300-
myResult = sqlite3_open(QString(QgsApplication::srsDbFilePath()+"qgis.db").latin1(), &myDatabase);
300+
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath(), &myDatabase);
301301
if(myResult)
302302
{
303303
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
@@ -329,7 +329,7 @@ QString QgsOptions::getEllipsoidName(QString theEllipsoidAcronym)
329329
int myResult;
330330
QString myName;
331331
//check the db is available
332-
myResult = sqlite3_open((QgsApplication::srsDbFilePath()+"qgis.db").latin1(), &myDatabase);
332+
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath(), &myDatabase);
333333
if(myResult)
334334
{
335335
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;

0 commit comments

Comments
 (0)
Please sign in to comment.