Skip to content

Commit 410781c

Browse files
author
g_j_m
committed
Fix for ticket #272 (warning message about not being able to delete a
bookmark when qgis actually did). Also now provides a gui message when it does fail git-svn-id: http://svn.osgeo.org/qgis/trunk@5829 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 76e09e1 commit 410781c

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

src/gui/qgsbookmarks.cpp

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -134,30 +134,21 @@ void QgsBookmarks::on_btnDelete_clicked()
134134
int rc = connectDb();
135135
if(rc == SQLITE_OK)
136136
{
137-
sqlite3_stmt *ppStmt;
138-
const char *pzTail;
137+
char *errmsg;
139138
// build the sql statement
140139
QString sql = "delete from tbl_bookmarks where bookmark_id = " + lvi->text(3);
141-
rc = sqlite3_prepare(db, sql.utf8(), sql.length(), &ppStmt, &pzTail);
142-
if(rc == SQLITE_OK)
140+
rc = sqlite3_exec(db, sql.utf8(), NULL, NULL, &errmsg);
141+
if(rc != SQLITE_OK)
143142
{
144-
rc = sqlite3_step(ppStmt);
145-
if(rc != SQLITE_OK)
146-
{
147-
// XXX Provide popup message on failure?
148-
std::cout << "Failed to delete " << lvi->text(0).toLocal8Bit().data()
149-
<< " bookmark from the database" << std::endl;
150-
}
151-
else
152-
{
153-
// XXX Provide popup message on failure?
154-
std::cout << "Failed to delete " << lvi->text(0).toLocal8Bit().data()
155-
<< " bookmark from the database" << std::endl;
156-
}
143+
// XXX Provide popup message on failure?
144+
QMessageBox::warning(this, tr("Error deleting bookmark"),
145+
tr("Failed to delete the ") +
146+
lvi->text(0) +
147+
tr(" bookmark from the database. The "
148+
"database said:\n") + QString(errmsg),
149+
QMessageBox::Ok, QMessageBox::NoButton);
150+
sqlite3_free(errmsg);
157151
}
158-
159-
// close the statement
160-
sqlite3_finalize(ppStmt);
161152
// close the database
162153
sqlite3_close(db);
163154
}

0 commit comments

Comments
 (0)