Skip to content

Commit e7ff164

Browse files
author
jef
committed
fix qml support for non-file data sources
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@9019 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 49969cc commit e7ff164

File tree

3 files changed

+29
-33
lines changed

3 files changed

+29
-33
lines changed

src/app/qgsbookmarks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ int QgsBookmarks::connectDb()
251251

252252
int rc;
253253
rc = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &db);
254-
if(rc)
254+
if(rc!=SQLITE_OK)
255255
{
256256
std::cout << "Can't open database: " << sqlite3_errmsg(db) << std::endl;
257257

src/app/qgscustomprojectiondialog.cpp

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,13 @@ void QgsCustomProjectionDialog::getProjList ()
105105
int myResult;
106106
//check the db is available
107107
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
108-
if(myResult)
108+
if(myResult!=SQLITE_OK)
109109
{
110110
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
111111
// XXX This will likely never happen since on open, sqlite creates the
112112
// database if it does not exist.
113-
assert(myResult == 0);
113+
assert(myResult == SQLITE_OK);
114114
}
115-
116115
// Set up the query to retrieve the projection information needed to populate the PROJECTION list
117116
QString mySql = "select * from tbl_projection order by name";
118117
myResult = sqlite3_prepare(myDatabase, mySql.toUtf8(), mySql.length(), &myPreparedStatement, &myTail);
@@ -140,14 +139,13 @@ void QgsCustomProjectionDialog::getEllipsoidList()
140139
int myResult;
141140
//check the db is available
142141
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
143-
if(myResult)
142+
if(myResult!=SQLITE_OK)
144143
{
145144
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
146145
// XXX This will likely never happen since on open, sqlite creates the
147146
// database if it does not exist.
148-
assert(myResult == 0);
147+
assert(myResult == SQLITE_OK);
149148
}
150-
151149
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
152150
QString mySql = "select * from tbl_ellipsoid order by name";
153151
myResult = sqlite3_prepare(myDatabase, mySql.toUtf8(), mySql.length(), &myPreparedStatement, &myTail);
@@ -184,12 +182,12 @@ void QgsCustomProjectionDialog::on_pbnDelete_clicked()
184182
QString myName;
185183
//check the db is available
186184
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
187-
if(myResult)
185+
if(myResult!=SQLITE_OK)
188186
{
189187
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
190188
// XXX This will likely never happen since on open, sqlite creates the
191189
// database if it does not exist.
192-
assert(myResult == 0);
190+
assert(myResult == SQLITE_OK);
193191
}
194192
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
195193
QString mySql = "delete from tbl_srs where srs_id='" + mCurrentRecordId + "'";
@@ -244,12 +242,12 @@ long QgsCustomProjectionDialog::getRecordCount()
244242
long myRecordCount=0;
245243
//check the db is available
246244
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
247-
if(myResult)
245+
if(myResult!=SQLITE_OK)
248246
{
249247
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
250248
// XXX This will likely never happen since on open, sqlite creates the
251249
// database if it does not exist.
252-
assert(myResult == 0);
250+
assert(myResult == SQLITE_OK);
253251
}
254252
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
255253
QString mySql = "select count(*) from tbl_srs";
@@ -279,12 +277,12 @@ QString QgsCustomProjectionDialog::getProjectionFamilyName(QString theProjection
279277
QString myName;
280278
//check the db is available
281279
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
282-
if(myResult)
280+
if(myResult!=SQLITE_OK)
283281
{
284282
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
285283
// XXX This will likely never happen since on open, sqlite creates the
286284
// database if it does not exist.
287-
assert(myResult == 0);
285+
assert(myResult == SQLITE_OK);
288286
}
289287
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
290288
QString mySql = "select name from tbl_projection where acronym='" + theProjectionFamilyAcronym + "'";
@@ -310,12 +308,12 @@ QString QgsCustomProjectionDialog::getEllipsoidName(QString theEllipsoidAcronym)
310308
QString myName;
311309
//check the db is available
312310
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
313-
if(myResult)
311+
if(myResult!=SQLITE_OK)
314312
{
315313
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
316314
// XXX This will likely never happen since on open, sqlite creates the
317315
// database if it does not exist.
318-
assert(myResult == 0);
316+
assert(myResult == SQLITE_OK);
319317
}
320318
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
321319
QString mySql = "select name from tbl_ellipsoid where acronym='" + theEllipsoidAcronym + "'";
@@ -341,12 +339,12 @@ QString QgsCustomProjectionDialog::getProjectionFamilyAcronym(QString theProject
341339
QString myName;
342340
//check the db is available
343341
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
344-
if(myResult)
342+
if(myResult!=SQLITE_OK)
345343
{
346344
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
347345
// XXX This will likely never happen since on open, sqlite creates the
348346
// database if it does not exist.
349-
assert(myResult == 0);
347+
assert(myResult == SQLITE_OK);
350348
}
351349
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
352350
QString mySql = "select acronym from tbl_projection where name='" + theProjectionFamilyName + "'";
@@ -372,12 +370,12 @@ QString QgsCustomProjectionDialog::getEllipsoidAcronym(QString theEllipsoidName)
372370
QString myName;
373371
//check the db is available
374372
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
375-
if(myResult)
373+
if(myResult!=SQLITE_OK)
376374
{
377375
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
378376
// XXX This will likely never happen since on open, sqlite creates the
379377
// database if it does not exist.
380-
assert(myResult == 0);
378+
assert(myResult == SQLITE_OK);
381379
}
382380
// Set up the query to retrieve the projection information needed to populate the ELLIPSOID list
383381
QString mySql = "select acronym from tbl_ellipsoid where name='" + theEllipsoidName + "'";
@@ -406,12 +404,12 @@ void QgsCustomProjectionDialog::on_pbnFirst_clicked()
406404
int myResult;
407405
//check the db is available
408406
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
409-
if(myResult)
407+
if(myResult!=SQLITE_OK)
410408
{
411409
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
412410
// XXX This will likely never happen since on open, sqlite creates the
413411
// database if it does not exist.
414-
assert(myResult == 0);
412+
assert(myResult == SQLITE_OK);
415413
}
416414

417415
QString mySql = "select * from tbl_srs order by srs_id limit 1";
@@ -484,12 +482,12 @@ void QgsCustomProjectionDialog::on_pbnPrevious_clicked()
484482
int myResult;
485483
//check the db is available
486484
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
487-
if(myResult)
485+
if(myResult!=SQLITE_OK)
488486
{
489487
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
490488
// XXX This will likely never happen since on open, sqlite creates the
491489
// database if it does not exist.
492-
assert(myResult == 0);
490+
assert(myResult == SQLITE_OK);
493491
}
494492

495493
QString mySql = "select * from tbl_srs where srs_id < " + mCurrentRecordId + " order by srs_id desc limit 1";
@@ -563,15 +561,14 @@ void QgsCustomProjectionDialog::on_pbnNext_clicked()
563561
int myResult;
564562
//check the db is available
565563
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
566-
if(myResult)
564+
if(myResult!=SQLITE_OK)
567565
{
568566
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
569567
// XXX This will likely never happen since on open, sqlite creates the
570568
// database if it does not exist.
571-
assert(myResult == 0);
569+
assert(myResult == SQLITE_OK);
572570
}
573571

574-
575572
QString mySql = "select * from tbl_srs where srs_id > " + mCurrentRecordId + " order by srs_id asc limit 1";
576573
#ifdef QGISDEBUG
577574
std::cout << "Query to move next:" << mySql.toLocal8Bit().data() << std::endl;
@@ -639,12 +636,12 @@ void QgsCustomProjectionDialog::on_pbnLast_clicked()
639636
int myResult;
640637
//check the db is available
641638
myResult = sqlite3_open(QgsApplication::qgisUserDbFilePath().toUtf8().data(), &myDatabase);
642-
if(myResult)
639+
if(myResult!=SQLITE_OK)
643640
{
644641
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
645642
// XXX This will likely never happen since on open, sqlite creates the
646643
// database if it does not exist.
647-
assert(myResult == 0);
644+
assert(myResult == SQLITE_OK);
648645
}
649646

650647
QString mySql = "select * from tbl_srs order by srs_id desc limit 1";
@@ -868,7 +865,7 @@ void QgsCustomProjectionDialog::on_pbnSave_clicked()
868865
<< std::endl;
869866
// XXX This will likely never happen since on open, sqlite creates the
870867
// database if it does not exist.
871-
assert(myResult == 0);
868+
assert(myResult == SQLITE_OK);
872869
}
873870
#ifdef QGISDEBUG
874871
std::cout << "Update or insert sql \n" << mySql.toLocal8Bit().data() << std::endl;
@@ -993,9 +990,8 @@ void QgsCustomProjectionDialog::cboProjectionFamily_highlighted( const QString &
993990
std::cout << "Can't open database: " << sqlite3_errmsg(myDatabase) << std::endl;
994991
// XXX This will likely never happen since on open, sqlite creates the
995992
// database if it does not exist.
996-
assert(myResult == 0);
993+
assert(myResult == SQLITE_OK);
997994
}
998-
999995
// Set up the query to retrieve the projection information needed to populate the PROJECTION list
1000996
QString mySql = "select parameters from tbl_projection name where name='"+theText+"'";
1001997
#ifdef QGISDEBUG

src/core/qgsmaplayer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ bool QgsMapLayer::loadNamedStyleFromDb (const QString db, const QString theURI,
434434
QgsDebugMsg( QString("Trying to load style for \"%1\" from \"%2\"").arg(theURI).arg(db) );
435435

436436
myResult = sqlite3_open(db.toUtf8().data(), &myDatabase);
437-
if (!myResult)
437+
if (myResult!=SQLITE_OK)
438438
{
439439
return false;
440440
}
@@ -610,7 +610,7 @@ QString QgsMapLayer::saveNamedStyle ( const QString theURI, bool & theResultFlag
610610
int myResult;
611611

612612
myResult = sqlite3_open( QDir( QgsApplication::qgisSettingsDirPath() ).absoluteFilePath( "qgis.qmldb").toUtf8().data(), &myDatabase);
613-
if (myResult)
613+
if (myResult!=SQLITE_OK)
614614
{
615615
return tr("User database could not be opened.");
616616
}

0 commit comments

Comments
 (0)