mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 19:11:39 -06:00
Previously all savepoints were added to and deleted from `savepointList`, so some savepoints could not be released, which lead to warnings and errors, e.g. it was impossible to save database or to move newly created row in 'Edit Table' window.
This commit is contained in:
@@ -284,13 +284,22 @@ bool DBBrowserDB::setSavepoint(const QString& pointname)
|
||||
|
||||
bool DBBrowserDB::releaseSavepoint(const QString& pointname)
|
||||
{
|
||||
if(!isOpen() || savepointList.contains(pointname) == false)
|
||||
if(!isOpen())
|
||||
return false;
|
||||
if(savepointList.contains(pointname) == false)
|
||||
// If there is no such savepoint in the list,
|
||||
// we have already released it, so in this case
|
||||
// the operation should be successfull
|
||||
return true;
|
||||
|
||||
QString query = QString("RELEASE %1;").arg(pointname);
|
||||
if(!executeSQL(query, false, false))
|
||||
return false;
|
||||
savepointList.removeAll(pointname);
|
||||
// SQLite releases all savepoints that were created between
|
||||
// creation of given savepoint and releasing of it,
|
||||
// so we should too
|
||||
int point_index = savepointList.lastIndexOf(pointname);
|
||||
savepointList.erase(savepointList.begin()+point_index, savepointList.end());
|
||||
emit dbChanged(getDirty());
|
||||
|
||||
return true;
|
||||
@@ -305,7 +314,11 @@ bool DBBrowserDB::revertToSavepoint(const QString& pointname)
|
||||
executeSQL(query, false, false);
|
||||
query = QString("RELEASE %1;").arg(pointname);
|
||||
executeSQL(query, false, false);
|
||||
savepointList.removeAll(pointname);
|
||||
// SQLite releases all savepoints that were created between
|
||||
// creation of given savepoint and releasing of it,
|
||||
// so we should too
|
||||
int point_index = savepointList.lastIndexOf(pointname);
|
||||
savepointList.erase(savepointList.begin()+point_index, savepointList.end());
|
||||
emit dbChanged(getDirty());
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user